mirror of
https://github.com/weechat/weechat.git
synced 2026-07-07 10:13:12 +02:00
irc: use parsed command parameters in "tagmsg" command callback
This commit is contained in:
@@ -3043,7 +3043,7 @@ IRC_PROTOCOL_CALLBACK(setname)
|
||||
* Callback for the IRC command "TAGMSG": message with tags but no text content
|
||||
* (received when capability "message-tags" is enabled).
|
||||
*
|
||||
* Command looks like:
|
||||
* Whole message looks like:
|
||||
* @msgid=6gqz7dxd22v7r3x9pvu;+typing=active :nick!user@host TAGMSG #channel
|
||||
* @msgid=6gqz7dxd22v7r3x9pvu;+typing=active :nick!user@host TAGMSG :#channel
|
||||
*/
|
||||
@@ -3052,10 +3052,9 @@ IRC_PROTOCOL_CALLBACK(tagmsg)
|
||||
{
|
||||
struct t_irc_channel *ptr_channel;
|
||||
const char *ptr_typing_value;
|
||||
char *pos_channel;
|
||||
int state;
|
||||
|
||||
IRC_PROTOCOL_MIN_ARGS(3);
|
||||
IRC_PROTOCOL_MIN_PARAMS(1);
|
||||
|
||||
if (ignored)
|
||||
return WEECHAT_RC_OK;
|
||||
@@ -3063,12 +3062,10 @@ IRC_PROTOCOL_CALLBACK(tagmsg)
|
||||
if (!tags)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
pos_channel = (argv[2][0] == ':') ? argv[2] + 1 : argv[2];
|
||||
|
||||
ptr_channel = NULL;
|
||||
if (irc_channel_is_channel (server, pos_channel))
|
||||
ptr_channel = irc_channel_search (server, pos_channel);
|
||||
else if (irc_server_strcasecmp (server, pos_channel, server->nick) == 0)
|
||||
if (irc_channel_is_channel (server, params[0]))
|
||||
ptr_channel = irc_channel_search (server, params[0]);
|
||||
else if (irc_server_strcasecmp (server, params[0], server->nick) == 0)
|
||||
ptr_channel = irc_channel_search (server, nick);
|
||||
if (!ptr_channel)
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
@@ -38,6 +38,8 @@ extern "C"
|
||||
#include "src/plugins/irc/irc-config.h"
|
||||
#include "src/plugins/irc/irc-nick.h"
|
||||
#include "src/plugins/irc/irc-server.h"
|
||||
#include "src/plugins/typing/typing-config.h"
|
||||
#include "src/plugins/typing/typing-status.h"
|
||||
|
||||
extern int irc_protocol_is_numeric_command (const char *str);
|
||||
extern int irc_protocol_log_level_for_command (const char *command);
|
||||
@@ -1819,19 +1821,50 @@ TEST(IrcProtocolWithServer, setname_with_setname_cap)
|
||||
|
||||
TEST(IrcProtocolWithServer, tagmsg)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_typing_status *ptr_typing_status;
|
||||
|
||||
SRV_INIT_JOIN2;
|
||||
|
||||
/* not enough arguments */
|
||||
/* not enough parameters */
|
||||
RECV(":bob!user@host TAGMSG");
|
||||
CHECK_ERROR_ARGS("tagmsg", 2, 3);
|
||||
CHECK_ERROR_PARAMS("tagmsg", 0, 1);
|
||||
|
||||
/* no tags */
|
||||
RECV(":bob!user@host TAGMSG #test");
|
||||
CHECK_NO_MSG;
|
||||
RECV(":bob!user@host TAGMSG :#test");
|
||||
CHECK_NO_MSG;
|
||||
|
||||
/* with tags */
|
||||
RECV("@tag1=123;tag2=456 :bob!user@host TAGMSG #test");
|
||||
CHECK_NO_MSG;
|
||||
RECV("@tag1=123;tag2=456 :bob!user@host TAGMSG :#test");
|
||||
CHECK_NO_MSG;
|
||||
|
||||
/* check typing status */
|
||||
ptr_buffer = ptr_server->channels->buffer;
|
||||
|
||||
config_file_option_set (irc_config_look_typing_status_nicks, "on", 1);
|
||||
config_file_option_set (typing_config_look_enabled_nicks, "on", 1);
|
||||
|
||||
POINTERS_EQUAL(NULL, typing_status_nick_search (ptr_buffer, "bob"));
|
||||
|
||||
RECV("@+typing=active :bob!user@host TAGMSG #test");
|
||||
ptr_typing_status = typing_status_nick_search (ptr_buffer, "bob");
|
||||
CHECK(ptr_typing_status);
|
||||
LONGS_EQUAL(TYPING_STATUS_STATE_TYPING, ptr_typing_status->state);
|
||||
|
||||
RECV("@+typing=paused :bob!user@host TAGMSG :#test");
|
||||
ptr_typing_status = typing_status_nick_search (ptr_buffer, "bob");
|
||||
CHECK(ptr_typing_status);
|
||||
LONGS_EQUAL(TYPING_STATUS_STATE_PAUSED, ptr_typing_status->state);
|
||||
|
||||
RECV("@+typing=done :bob!user@host TAGMSG #test");
|
||||
POINTERS_EQUAL(NULL, typing_status_nick_search (ptr_buffer, "bob"));
|
||||
|
||||
config_file_option_reset (typing_config_look_enabled_nicks, 1);
|
||||
config_file_option_reset (irc_config_look_typing_status_nicks, 1);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user