89 lines
3.5 KiB
Python
89 lines
3.5 KiB
Python
import asyncio
|
|
import textwrap
|
|
from typing import Match
|
|
|
|
from slackclient import SlackClient
|
|
|
|
import channel_util
|
|
import client_wrapper
|
|
import identifier
|
|
import job_commands
|
|
import management_commands
|
|
import scroll_util
|
|
import slack_util
|
|
import slavestothemachine
|
|
|
|
|
|
def main() -> None:
|
|
wrap = client_wrapper.get_client_wrapper()
|
|
|
|
# Add scroll handling
|
|
wrap.add_hook(scroll_util.scroll_hook)
|
|
|
|
# Add id handling
|
|
wrap.add_hook(identifier.check_hook)
|
|
wrap.add_hook(identifier.identify_hook)
|
|
wrap.add_hook(identifier.identify_other_hook)
|
|
wrap.add_hook(identifier.name_hook)
|
|
|
|
# Added channel utility
|
|
wrap.add_hook(channel_util.channel_check_hook)
|
|
|
|
# Add kill switch
|
|
wrap.add_hook(management_commands.reboot_hook)
|
|
|
|
# Add towel rolling
|
|
wrap.add_hook(slavestothemachine.count_work_hook)
|
|
wrap.add_hook(slavestothemachine.dump_work_hook)
|
|
|
|
# Add job management
|
|
wrap.add_hook(job_commands.signoff_hook)
|
|
wrap.add_hook(job_commands.late_hook)
|
|
wrap.add_hook(job_commands.reset_hook)
|
|
wrap.add_hook(job_commands.nag_hook)
|
|
|
|
# Add help
|
|
wrap.add_hook(slack_util.Hook(help_callback, pattern=management_commands.bot_help_pattern))
|
|
|
|
# Add boozebot
|
|
# wrap.add_passive(periodicals.ItsTenPM())
|
|
|
|
event_loop = asyncio.get_event_loop()
|
|
event_loop.set_debug(True)
|
|
message_handling = wrap.respond_messages()
|
|
passive_handling = wrap.run_passives()
|
|
both = asyncio.gather(message_handling, passive_handling)
|
|
event_loop.run_until_complete(both)
|
|
|
|
|
|
async def help_callback(slack: SlackClient, msg: dict, match: Match) -> None:
|
|
slack_util.reply(slack, msg, textwrap.dedent("""
|
|
Commands are as follows. Note that some only work in certain channels.
|
|
"my scroll is <number>" : Registers your slack account to have a certain scroll, for the purpose of automatic dm's.
|
|
"@person has scroll <number>" : same as above, but for other users. Helpful if they are being obstinate.
|
|
"what is my scroll" : Echos back what the bot thinks your scroll is. Largely for debugging.
|
|
"what is my name" : Echos back what the bot thinks your name is. Largely for debugging. If you want to change this, you'll need to fix the "Sorted family tree" file that the bot reads. Sorry.
|
|
"channel id #wherever" : Debug command to get a slack channels full ID
|
|
"reboot" : Restarts the server.
|
|
"dump towel data" : Summarize the towel roller work for the week, and reset it.
|
|
"signoff <John Doe>" : Sign off a brother's house job. Will prompt for more information if needed.
|
|
"marklate <John Doe>" : Same as above, but to mark a job as being completed but having been done late.
|
|
IN PROGRESS: "reassign <John Doe> -> <James Deer>" : Reassign a house job.
|
|
"nagjobs <day>" : Notify in general the house jobs for the week.
|
|
"reset signoffs" : Clear points for the week, and undo all signoffs. Not frequently useful.
|
|
"help" : You stupid or something? You're reading it. This is all it does. What do you want from me?
|
|
|
|
---
|
|
|
|
Also of note is that in #slavestothemachine, any wording of the format "replaced <number>", or similarly with "washed", "dried", "rolled", or "flaked", will track your effort for the week.
|
|
|
|
Github is https://github.com/TheVillageIdiot2/waitonbot
|
|
Man in charge is Jacob Henry, but nothing lasts forever.
|
|
"""))
|
|
# Do not let my efforts fall to waste. Its a pitious legacy but its something, at least, to maybe tide the
|
|
# unending flow of work for poor Niko.
|
|
|
|
# run main
|
|
if __name__ == '__main__':
|
|
main()
|