From d290499d9dd3d58771b706a865fd23f600e6cfc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersson?= Date: Wed, 3 Sep 2014 15:19:09 +0200 Subject: [PATCH] Added /status command. --- src/tox-weechat-commands.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/tox-weechat-commands.c b/src/tox-weechat-commands.c index 64f42b1..7e4fdf5 100644 --- a/src/tox-weechat-commands.c +++ b/src/tox-weechat-commands.c @@ -345,6 +345,29 @@ tox_weechat_cmd_name(void *data, struct t_gui_buffer *buffer, return WEECHAT_RC_OK; } +int +tox_weechat_cmd_status(void *data, struct t_gui_buffer *buffer, + int argc, char **argv, char **argv_eol) +{ + if (argc != 2) + return WEECHAT_RC_ERROR; + + TOX_USERSTATUS status = TOX_USERSTATUS_INVALID; + if (weechat_strcasecmp(argv[1], "online") == 0) + status = TOX_USERSTATUS_NONE; + else if (weechat_strcasecmp(argv[1], "busy") == 0) + status = TOX_USERSTATUS_BUSY; + else if (weechat_strcasecmp(argv[1], "away") == 0) + status = TOX_USERSTATUS_AWAY; + + if (status == TOX_USERSTATUS_INVALID) + return WEECHAT_RC_ERROR; + + tox_set_user_status(tox, status); + + return WEECHAT_RC_OK; +} + int tox_weechat_cmd_statusmsg(void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) @@ -412,6 +435,12 @@ tox_weechat_commands_init() "name: your new name", NULL, tox_weechat_cmd_name, NULL); + weechat_hook_command("status", + "change your Tox status", + "online|busy|away", + "", + NULL, tox_weechat_cmd_status, NULL); + weechat_hook_command("statusmsg", "change your Tox status message", "[]",