2016-03-29 11:56:58 +00:00
|
|
|
import signal
|
2018-09-24 14:13:27 +00:00
|
|
|
from src import Config
|
2016-03-29 11:56:58 +00:00
|
|
|
|
|
|
|
class Module(object):
|
2018-09-02 18:54:45 +00:00
|
|
|
def __init__(self, bot, events, exports):
|
2016-03-29 11:56:58 +00:00
|
|
|
self.bot = bot
|
2018-08-31 11:55:52 +00:00
|
|
|
self.events = events
|
2016-03-29 11:56:58 +00:00
|
|
|
signal.signal(signal.SIGINT, self.SIGINT)
|
|
|
|
signal.signal(signal.SIGUSR1, self.SIGUSR1)
|
|
|
|
|
|
|
|
def SIGINT(self, signum, frame):
|
|
|
|
print()
|
2018-09-19 12:25:12 +00:00
|
|
|
self.events.on("signal.interrupt").call(signum=signum, frame=frame)
|
2018-07-15 14:15:52 +00:00
|
|
|
|
2016-03-29 11:56:58 +00:00
|
|
|
for server in self.bot.servers.values():
|
2018-08-13 15:04:27 +00:00
|
|
|
reason = "Leaving"
|
|
|
|
if server.get_setting("quit-quote", True):
|
2018-08-31 11:55:52 +00:00
|
|
|
reason = self.events.on("get.quit-quote"
|
2018-08-13 15:04:27 +00:00
|
|
|
).call_for_result(default="Leaving")
|
|
|
|
server.send_quit(reason)
|
2016-03-29 11:56:58 +00:00
|
|
|
self.bot.register_write(server)
|
2018-07-15 14:15:52 +00:00
|
|
|
|
2016-03-29 11:56:58 +00:00
|
|
|
self.bot.running = False
|
|
|
|
|
|
|
|
def SIGUSR1(self, signum, frame):
|
2018-09-02 10:43:52 +00:00
|
|
|
self.bot.log.info("Reloading config file", [])
|
2018-09-29 19:27:20 +00:00
|
|
|
self.bot.config.load()
|
2018-09-02 10:43:52 +00:00
|
|
|
self.bot.log.info("Reloaded config file", [])
|