diff options
author | Tollef Fog Heen <tfheen@err.no> | 2016-03-11 16:43:42 +0100 |
---|---|---|
committer | Tollef Fog Heen <tfheen@err.no> | 2016-03-11 16:43:42 +0100 |
commit | 602ecac2b09aaa616361f37f7036e2816cab1f11 (patch) | |
tree | 49890eff6dbb7ba49b083d9e85d53f02573b1866 /wee_slack.py | |
parent | d02a8d2d16cb8f4378c63259b7575945ad71aed9 (diff) | |
parent | 35ad9fdb539c40aa77f73e056fd369e6b740073e (diff) | |
download | wee-slack-602ecac2b09aaa616361f37f7036e2816cab1f11.tar.gz |
Merge pull request #172 from rawdigits/msg-support
Implement support for /msg user message
Diffstat (limited to 'wee_slack.py')
-rw-r--r-- | wee_slack.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/wee_slack.py b/wee_slack.py index cc7c7cd..c258fb4 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -984,6 +984,23 @@ def slack_buffer_required(f): @slack_buffer_required +def msg_command_cb(data, current_buffer, args): + dbg("msg_command_cb") + aargs = args.split(None, 2) + who = aargs[1] + + command_talk(current_buffer, who) + + if len(aargs) > 2: + message = aargs[2] + server = servers.find(current_domain_name()) + if server: + channel = server.channels.find(who) + channel.send_message(message) + return w.WEECHAT_RC_OK_EAT + + +@slack_buffer_required def command_upload(current_buffer, args): """ Uploads a file to the current buffer @@ -1012,7 +1029,7 @@ def command_talk(current_buffer, args): server = servers.find(current_domain_name()) if server: channel = server.channels.find(args) - if channel: + if not channel: channel.open() else: user = server.users.find(args) @@ -2218,6 +2235,7 @@ if __name__ == "__main__": w.hook_command_run('/part', 'part_command_cb', '') w.hook_command_run('/leave', 'part_command_cb', '') w.hook_command_run('/topic', 'topic_command_cb', '') + w.hook_command_run('/msg', 'msg_command_cb', '') w.hook_command_run("/input complete_next", "complete_next_cb", "") w.hook_completion("nicks", "complete @-nicks for slack", "nick_completion_cb", "") |