diff options
author | Ryan Huber <rhuber@gmail.com> | 2016-04-22 07:28:09 -0700 |
---|---|---|
committer | Ryan Huber <rhuber@gmail.com> | 2016-04-22 07:28:09 -0700 |
commit | 4bedc30a4cfe4ff6aba9d1339a8da1305ea12ad8 (patch) | |
tree | 407e87274939c5089f4194b7b8e3c51e58e7b9d6 /wee_slack.py | |
parent | 885df2b0a40b12010c229761024f0ceb896c5c1e (diff) | |
parent | 6004ca6c05c2b61b4abec868577bdf391e3f6c93 (diff) | |
download | wee-slack-4bedc30a4cfe4ff6aba9d1339a8da1305ea12ad8.tar.gz |
Merge pull request #210 from rawdigits/integration-bot-name-print
Print out the name of the user when enabling/disabling integrations
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py index cff2c01..ab41b37 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -1528,6 +1528,25 @@ def process_user_typing(message_json): channel.set_typing(server.users.find(message_json["user"]).name) +def process_bot_enable(message_json): + process_bot_integration(message_json) + + +def process_bot_disable(message_json): + process_bot_integration(message_json) + + +def process_bot_integration(message_json): + server = servers.find(message_json["_server"]) + channel = server.channels.find(message_json["channel"]) + + time = message_json['ts'] + text = "{} {}".format(server.users.find(message_json['user']).formatted_name(), + render_message(message_json)) + bot_name = get_user(message_json, server) + bot_name = bot_name.encode('utf-8') + channel.buffer_prnt(bot_name, text, time) + # todo: does this work? def process_error(message_json): @@ -1626,7 +1645,7 @@ def render_message(message_json, force=False): def process_message(message_json, cache=True): try: # send these subtype messages elsewhere - known_subtypes = ["message_changed", 'message_deleted', 'channel_join', 'channel_leave', 'channel_topic'] + known_subtypes = ["message_changed", 'message_deleted', 'channel_join', 'channel_leave', 'channel_topic', 'bot_enable', 'bot_disable'] if "subtype" in message_json and message_json["subtype"] in known_subtypes: proc[message_json["subtype"]](message_json) |