Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion pybot/endpoints/slack/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def create_endpoints(plugin):
plugin.on_message(".*@here", here_bad)
plugin.on_message(".*@channel", here_bad)
plugin.on_message(".*\!pybot", advertise_pybot)
plugin.on_message("=== .* Daily Programmer ===.*", daily_challenge)


def not_bot_message(event: Message):
Expand All @@ -32,7 +33,7 @@ async def advertise_pybot(event: Message, app: SirBot):
BOT_URL = 'https://github.com/OperationCode/operationcode-pybot'
response = {'channel': event['channel'],
'text': f'OC-Community-Bot is a community led project'
f'\n <{BOT_URL}|source> '}
f'\n <{BOT_URL}|source> '}
await app.plugins["slack"].api.query(methods.CHAT_POST_MESSAGE, data=response)


Expand Down Expand Up @@ -81,3 +82,19 @@ async def message_deleted(event: Message, app: SirBot):
except Exception as E:
logger.exception(E)
logger.debug(event)


async def daily_challenge(event: Message, app: SirBot):
"""
Pings general with the new Daily Challenge as well as saves it to a text file.
Planning on adding a link to the new challenge but this will come later.
"""
new_message = event["text"]
f = open("DailyChallenges.txt", "w+")
f.write(new_message + "\n")
f.close()
response = {
'channel': 'general',
'text': 'New Daily Programmer challenge check out #Daily-programmer'
}
await app.plugins["slack"].api.query(methods.CHAT_POST_MESSAGE, data=response)