280 |
char *server, char *channel, char *command) |
char *server, char *channel, char *command) |
281 |
{ |
{ |
282 |
t_irc_server *ptr_server; |
t_irc_server *ptr_server; |
283 |
|
t_irc_channel *ptr_channel; |
284 |
|
|
285 |
if (!plugin || !command) |
if (!plugin || !command) |
286 |
return; |
return; |
287 |
|
|
288 |
ptr_server = plugin_find_server (server, channel); |
plugin_find_server_channel (server, channel, &ptr_server, &ptr_channel); |
289 |
if (ptr_server && (ptr_server->buffer)) |
if (ptr_server && ptr_channel) |
290 |
|
user_command (ptr_server, ptr_channel->buffer, command); |
291 |
|
else if (ptr_server && (ptr_server->buffer)) |
292 |
user_command (ptr_server, ptr_server->buffer, command); |
user_command (ptr_server, ptr_server->buffer, command); |
293 |
} |
} |
294 |
|
|
299 |
*/ |
*/ |
300 |
|
|
301 |
char * |
char * |
302 |
weechat_plugin_get_info (t_weechat_plugin *plugin, char *info, char *server, char *channel) |
weechat_plugin_get_info (t_weechat_plugin *plugin, char *info, char *server) |
303 |
{ |
{ |
304 |
t_gui_buffer *ptr_buffer; |
t_irc_server *ptr_server; |
305 |
|
t_irc_channel *ptr_channel; |
306 |
|
|
307 |
if (!plugin || !info) |
if (!plugin || !info) |
308 |
return NULL; |
return NULL; |
309 |
|
|
310 |
ptr_buffer = plugin_find_buffer (server, channel); |
/* below are infos that do NOT need server to return info */ |
|
if (!ptr_buffer) |
|
|
return NULL; |
|
311 |
|
|
312 |
if (ascii_strcasecmp (info, "version") == 0) |
if (ascii_strcasecmp (info, "version") == 0) |
313 |
{ |
{ |
314 |
return strdup (PACKAGE_VERSION); |
return strdup (PACKAGE_VERSION); |
315 |
} |
} |
|
else if (ascii_strcasecmp (info, "nick") == 0) |
|
|
{ |
|
|
if (SERVER(ptr_buffer) && (SERVER(ptr_buffer)->is_connected) |
|
|
&& (SERVER(ptr_buffer)->nick)) |
|
|
return strdup (SERVER(ptr_buffer)->nick); |
|
|
} |
|
|
else if (ascii_strcasecmp (info, "channel") == 0) |
|
|
{ |
|
|
if (BUFFER_IS_CHANNEL(ptr_buffer)) |
|
|
return strdup (CHANNEL(gui_current_window->buffer)->name); |
|
|
} |
|
|
else if (ascii_strcasecmp (info, "server") == 0) |
|
|
{ |
|
|
if (SERVER(ptr_buffer) && (SERVER(ptr_buffer)->is_connected) |
|
|
&& (SERVER(ptr_buffer)->name)) |
|
|
return strdup (SERVER(ptr_buffer)->name); |
|
|
} |
|
|
else if (ascii_strcasecmp (info, "away") == 0) |
|
|
{ |
|
|
if (SERVER(ptr_buffer) && (SERVER(ptr_buffer)->is_connected)) |
|
|
{ |
|
|
if (SERVER(ptr_buffer)->is_away) |
|
|
return strdup ("1"); |
|
|
else |
|
|
return strdup ("0"); |
|
|
} |
|
|
} |
|
316 |
else if (ascii_strcasecmp (info, "weechatdir") == 0) |
else if (ascii_strcasecmp (info, "weechatdir") == 0) |
317 |
{ |
{ |
318 |
/* WARNING: deprecated info, you should use weechat_dir */ |
/* WARNING: deprecated info, you should use "weechat_dir" */ |
319 |
/* will be removed in a future version */ |
/* will be removed in a future version */ |
320 |
return strdup (weechat_home); |
return strdup (weechat_home); |
321 |
} |
} |
332 |
return strdup (WEECHAT_SHAREDIR); |
return strdup (WEECHAT_SHAREDIR); |
333 |
} |
} |
334 |
|
|
335 |
|
/* below are infos that need server to return value */ |
336 |
|
|
337 |
|
plugin_find_server_channel (server, NULL, &ptr_server, &ptr_channel); |
338 |
|
if (!ptr_server) |
339 |
|
return NULL; |
340 |
|
|
341 |
|
if (ascii_strcasecmp (info, "nick") == 0) |
342 |
|
{ |
343 |
|
if (ptr_server->is_connected && ptr_server->nick) |
344 |
|
return strdup (ptr_server->nick); |
345 |
|
} |
346 |
|
else if (ascii_strcasecmp (info, "channel") == 0) |
347 |
|
{ |
348 |
|
if (BUFFER_IS_CHANNEL(gui_current_window->buffer)) |
349 |
|
return strdup (CHANNEL(gui_current_window->buffer)->name); |
350 |
|
} |
351 |
|
else if (ascii_strcasecmp (info, "server") == 0) |
352 |
|
{ |
353 |
|
if (ptr_server->is_connected && ptr_server->name) |
354 |
|
return strdup (ptr_server->name); |
355 |
|
} |
356 |
|
else if (ascii_strcasecmp (info, "away") == 0) |
357 |
|
{ |
358 |
|
if (ptr_server->is_connected && ptr_server->is_away) |
359 |
|
return strdup ("1"); |
360 |
|
else |
361 |
|
return strdup ("0"); |
362 |
|
} |
363 |
|
|
364 |
/* info not found */ |
/* info not found */ |
365 |
return NULL; |
return NULL; |
366 |
} |
} |