43 |
|
|
44 |
|
|
45 |
/* |
/* |
46 |
|
* irc_is_highlight: returns 1 if given message contains highlight (with given nick |
47 |
|
* or at least one of string in "irc_higlight" setting |
48 |
|
*/ |
49 |
|
|
50 |
|
int |
51 |
|
irc_is_highlight (char *message, char *nick) |
52 |
|
{ |
53 |
|
char *highlight, *pos, *pos_end; |
54 |
|
int end, length; |
55 |
|
|
56 |
|
/* empty message ? */ |
57 |
|
if (!message || !message[0]) |
58 |
|
return 0; |
59 |
|
|
60 |
|
/* highlight by nickname */ |
61 |
|
if (strstr (message, nick)) |
62 |
|
return 1; |
63 |
|
|
64 |
|
/* no highlight by nickname and "irc_highlight" is empty */ |
65 |
|
if (!cfg_irc_highlight || !cfg_irc_highlight[0]) |
66 |
|
return 0; |
67 |
|
|
68 |
|
/* look in "irc_highlight" for highlight */ |
69 |
|
if ((highlight = strdup (cfg_irc_highlight)) == NULL) |
70 |
|
return 0; |
71 |
|
pos = highlight; |
72 |
|
end = 0; |
73 |
|
while (!end) |
74 |
|
{ |
75 |
|
pos_end = strchr (pos, ','); |
76 |
|
if (!pos_end) |
77 |
|
{ |
78 |
|
pos_end = strchr (pos, '\0'); |
79 |
|
end = 1; |
80 |
|
} |
81 |
|
/* error parsing string! */ |
82 |
|
if (!pos_end) |
83 |
|
{ |
84 |
|
free (highlight); |
85 |
|
return 0; |
86 |
|
} |
87 |
|
|
88 |
|
length = pos_end - pos; |
89 |
|
pos_end[0] = '\0'; |
90 |
|
if (length > 0) |
91 |
|
{ |
92 |
|
/* highlight found! */ |
93 |
|
if (strstr (message, pos)) |
94 |
|
{ |
95 |
|
free (highlight); |
96 |
|
return 1; |
97 |
|
} |
98 |
|
} |
99 |
|
|
100 |
|
if (!end) |
101 |
|
pos = pos_end + 1; |
102 |
|
} |
103 |
|
|
104 |
|
/* no highlight found with "irc_highlight" list */ |
105 |
|
free (highlight); |
106 |
|
return 0; |
107 |
|
} |
108 |
|
|
109 |
|
/* |
110 |
* irc_recv_command: executes action when receiving IRC command |
* irc_recv_command: executes action when receiving IRC command |
111 |
* returns: 0 = all ok, command executed |
* returns: 0 = all ok, command executed |
112 |
* -1 = command failed |
* -1 = command failed |
1296 |
if (pos2) |
if (pos2) |
1297 |
pos2[0] = '\0'; |
pos2[0] = '\0'; |
1298 |
irc_display_prefix (ptr_channel->buffer, PREFIX_ACTION_ME); |
irc_display_prefix (ptr_channel->buffer, PREFIX_ACTION_ME); |
1299 |
if (strstr (pos, server->nick)) |
if (irc_is_highlight (pos, server->nick)) |
1300 |
{ |
{ |
1301 |
gui_printf_type_color (ptr_channel->buffer, |
gui_printf_type_color (ptr_channel->buffer, |
1302 |
MSG_TYPE_MSG | MSG_TYPE_HIGHLIGHT, |
MSG_TYPE_MSG | MSG_TYPE_HIGHLIGHT, |
1335 |
else |
else |
1336 |
{ |
{ |
1337 |
ptr_nick = nick_search (ptr_channel, host); |
ptr_nick = nick_search (ptr_channel, host); |
1338 |
if (strstr (pos, server->nick)) |
if (irc_is_highlight (pos, server->nick)) |
1339 |
{ |
{ |
1340 |
irc_display_nick (ptr_channel->buffer, ptr_nick, |
irc_display_nick (ptr_channel->buffer, ptr_nick, |
1341 |
(ptr_nick) ? NULL : host, |
(ptr_nick) ? NULL : host, |
1778 |
if (pos2) |
if (pos2) |
1779 |
pos2[0] = '\0'; |
pos2[0] = '\0'; |
1780 |
irc_display_prefix (ptr_channel->buffer, PREFIX_ACTION_ME); |
irc_display_prefix (ptr_channel->buffer, PREFIX_ACTION_ME); |
1781 |
if (strstr (pos, server->nick)) |
if (irc_is_highlight (pos, server->nick)) |
1782 |
{ |
{ |
1783 |
gui_printf_type_color (ptr_channel->buffer, |
gui_printf_type_color (ptr_channel->buffer, |
1784 |
MSG_TYPE_MSG | MSG_TYPE_HIGHLIGHT, |
MSG_TYPE_MSG | MSG_TYPE_HIGHLIGHT, |
1805 |
gui_printf_type_color (ptr_channel->buffer, |
gui_printf_type_color (ptr_channel->buffer, |
1806 |
MSG_TYPE_NICK, |
MSG_TYPE_NICK, |
1807 |
COLOR_WIN_CHAT_DARK, "<"); |
COLOR_WIN_CHAT_DARK, "<"); |
1808 |
if (strstr (pos, server->nick)) |
if (irc_is_highlight (pos, server->nick)) |
1809 |
{ |
{ |
1810 |
gui_printf_type_color (ptr_channel->buffer, |
gui_printf_type_color (ptr_channel->buffer, |
1811 |
MSG_TYPE_NICK | MSG_TYPE_HIGHLIGHT, |
MSG_TYPE_NICK | MSG_TYPE_HIGHLIGHT, |