forked from Motoko11/motobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdesutest.py
40 lines (34 loc) · 945 Bytes
/
desutest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from motobot import IRCBot, IRCLevel
from json import load
from threading import Thread
import traceback
def thread_func(bot):
def worker():
bot.run()
return worker
def main():
config_filename = 'desutest_config.json'
config_file = open(config_filename, 'r')
config = load(config_file)
bot = IRCBot(config)
bot.load_plugins('plugins')
bot.load_database('desutest.json')
thread = Thread(target=thread_func(bot))
thread.start()
running = True
while running:
try:
msg = input()
if msg.startswith(':'):
bot.reload_plugins()
elif msg.startswith('?'):
bot.load_database('desubot.json')
else:
bot.send(msg)
except KeyboardInterrupt:
running = False
bot.disconnect()
except:
traceback.print_exc()
if __name__ == '__main__':
main()