bitbot-3.11-fork/modules/signals.py

24 lines
727 B
Python
Raw Normal View History

2016-03-29 11:56:58 +00:00
import signal
class Module(object):
def __init__(self, bot):
self.bot = bot
signal.signal(signal.SIGINT, self.SIGINT)
signal.signal(signal.SIGUSR1, self.SIGUSR1)
def SIGINT(self, signum, frame):
print()
2017-09-05 19:50:20 +00:00
self.bot.events.on("signal").on("interrupt").call(signum=signum, frame=frame)
2016-03-29 11:56:58 +00:00
for server in self.bot.servers.values():
quote = self.bot.events.on("get.quit-quote"
).call_for_result(default="Leaving")
2018-07-15 14:09:11 +00:00
server.send_quit(quote)
2016-03-29 11:56:58 +00:00
self.bot.register_write(server)
2016-03-29 11:56:58 +00:00
self.bot.running = False
def SIGUSR1(self, signum, frame):
print("Reloading config file")
self.bot.config_object.load_config()