From ec0c54acb8f0801ba1902ff4395de12986b55cbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Pettersson?= Date: Thu, 4 Sep 2014 00:24:37 +0200 Subject: [PATCH] Added /friend remove command. --- src/tox-weechat-commands.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/tox-weechat-commands.c b/src/tox-weechat-commands.c index 3d4f756..362364a 100644 --- a/src/tox-weechat-commands.c +++ b/src/tox-weechat-commands.c @@ -135,6 +135,36 @@ tox_weechat_cmd_friend(void *data, struct t_gui_buffer *buffer, return WEECHAT_RC_OK; } + if (argc == 3 && (weechat_strcasecmp(argv[1], "remove") == 0)) + { + char *endptr; + unsigned long friend_number = strtoul(argv[2], &endptr, 10); + + if (endptr == argv[2] || !tox_friend_exists(tox, friend_number)) + { + weechat_printf(tox_main_buffer, + "%sInvalid friend number.", + weechat_prefix("error")); + return WEECHAT_RC_OK; + } + + char *name = tox_weechat_get_name_nt(friend_number); + if (tox_del_friend(tox, friend_number) == 0) + { + weechat_printf(tox_main_buffer, + "%sRemoved %s from friend list.", + weechat_prefix("network"), name); + } + else + { + weechat_printf(tox_main_buffer, + "%sCould not remove friend!", + weechat_prefix("error")); + } + + return WEECHAT_RC_OK; + } + // /friend accept if (argc == 3 && (weechat_strcasecmp(argv[1], "accept") == 0 @@ -402,6 +432,7 @@ tox_weechat_commands_init() "manage friends", "list" " || add
[]" + " || remove " " || requests" " || accept |all" " || decline |all",