Moved some manually-checked channel priveleges to blacklist mode
This commit is contained in:
parent
e6ec258466
commit
b925854cc5
|
|
@ -8,8 +8,6 @@ COMMAND_CENTER_ID = "GCR631LQ1"
|
||||||
SLAVES_TO_THE_MACHINE_ID = "C9WUQBYNP"
|
SLAVES_TO_THE_MACHINE_ID = "C9WUQBYNP"
|
||||||
BOTZONE = "C3BF2MFKM"
|
BOTZONE = "C3BF2MFKM"
|
||||||
|
|
||||||
NOT_ALLOWED_HERE = "There's a time and place for everything, but not here!"
|
|
||||||
|
|
||||||
|
|
||||||
# Callback for telling what channel we in
|
# Callback for telling what channel we in
|
||||||
def channel_check_callback(slack, msg, match):
|
def channel_check_callback(slack, msg, match):
|
||||||
|
|
|
||||||
|
|
@ -20,38 +20,34 @@ class Job(object):
|
||||||
|
|
||||||
|
|
||||||
def nag_callback(slack, msg, match):
|
def nag_callback(slack, msg, match):
|
||||||
# Only allow in command center
|
# Get the day
|
||||||
if msg["channel"] != channel_util.COMMAND_CENTER_ID:
|
day = match.group(1).lower().strip()
|
||||||
response = channel_util.NOT_ALLOWED_HERE
|
|
||||||
else:
|
|
||||||
# Get the day
|
|
||||||
day = match.group(1).lower().strip()
|
|
||||||
|
|
||||||
# Get the spreadsheet section
|
# Get the spreadsheet section
|
||||||
eight_jobs = google_api.get_sheet_range(SHEET_ID, eight_job_range)
|
eight_jobs = google_api.get_sheet_range(SHEET_ID, eight_job_range)
|
||||||
ft_jobs = google_api.get_sheet_range(SHEET_ID, fiftythree_job_range)
|
ft_jobs = google_api.get_sheet_range(SHEET_ID, fiftythree_job_range)
|
||||||
|
|
||||||
# Turn to job objects
|
# Turn to job objects
|
||||||
eight_jobs = [Job("8", *r) for r in eight_jobs]
|
eight_jobs = [Job("8", *r) for r in eight_jobs]
|
||||||
ft_jobs = [Job("53", *r) for r in ft_jobs]
|
ft_jobs = [Job("53", *r) for r in ft_jobs]
|
||||||
jobs = eight_jobs + ft_jobs
|
jobs = eight_jobs + ft_jobs
|
||||||
|
|
||||||
# Filter to day
|
# Filter to day
|
||||||
jobs = [j for j in jobs if j.day == day]
|
jobs = [j for j in jobs if j.day == day]
|
||||||
|
|
||||||
# Nag each
|
# Nag each
|
||||||
response = "Do yer jerbs! They are as follows:\n"
|
response = "Do yer jerbs! They are as follows:\n"
|
||||||
for job in jobs:
|
for job in jobs:
|
||||||
response += "({}) {} -- ".format(job.house, job.job_name)
|
response += "({}) {} -- ".format(job.house, job.job_name)
|
||||||
ids = job.lookup_brother_slack_id()
|
ids = job.lookup_brother_slack_id()
|
||||||
if ids:
|
if ids:
|
||||||
for slack_id in ids:
|
for slack_id in ids:
|
||||||
response += "<@{}> ".format(slack_id)
|
response += "<@{}> ".format(slack_id)
|
||||||
else:
|
else:
|
||||||
response += "{} (scroll missing. Please register for @ pings!)".format(job.brother_name)
|
response += "{} (scroll missing. Please register for @ pings!)".format(job.brother_name)
|
||||||
response += "\n"
|
response += "\n"
|
||||||
|
|
||||||
slack_util.reply(slack, msg, response, in_thread=False, to_channel=channel_util.GENERAL)
|
slack_util.reply(slack, msg, response, in_thread=False, to_channel=channel_util.GENERAL)
|
||||||
|
|
||||||
|
|
||||||
nag_hook = slack_util.Hook(nag_callback, pattern=r"nagjobs\s*(.*)")
|
nag_hook = slack_util.Hook(nag_callback, pattern=r"nagjobs\s*(.*)", channel_whitelist=[channel_util.COMMAND_CENTER_ID])
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,11 @@ def list_hooks_callback_gen(hooks):
|
||||||
# Gracefully reboot to reload code changes
|
# Gracefully reboot to reload code changes
|
||||||
# noinspection PyUnusedLocal
|
# noinspection PyUnusedLocal
|
||||||
def reboot_callback(slack, msg, match):
|
def reboot_callback(slack, msg, match):
|
||||||
if msg["channel"] != channel_util.COMMAND_CENTER_ID:
|
response = "Ok. Rebooting..."
|
||||||
response = channel_util.NOT_ALLOWED_HERE
|
|
||||||
reboot = False
|
|
||||||
else:
|
|
||||||
response = "Ok. Rebooting..."
|
|
||||||
reboot = True
|
|
||||||
|
|
||||||
slack_util.reply(slack, msg, response)
|
slack_util.reply(slack, msg, response)
|
||||||
if reboot:
|
exit(0)
|
||||||
exit(0)
|
|
||||||
|
|
||||||
|
|
||||||
# Make hooks
|
# Make hooks
|
||||||
bot_help_pattern = r"bot help" # Can't init this directly, as it relies on us knowing all other hooks. handle in main
|
bot_help_pattern = r"bot help" # Can't init this directly, as it relies on us knowing all other hooks. handle in main
|
||||||
reboot_hook = slack_util.Hook(reboot_callback, pattern=r"reboot")
|
reboot_hook = slack_util.Hook(reboot_callback, pattern=r"reboot", channel_whitelist=[channel_util.COMMAND_CENTER_ID])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue