Skip to content

Commit 065c54c

Browse files
committed
Add IM channel_type check to @here message
1 parent 9eaaaf8 commit 065c54c

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

pybot/endpoints/slack/commands.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ async def slash_repeat(command: Command, app: SirBot):
142142
method_type, message = get_slash_repeat_messages(slack_id, channel_id, command['text'])
143143
await slack.query(method_type, message)
144144

145+
145146
async def slash_roll(command: Command, app: SirBot):
146147
"""
147148
Sends text supplied with the /report command to the moderators channel along
@@ -153,7 +154,7 @@ async def slash_roll(command: Command, app: SirBot):
153154

154155
slack = app["plugins"]["slack"].api
155156

156-
#parse the type of die and number to roll
157+
# parse the type of die and number to roll
157158
try:
158159
text = text.lower()
159160
numdice, typedice = text.split('d')
@@ -165,13 +166,13 @@ async def slash_roll(command: Command, app: SirBot):
165166
raise ValueError
166167
except ValueError:
167168
logger.debug("invalid input to roll: %s", text)
168-
await slack.query(methods.CHAT_POST_EPHEMERAL,
169+
await slack.query(methods.CHAT_POST_EPHEMERAL,
169170
{'user': slack_id, 'channel': channel_id,
170171
'text': "Sorry, I didn't understand your input. Should be XDYY where X is the number of dice, and YY is the number of sides"})
171172
return
172173
dice = []
173-
for _ in range(0,numdice):
174-
dice.append(random.randint(1,typedice+1))
174+
for _ in range(0, numdice):
175+
dice.append(random.randint(1, typedice + 1))
175176

176-
message = f'<@{slack_id}> Rolled {numdice} D{typedice}: {dice}'
177+
message = f'<@{slack_id}> Rolled {numdice} D{typedice}: {dice}'
177178
await slack.query(methods.CHAT_POST_MESSAGE, {'channel': channel_id, 'text': message})

pybot/endpoints/slack/messages.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ async def advertise_pybot(event: Message, app: SirBot):
3939

4040

4141
async def here_bad(event: Message, app: SirBot):
42-
response = {'channel': event['channel'],
43-
'text': f'<@{event["user"]}> - you are a very bad person for using that command'}
44-
await app.plugins["slack"].api.query(methods.CHAT_POST_MESSAGE, data=response)
42+
if 'channel_type' in event and event['channel_type'] != 'im':
43+
response = {'channel': event['channel'],
44+
'text': f'<@{event["user"]}> - you are a very bad person for using that command'}
45+
await app.plugins["slack"].api.query(methods.CHAT_POST_MESSAGE, data=response)
4546

4647

4748
async def tech_tips(event: Message, app: SirBot):

0 commit comments

Comments
 (0)