|
|
|
@ -1053,8 +1053,12 @@ def discordbot_ensure_irc_presence():
|
|
|
|
|
'{} is gone! Attempting to restart...'.format(nickname)
|
|
|
|
|
)
|
|
|
|
|
cfg['attempts'] += 1
|
|
|
|
|
# TODO: Replace this with a JSON API call to discordbotctld.
|
|
|
|
|
subprocess.call(cfg['restart_shell_command'], shell=True)
|
|
|
|
|
r = requests.get(
|
|
|
|
|
cfg['api_url'] + "/restart",
|
|
|
|
|
headers={'ApiKey': cfg['api_key']}
|
|
|
|
|
)
|
|
|
|
|
if r.status_code != 200:
|
|
|
|
|
print("discordbot_autorstart: http_status={}".format(r.status_code))
|
|
|
|
|
|
|
|
|
|
def discordbot_on_ensure_irc_presence(data, remaining_calls):
|
|
|
|
|
discordbot_ensure_irc_presence()
|
|
|
|
@ -1346,10 +1350,15 @@ def load_cfg_mod_discordbot(cfg):
|
|
|
|
|
users_to_notify.setdefault('irc', [])
|
|
|
|
|
users_to_notify.setdefault('discord', [])
|
|
|
|
|
# TODO: Use just .keys() in Python 3.
|
|
|
|
|
if (autorestart.viewkeys() < {'discord_webhook_url',
|
|
|
|
|
'monitored_irc_server', 'monitored_irc_channel',
|
|
|
|
|
'max_attempts', 'restart_shell_command',
|
|
|
|
|
'webhook_shell_command'}):
|
|
|
|
|
if (autorestart.viewkeys() < {
|
|
|
|
|
'api_key',
|
|
|
|
|
'api_url',
|
|
|
|
|
'discord_webhook_url',
|
|
|
|
|
'monitored_irc_server',
|
|
|
|
|
'monitored_irc_channel',
|
|
|
|
|
'max_attempts',
|
|
|
|
|
'webhook_shell_command'
|
|
|
|
|
}):
|
|
|
|
|
raise KeyError()
|
|
|
|
|
except (KeyError, TypeError):
|
|
|
|
|
return False
|
|
|
|
|