Break out react api call to separate function.
This commit is contained in:
parent
6ddfd96f7d
commit
6e5f8052ea
@ -108,6 +108,14 @@ def reactable_string(text):
|
|||||||
reactable_array.append('flavortown')
|
reactable_array.append('flavortown')
|
||||||
return reactable_array
|
return reactable_array
|
||||||
|
|
||||||
|
def react_to_message(reaction):
|
||||||
|
slack_client.api_call(
|
||||||
|
'reactions.add',
|
||||||
|
channel = get_channel_ID("inmyimo"),
|
||||||
|
name = reaction,
|
||||||
|
timestamp = event.get('ts')
|
||||||
|
)
|
||||||
|
|
||||||
def get_channel_ID(channelName):
|
def get_channel_ID(channelName):
|
||||||
for channel in slack_client.api_call('channels.list')["channels"]:
|
for channel in slack_client.api_call('channels.list')["channels"]:
|
||||||
if channel["name"] == channelName:
|
if channel["name"] == channelName:
|
||||||
@ -131,41 +139,13 @@ if __name__ == "__main__":
|
|||||||
text = event['text']
|
text = event['text']
|
||||||
reactions_needed = reactable_string(text)
|
reactions_needed = reactable_string(text)
|
||||||
if 'ai' in reactions_needed:
|
if 'ai' in reactions_needed:
|
||||||
print(event.get('ts')) # does this populate
|
react_to_message("robot_face")
|
||||||
slack_client.api_call(
|
|
||||||
'reactions.add',
|
|
||||||
channel = get_channel_ID("inmyimo"),
|
|
||||||
name = "robot_face",
|
|
||||||
timestamp = event.get('ts')
|
|
||||||
)
|
|
||||||
if 'furry' in reactions_needed:
|
if 'furry' in reactions_needed:
|
||||||
print(event.get('ts')) # does this populate
|
react_to_message("eggplant")
|
||||||
slack_client.api_call(
|
react_to_message("sweat_drops")
|
||||||
'reactions.add',
|
|
||||||
channel = get_channel_ID("inmyimo"),
|
|
||||||
name = "eggplant",
|
|
||||||
timestamp = event.get('ts')
|
|
||||||
)
|
|
||||||
slack_client.api_call(
|
|
||||||
'reactions.add',
|
|
||||||
channel = get_channel_ID("inmyimo"),
|
|
||||||
name = "sweat_drops",
|
|
||||||
timestamp = event.get('ts')
|
|
||||||
)
|
|
||||||
if 'flavortown' in reactions_needed:
|
if 'flavortown' in reactions_needed:
|
||||||
print(event.get('ts')) # does this populate
|
react_to_message("dark_sunglasses")
|
||||||
slack_client.api_call(
|
react_to_message("guyfieri")
|
||||||
'reactions.add',
|
|
||||||
channel = get_channel_ID("inmyimo"),
|
|
||||||
name = "dark_sunglasses",
|
|
||||||
timestamp = event.get('ts')
|
|
||||||
)
|
|
||||||
slack_client.api_call(
|
|
||||||
'reactions.add',
|
|
||||||
channel = get_channel_ID("inmyimo"),
|
|
||||||
name = "guyfieri",
|
|
||||||
timestamp = event.get('ts')
|
|
||||||
)
|
|
||||||
time.sleep(RTM_READ_DELAY)
|
time.sleep(RTM_READ_DELAY)
|
||||||
logging.info("Client worked. No errors (we think lol)")
|
logging.info("Client worked. No errors (we think lol)")
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user