mirror of
https://github.com/weechat/weechat.git
synced 2026-07-09 03:03:12 +02:00
core: store microseconds in buffer lines (closes #649)
This commit is contained in:
@@ -2004,6 +2004,28 @@ weechat_guile_api_print_date_tags (SCM buffer, SCM date, SCM tags, SCM message)
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_print_datetime_tags (SCM buffer, SCM date, SCM date_usec,
|
||||
SCM tags, SCM message)
|
||||
{
|
||||
API_INIT_FUNC(1, "print_datetime_tags", API_RETURN_ERROR);
|
||||
if (!scm_is_string (buffer) || !scm_is_integer (date)
|
||||
|| !scm_is_integer (date_usec) || !scm_is_string (tags)
|
||||
|| !scm_is_string (message))
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
plugin_script_api_printf_datetime_tags (
|
||||
weechat_guile_plugin,
|
||||
guile_current_script,
|
||||
API_STR2PTR(API_SCM_TO_STRING(buffer)),
|
||||
(time_t)scm_to_long (date),
|
||||
scm_to_int (date_usec),
|
||||
API_SCM_TO_STRING(tags),
|
||||
"%s", API_SCM_TO_STRING(message));
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_print_y (SCM buffer, SCM y, SCM message)
|
||||
{
|
||||
@@ -2042,6 +2064,29 @@ weechat_guile_api_print_y_date_tags (SCM buffer, SCM y, SCM date, SCM tags,
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_print_y_datetime_tags (SCM buffer, SCM y, SCM date,
|
||||
SCM date_usec, SCM tags, SCM message)
|
||||
{
|
||||
API_INIT_FUNC(1, "print_y_datetime_tags", API_RETURN_ERROR);
|
||||
if (!scm_is_string (buffer) || !scm_is_integer (y)
|
||||
|| !scm_is_integer (date) || !scm_is_integer (date_usec)
|
||||
|| !scm_is_string (tags) || !scm_is_string (message))
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
plugin_script_api_printf_y_datetime_tags (
|
||||
weechat_guile_plugin,
|
||||
guile_current_script,
|
||||
API_STR2PTR(API_SCM_TO_STRING(buffer)),
|
||||
scm_to_int (y),
|
||||
(time_t)scm_to_long (date),
|
||||
scm_to_int (date_usec),
|
||||
API_SCM_TO_STRING(tags),
|
||||
"%s", API_SCM_TO_STRING(message));
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
SCM
|
||||
weechat_guile_api_log_print (SCM message)
|
||||
{
|
||||
@@ -2743,7 +2788,7 @@ weechat_guile_api_hook_line (SCM buffer_type, SCM buffer_name, SCM tags,
|
||||
int
|
||||
weechat_guile_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
time_t date, int date_usec,
|
||||
int tags_count, const char **tags,
|
||||
int displayed, int highlight,
|
||||
const char *prefix, const char *message)
|
||||
@@ -2756,6 +2801,7 @@ weechat_guile_api_hook_print_cb (const void *pointer, void *data,
|
||||
int *rc, ret;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) date_usec;
|
||||
(void) tags_count;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
@@ -5353,8 +5399,10 @@ weechat_guile_api_module_init (void *data)
|
||||
API_DEF_FUNC(color, 1);
|
||||
API_DEF_FUNC(print, 2);
|
||||
API_DEF_FUNC(print_date_tags, 4);
|
||||
API_DEF_FUNC(print_datetime_tags, 5);
|
||||
API_DEF_FUNC(print_y, 3);
|
||||
API_DEF_FUNC(print_y_date_tags, 5);
|
||||
API_DEF_FUNC(print_y_datetime_tags, 6);
|
||||
API_DEF_FUNC(log_print, 1);
|
||||
API_DEF_FUNC(hook_command, 7);
|
||||
API_DEF_FUNC(hook_completion, 4);
|
||||
|
||||
@@ -388,6 +388,7 @@ irc_command_me_channel_message (struct t_irc_server *server,
|
||||
irc_input_user_message_display (
|
||||
server,
|
||||
0, /* date */
|
||||
0, /* date_usec */
|
||||
channel_name,
|
||||
NULL, /* address */
|
||||
"privmsg",
|
||||
@@ -1974,6 +1975,7 @@ IRC_COMMAND_CALLBACK(ctcp)
|
||||
irc_input_user_message_display (
|
||||
ptr_server,
|
||||
0, /* date */
|
||||
0, /* date_usec */
|
||||
ctcp_target,
|
||||
NULL, /* address */
|
||||
"privmsg",
|
||||
@@ -3841,6 +3843,7 @@ IRC_COMMAND_CALLBACK(msg)
|
||||
irc_input_user_message_display (
|
||||
ptr_server,
|
||||
0, /* date */
|
||||
0, /* date_usec */
|
||||
ptr_channel->name,
|
||||
NULL, /* address */
|
||||
"privmsg",
|
||||
@@ -3864,6 +3867,7 @@ IRC_COMMAND_CALLBACK(msg)
|
||||
irc_input_user_message_display (
|
||||
ptr_server,
|
||||
0, /* date */
|
||||
0, /* date_usec */
|
||||
targets[i],
|
||||
NULL, /* address */
|
||||
"privmsg",
|
||||
@@ -4065,6 +4069,7 @@ IRC_COMMAND_CALLBACK(notice)
|
||||
irc_input_user_message_display (
|
||||
ptr_server,
|
||||
0, /* date */
|
||||
0, /* date_usec */
|
||||
argv[arg_target],
|
||||
NULL, /* address */
|
||||
"notice",
|
||||
@@ -4595,6 +4600,7 @@ IRC_COMMAND_CALLBACK(query)
|
||||
irc_input_user_message_display (
|
||||
ptr_server,
|
||||
0, /* date */
|
||||
0, /* date_usec */
|
||||
ptr_channel->name,
|
||||
NULL, /* address */
|
||||
"privmsg",
|
||||
@@ -7799,8 +7805,9 @@ irc_command_init ()
|
||||
"condition \"xxx\", using following variables: output of function "
|
||||
"irc_message_parse (like nick, command, channel, text, etc., see "
|
||||
"function info_get_hashtable in plugin API reference for the list "
|
||||
"of all variables), date (format: \"yyyy-mm-dd hh:mm:ss\"), server, "
|
||||
"recv, sent, modified, redirected"),
|
||||
"of all variables), date (format: \"%FT%T.%f\", see function "
|
||||
"util_strftimeval in Plugin API reference), server, recv, sent, "
|
||||
"modified, redirected"),
|
||||
"",
|
||||
N_("Examples:"),
|
||||
AI(" /server listfull"),
|
||||
|
||||
@@ -3114,7 +3114,8 @@ irc_config_init ()
|
||||
irc_config_file, irc_config_section_look,
|
||||
"ctcp_time_format", "string",
|
||||
N_("time format used in answer to message CTCP TIME (see man "
|
||||
"strftime for date/time specifiers)"),
|
||||
"strftime for date/time specifiers, extra specifiers are supported, "
|
||||
"see function util_strftimeval in Plugin API reference)"),
|
||||
NULL, 0, 0, "%a, %d %b %Y %T %z", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
irc_config_look_display_account_message = weechat_config_new_option (
|
||||
|
||||
+22
-16
@@ -185,11 +185,12 @@ irc_ctcp_display_request (struct t_irc_protocol_ctxt *ctxt,
|
||||
&& !weechat_config_boolean (irc_config_look_display_ctcp_blocked))
|
||||
return;
|
||||
|
||||
weechat_printf_date_tags (
|
||||
weechat_printf_datetime_tags (
|
||||
irc_msgbuffer_get_target_buffer (
|
||||
ctxt->server, ctxt->nick, NULL, "ctcp",
|
||||
(channel) ? channel->buffer : NULL),
|
||||
ctxt->date,
|
||||
ctxt->date_usec,
|
||||
irc_protocol_tags (ctxt, "irc_ctcp"),
|
||||
_("%sCTCP requested by %s%s%s: %s%s%s%s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
@@ -252,10 +253,11 @@ irc_ctcp_display_reply_from_nick (struct t_irc_protocol_ctxt *ctxt,
|
||||
|
||||
difftime = ((sec2 * 1000000) + usec2) -
|
||||
((sec1 * 1000000) + usec1);
|
||||
weechat_printf_date_tags (
|
||||
weechat_printf_datetime_tags (
|
||||
irc_msgbuffer_get_target_buffer (
|
||||
ctxt->server, ctxt->nick, NULL, "ctcp", NULL),
|
||||
ctxt->date,
|
||||
ctxt->date_usec,
|
||||
irc_protocol_tags (ctxt, "irc_ctcp"),
|
||||
/* TRANSLATORS: %.3fs is a float number + "s" ("seconds") */
|
||||
_("%sCTCP reply from %s%s%s: %s%s%s %.3fs"),
|
||||
@@ -272,10 +274,11 @@ irc_ctcp_display_reply_from_nick (struct t_irc_protocol_ctxt *ctxt,
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf_date_tags (
|
||||
weechat_printf_datetime_tags (
|
||||
irc_msgbuffer_get_target_buffer (
|
||||
ctxt->server, ctxt->nick, NULL, "ctcp", NULL),
|
||||
ctxt->date,
|
||||
ctxt->date_usec,
|
||||
irc_protocol_tags (ctxt, "irc_ctcp"),
|
||||
_("%sCTCP reply from %s%s%s: %s%s%s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
@@ -291,10 +294,11 @@ irc_ctcp_display_reply_from_nick (struct t_irc_protocol_ctxt *ctxt,
|
||||
}
|
||||
else
|
||||
{
|
||||
weechat_printf_date_tags (
|
||||
weechat_printf_datetime_tags (
|
||||
irc_msgbuffer_get_target_buffer (
|
||||
ctxt->server, ctxt->nick, NULL, "ctcp", NULL),
|
||||
ctxt->date,
|
||||
ctxt->date_usec,
|
||||
irc_protocol_tags (ctxt, NULL),
|
||||
_("%sCTCP reply from %s%s%s: %s%s%s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
@@ -545,8 +549,7 @@ irc_ctcp_eval_reply (struct t_irc_server *server, const char *format)
|
||||
struct t_hashtable *extra_vars;
|
||||
char *info, *info_version, *info_version_git, *username, *realname;
|
||||
char buf[4096], *value;
|
||||
time_t now;
|
||||
struct tm *local_time;
|
||||
struct timeval tv_now;
|
||||
struct utsname *buf_uname;
|
||||
|
||||
if (!server || !format)
|
||||
@@ -661,13 +664,12 @@ irc_ctcp_eval_reply (struct t_irc_server *server, const char *format)
|
||||
* ${time}: local date/time of user, example:
|
||||
* Sat, 08 Jul 2023 21:11:19 +0200
|
||||
*/
|
||||
now = time (NULL);
|
||||
local_time = localtime (&now);
|
||||
gettimeofday (&tv_now, NULL);
|
||||
setlocale (LC_ALL, "C");
|
||||
if (strftime (buf, sizeof (buf),
|
||||
weechat_config_string (irc_config_look_ctcp_time_format),
|
||||
local_time) == 0)
|
||||
buf[0] = '\0';
|
||||
weechat_util_strftimeval (
|
||||
buf, sizeof (buf),
|
||||
weechat_config_string (irc_config_look_ctcp_time_format),
|
||||
&tv_now);
|
||||
setlocale (LC_ALL, "");
|
||||
weechat_hashtable_set (extra_vars, "time", buf);
|
||||
|
||||
@@ -1389,9 +1391,10 @@ irc_ctcp_recv (struct t_irc_protocol_ctxt *ctxt,
|
||||
ctxt->params[0][0]))
|
||||
{
|
||||
/* STATUSMSG action */
|
||||
weechat_printf_date_tags (
|
||||
weechat_printf_datetime_tags (
|
||||
channel->buffer,
|
||||
ctxt->date,
|
||||
ctxt->date_usec,
|
||||
irc_protocol_tags (
|
||||
ctxt,
|
||||
(ctxt->nick_is_me) ?
|
||||
@@ -1414,9 +1417,10 @@ irc_ctcp_recv (struct t_irc_protocol_ctxt *ctxt,
|
||||
else
|
||||
{
|
||||
/* standard action */
|
||||
weechat_printf_date_tags (
|
||||
weechat_printf_datetime_tags (
|
||||
channel->buffer,
|
||||
ctxt->date,
|
||||
ctxt->date_usec,
|
||||
irc_protocol_tags (
|
||||
ctxt,
|
||||
(ctxt->nick_is_me) ?
|
||||
@@ -1456,9 +1460,10 @@ irc_ctcp_recv (struct t_irc_protocol_ctxt *ctxt,
|
||||
if (!ptr_channel->topic)
|
||||
irc_channel_set_topic (ptr_channel, ctxt->address);
|
||||
|
||||
weechat_printf_date_tags (
|
||||
weechat_printf_datetime_tags (
|
||||
ptr_channel->buffer,
|
||||
ctxt->date,
|
||||
ctxt->date_usec,
|
||||
irc_protocol_tags (
|
||||
ctxt,
|
||||
(ctxt->nick_is_me) ?
|
||||
@@ -1535,11 +1540,12 @@ irc_ctcp_recv (struct t_irc_protocol_ctxt *ctxt,
|
||||
{
|
||||
if (weechat_config_boolean (irc_config_look_display_ctcp_unknown))
|
||||
{
|
||||
weechat_printf_date_tags (
|
||||
weechat_printf_datetime_tags (
|
||||
irc_msgbuffer_get_target_buffer (
|
||||
ctxt->server, ctxt->nick, NULL, "ctcp",
|
||||
(channel) ? channel->buffer : NULL),
|
||||
ctxt->date,
|
||||
ctxt->date_usec,
|
||||
irc_protocol_tags (ctxt, "irc_ctcp"),
|
||||
_("%sUnknown CTCP requested by %s%s%s: %s%s%s%s%s"),
|
||||
weechat_prefix ("network"),
|
||||
|
||||
@@ -64,6 +64,7 @@
|
||||
void
|
||||
irc_input_user_message_display (struct t_irc_server *server,
|
||||
time_t date,
|
||||
int date_usec,
|
||||
const char *target,
|
||||
const char *address,
|
||||
const char *command,
|
||||
@@ -86,6 +87,7 @@ irc_input_user_message_display (struct t_irc_server *server,
|
||||
memset (&ctxt, 0, sizeof (ctxt));
|
||||
ctxt.server = server;
|
||||
ctxt.date = date;
|
||||
ctxt.date_usec = date_usec;
|
||||
ctxt.address = (char *)address;
|
||||
ctxt.command = (char *)command;
|
||||
|
||||
@@ -317,6 +319,7 @@ irc_input_send_user_message (struct t_gui_buffer *buffer, int flags,
|
||||
irc_input_user_message_display (
|
||||
ptr_server,
|
||||
0, /* date */
|
||||
0, /* date_usec */
|
||||
ptr_channel->name,
|
||||
NULL, /* address */
|
||||
"privmsg",
|
||||
|
||||
@@ -26,6 +26,7 @@ struct t_gui_buffer;
|
||||
|
||||
extern void irc_input_user_message_display (struct t_irc_server *server,
|
||||
time_t date,
|
||||
int date_usec,
|
||||
const char *target,
|
||||
const char *address,
|
||||
const char *command,
|
||||
|
||||
+388
-184
File diff suppressed because it is too large
Load Diff
@@ -63,6 +63,7 @@ struct t_irc_protocol_ctxt
|
||||
{
|
||||
struct t_irc_server *server; /* IRC server */
|
||||
time_t date; /* message date */
|
||||
int date_usec; /* microseconds of date */
|
||||
char *irc_message; /* whole raw IRC message */
|
||||
struct t_hashtable *tags; /* IRC tags */
|
||||
char *nick; /* nick of sender */
|
||||
@@ -88,7 +89,6 @@ struct t_irc_protocol_msg
|
||||
|
||||
extern const char *irc_protocol_tags (struct t_irc_protocol_ctxt *ctxt,
|
||||
const char *extra_tags);
|
||||
extern time_t irc_protocol_parse_time (const char *time);
|
||||
extern void irc_protocol_recv_command (struct t_irc_server *server,
|
||||
const char *irc_message,
|
||||
const char *msg_command,
|
||||
|
||||
+21
-16
@@ -23,6 +23,7 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "irc.h"
|
||||
@@ -80,7 +81,7 @@ irc_raw_message_match_filter (struct t_irc_raw_message *raw_message,
|
||||
int match;
|
||||
char *command, *result, str_date[128];
|
||||
struct t_hashtable *hashtable;
|
||||
struct tm *date_tmp;
|
||||
struct timeval tv;
|
||||
|
||||
if (!filter || !filter[0])
|
||||
return 1;
|
||||
@@ -92,12 +93,10 @@ irc_raw_message_match_filter (struct t_irc_raw_message *raw_message,
|
||||
raw_message->message);
|
||||
if (hashtable)
|
||||
{
|
||||
date_tmp = localtime (&(raw_message->date));
|
||||
if (strftime (str_date, sizeof (str_date),
|
||||
"%Y-%m-%d %H:%M:%S", date_tmp) == 0)
|
||||
{
|
||||
str_date[0] = '\0';
|
||||
}
|
||||
tv.tv_sec = raw_message->date;
|
||||
tv.tv_usec = raw_message->date_usec;
|
||||
weechat_util_strftimeval (str_date, sizeof (str_date),
|
||||
"%FT%T.%f", &tv);
|
||||
weechat_hashtable_set (hashtable, "date", str_date);
|
||||
weechat_hashtable_set (hashtable,
|
||||
"server", raw_message->server->name);
|
||||
@@ -301,9 +300,11 @@ irc_raw_message_print (struct t_irc_raw_message *raw_message)
|
||||
(raw_message->server) ? (raw_message->server)->name : "");
|
||||
}
|
||||
|
||||
weechat_printf_date_tags (
|
||||
weechat_printf_datetime_tags (
|
||||
irc_raw_buffer,
|
||||
raw_message->date, NULL,
|
||||
raw_message->date,
|
||||
raw_message->date_usec,
|
||||
NULL,
|
||||
"%s\t%s",
|
||||
prefix,
|
||||
(buf2) ? buf2 : ((buf) ? buf : raw_message->message));
|
||||
@@ -532,7 +533,8 @@ irc_raw_message_remove_old ()
|
||||
*/
|
||||
|
||||
struct t_irc_raw_message *
|
||||
irc_raw_message_add_to_list (time_t date, struct t_irc_server *server,
|
||||
irc_raw_message_add_to_list (time_t date, int date_usec,
|
||||
struct t_irc_server *server,
|
||||
int flags, const char *message)
|
||||
{
|
||||
struct t_irc_raw_message *new_raw_message;
|
||||
@@ -546,6 +548,7 @@ irc_raw_message_add_to_list (time_t date, struct t_irc_server *server,
|
||||
if (new_raw_message)
|
||||
{
|
||||
new_raw_message->date = date;
|
||||
new_raw_message->date_usec = date_usec;
|
||||
new_raw_message->server = server;
|
||||
new_raw_message->flags = flags;
|
||||
new_raw_message->message = strdup (message);
|
||||
@@ -574,7 +577,7 @@ irc_raw_print (struct t_irc_server *server, int flags,
|
||||
const char *message)
|
||||
{
|
||||
struct t_irc_raw_message *new_raw_message;
|
||||
time_t now;
|
||||
struct timeval tv_now;
|
||||
|
||||
if (!message)
|
||||
return;
|
||||
@@ -583,10 +586,9 @@ irc_raw_print (struct t_irc_server *server, int flags,
|
||||
if (!irc_raw_buffer && (weechat_irc_plugin->debug >= 1))
|
||||
irc_raw_open (0);
|
||||
|
||||
now = time (NULL);
|
||||
|
||||
new_raw_message = irc_raw_message_add_to_list (now, server, flags,
|
||||
message);
|
||||
gettimeofday (&tv_now, NULL);
|
||||
new_raw_message = irc_raw_message_add_to_list (
|
||||
tv_now.tv_sec, tv_now.tv_usec, server, flags, message);
|
||||
if (new_raw_message)
|
||||
{
|
||||
if (irc_raw_buffer)
|
||||
@@ -598,7 +600,8 @@ irc_raw_print (struct t_irc_server *server, int flags,
|
||||
if (weechat_irc_plugin->debug >= 2)
|
||||
{
|
||||
new_raw_message = irc_raw_message_add_to_list (
|
||||
now,
|
||||
tv_now.tv_sec,
|
||||
tv_now.tv_usec,
|
||||
server,
|
||||
flags | IRC_RAW_FLAG_BINARY,
|
||||
message);
|
||||
@@ -635,6 +638,8 @@ irc_raw_add_to_infolist (struct t_infolist *infolist,
|
||||
|
||||
if (!weechat_infolist_new_var_time (ptr_item, "date", raw_message->date))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "date_usec", raw_message->date_usec))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_string (ptr_item, "server", raw_message->server->name))
|
||||
return 0;
|
||||
if (!weechat_infolist_new_var_integer (ptr_item, "flags", raw_message->flags))
|
||||
|
||||
@@ -41,6 +41,7 @@ struct t_irc_server;
|
||||
struct t_irc_raw_message
|
||||
{
|
||||
time_t date; /* date/time of message */
|
||||
int date_usec; /* microseconds of date */
|
||||
struct t_irc_server *server; /* server */
|
||||
int flags; /* flags */
|
||||
char *message; /* message */
|
||||
@@ -59,6 +60,7 @@ extern void irc_raw_open (int switch_to_buffer);
|
||||
extern void irc_raw_set_filter (const char *filter);
|
||||
extern void irc_raw_filter_options (const char *filter);
|
||||
extern struct t_irc_raw_message *irc_raw_message_add_to_list (time_t date,
|
||||
int date_usec,
|
||||
struct t_irc_server *server,
|
||||
int flags,
|
||||
const char *message);
|
||||
|
||||
@@ -969,6 +969,7 @@ irc_upgrade_read_cb (const void *pointer, void *data,
|
||||
{
|
||||
irc_raw_message_add_to_list (
|
||||
weechat_infolist_time (infolist, "date"),
|
||||
weechat_infolist_integer (infolist, "date_usec"),
|
||||
ptr_server,
|
||||
weechat_infolist_integer (infolist, "flags"),
|
||||
weechat_infolist_string (infolist, "message"));
|
||||
|
||||
@@ -1903,6 +1903,31 @@ API_FUNC(print_date_tags)
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_datetime_tags)
|
||||
{
|
||||
long date;
|
||||
int date_usec;
|
||||
|
||||
API_INIT_FUNC(1, "print_datetime_tags", "sniss", API_RETURN_ERROR);
|
||||
|
||||
v8::String::Utf8Value buffer(args[0]);
|
||||
date = args[1]->IntegerValue();
|
||||
date_usec = args[2]->IntegerValue();
|
||||
v8::String::Utf8Value tags(args[3]);
|
||||
v8::String::Utf8Value message(args[4]);
|
||||
|
||||
plugin_script_api_printf_datetime_tags (
|
||||
weechat_js_plugin,
|
||||
js_current_script,
|
||||
(struct t_gui_buffer *)API_STR2PTR(*buffer),
|
||||
(time_t)date,
|
||||
date_usec,
|
||||
*tags,
|
||||
"%s", *message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_y)
|
||||
{
|
||||
int y;
|
||||
@@ -1913,11 +1938,12 @@ API_FUNC(print_y)
|
||||
y = args[1]->IntegerValue();
|
||||
v8::String::Utf8Value message(args[2]);
|
||||
|
||||
plugin_script_api_printf_y (weechat_js_plugin,
|
||||
js_current_script,
|
||||
(struct t_gui_buffer *)API_STR2PTR(*buffer),
|
||||
y,
|
||||
"%s", *message);
|
||||
plugin_script_api_printf_y (
|
||||
weechat_js_plugin,
|
||||
js_current_script,
|
||||
(struct t_gui_buffer *)API_STR2PTR(*buffer),
|
||||
y,
|
||||
"%s", *message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
@@ -1935,13 +1961,41 @@ API_FUNC(print_y_date_tags)
|
||||
v8::String::Utf8Value tags(args[3]);
|
||||
v8::String::Utf8Value message(args[4]);
|
||||
|
||||
plugin_script_api_printf_y_date_tags (weechat_js_plugin,
|
||||
js_current_script,
|
||||
(struct t_gui_buffer *)API_STR2PTR(*buffer),
|
||||
y,
|
||||
(time_t)date,
|
||||
*tags,
|
||||
"%s", *message);
|
||||
plugin_script_api_printf_y_date_tags (
|
||||
weechat_js_plugin,
|
||||
js_current_script,
|
||||
(struct t_gui_buffer *)API_STR2PTR(*buffer),
|
||||
y,
|
||||
(time_t)date,
|
||||
*tags,
|
||||
"%s", *message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_y_datetime_tags)
|
||||
{
|
||||
int y, date_usec;
|
||||
long date;
|
||||
|
||||
API_INIT_FUNC(1, "print_y_datetime_tags", "siniss", API_RETURN_ERROR);
|
||||
|
||||
v8::String::Utf8Value buffer(args[0]);
|
||||
y = args[1]->IntegerValue();
|
||||
date = args[2]->IntegerValue();
|
||||
date_usec = args[3]->IntegerValue();
|
||||
v8::String::Utf8Value tags(args[4]);
|
||||
v8::String::Utf8Value message(args[5]);
|
||||
|
||||
plugin_script_api_printf_y_datetime_tags (
|
||||
weechat_js_plugin,
|
||||
js_current_script,
|
||||
(struct t_gui_buffer *)API_STR2PTR(*buffer),
|
||||
y,
|
||||
(time_t)date,
|
||||
date_usec,
|
||||
*tags,
|
||||
"%s", *message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
@@ -2667,7 +2721,7 @@ API_FUNC(hook_line)
|
||||
int
|
||||
weechat_js_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
time_t date, int date_usec,
|
||||
int tags_count, const char **tags,
|
||||
int displayed, int highlight,
|
||||
const char *prefix, const char *message)
|
||||
@@ -2680,6 +2734,7 @@ weechat_js_api_hook_print_cb (const void *pointer, void *data,
|
||||
int *rc, ret;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) date_usec;
|
||||
(void) tags_count;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
@@ -5297,8 +5352,10 @@ WeechatJsV8::loadLibs()
|
||||
API_DEF_FUNC(color);
|
||||
API_DEF_FUNC(print);
|
||||
API_DEF_FUNC(print_date_tags);
|
||||
API_DEF_FUNC(print_datetime_tags);
|
||||
API_DEF_FUNC(print_y);
|
||||
API_DEF_FUNC(print_y_date_tags);
|
||||
API_DEF_FUNC(print_y_datetime_tags);
|
||||
API_DEF_FUNC(log_print);
|
||||
API_DEF_FUNC(hook_command);
|
||||
API_DEF_FUNC(hook_completion);
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
@@ -236,8 +238,7 @@ logger_buffer_create_log_file (struct t_logger_buffer *logger_buffer)
|
||||
{
|
||||
char *charset, *message, buf_time[256], buf_beginning[1024];
|
||||
int log_level, rc;
|
||||
time_t seconds;
|
||||
struct tm *date_tmp;
|
||||
struct timeval tv_now;
|
||||
struct stat statbuf;
|
||||
|
||||
if (logger_buffer->log_file)
|
||||
@@ -311,16 +312,11 @@ logger_buffer_create_log_file (struct t_logger_buffer *logger_buffer)
|
||||
if (weechat_config_boolean (logger_config_file_info_lines)
|
||||
&& logger_buffer->write_start_info_line)
|
||||
{
|
||||
buf_time[0] = '\0';
|
||||
seconds = time (NULL);
|
||||
date_tmp = localtime (&seconds);
|
||||
if (date_tmp)
|
||||
{
|
||||
if (strftime (buf_time, sizeof (buf_time) - 1,
|
||||
weechat_config_string (logger_config_file_time_format),
|
||||
date_tmp) == 0)
|
||||
buf_time[0] = '\0';
|
||||
}
|
||||
gettimeofday (&tv_now, NULL);
|
||||
weechat_util_strftimeval (
|
||||
buf_time, sizeof (buf_time),
|
||||
weechat_config_string (logger_config_file_time_format),
|
||||
&tv_now);
|
||||
snprintf (buf_beginning, sizeof (buf_beginning),
|
||||
_("%s\t**** Beginning of log ****"),
|
||||
buf_time);
|
||||
@@ -663,8 +659,7 @@ logger_buffer_write_line (struct t_logger_buffer *logger_buffer,
|
||||
void
|
||||
logger_buffer_stop (struct t_logger_buffer *logger_buffer, int write_info_line)
|
||||
{
|
||||
time_t seconds;
|
||||
struct tm *date_tmp;
|
||||
struct timeval tv_now;
|
||||
char buf_time[256];
|
||||
|
||||
if (!logger_buffer)
|
||||
@@ -674,16 +669,11 @@ logger_buffer_stop (struct t_logger_buffer *logger_buffer, int write_info_line)
|
||||
{
|
||||
if (write_info_line && weechat_config_boolean (logger_config_file_info_lines))
|
||||
{
|
||||
buf_time[0] = '\0';
|
||||
seconds = time (NULL);
|
||||
date_tmp = localtime (&seconds);
|
||||
if (date_tmp)
|
||||
{
|
||||
if (strftime (buf_time, sizeof (buf_time) - 1,
|
||||
weechat_config_string (logger_config_file_time_format),
|
||||
date_tmp) == 0)
|
||||
buf_time[0] = '\0';
|
||||
}
|
||||
gettimeofday (&tv_now, NULL);
|
||||
weechat_util_strftimeval (
|
||||
buf_time, sizeof (buf_time),
|
||||
weechat_config_string (logger_config_file_time_format),
|
||||
&tv_now);
|
||||
logger_buffer_write_line (logger_buffer,
|
||||
_("%s\t**** End of log ****"),
|
||||
buf_time);
|
||||
|
||||
@@ -716,7 +716,8 @@ logger_config_init ()
|
||||
logger_config_file, logger_config_section_file,
|
||||
"time_format", "string",
|
||||
N_("timestamp used in log files (see man strftime for date/time "
|
||||
"specifiers)"),
|
||||
"specifiers, extra specifiers are supported, see function "
|
||||
"util_strftimeval in Plugin API reference)"),
|
||||
NULL, 0, 0, "%Y-%m-%d %H:%M:%S", NULL, 0,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
+11
-13
@@ -25,6 +25,7 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "../weechat-plugin.h"
|
||||
#include "logger.h"
|
||||
@@ -150,7 +151,7 @@ logger_get_file_path ()
|
||||
seconds = time (NULL);
|
||||
date_tmp = localtime (&seconds);
|
||||
path2[0] = '\0';
|
||||
if (strftime (path2, length - 1, path, date_tmp) == 0)
|
||||
if (strftime (path2, length, path, date_tmp) == 0)
|
||||
path2[0] = '\0';
|
||||
|
||||
if (weechat_logger_plugin->debug)
|
||||
@@ -378,7 +379,7 @@ logger_get_mask_expanded (struct t_gui_buffer *buffer, const char *mask)
|
||||
seconds = time (NULL);
|
||||
date_tmp = localtime (&seconds);
|
||||
mask2[0] = '\0';
|
||||
if (strftime (mask2, length - 1, mask, date_tmp) == 0)
|
||||
if (strftime (mask2, length, mask, date_tmp) == 0)
|
||||
mask2[0] = '\0';
|
||||
|
||||
/*
|
||||
@@ -695,13 +696,13 @@ logger_get_line_tag_info (int tags_count, const char **tags,
|
||||
|
||||
int
|
||||
logger_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer, time_t date,
|
||||
struct t_gui_buffer *buffer, time_t date, int date_usec,
|
||||
int tags_count, const char **tags,
|
||||
int displayed, int highlight,
|
||||
const char *prefix, const char *message)
|
||||
{
|
||||
struct t_logger_buffer *ptr_logger_buffer;
|
||||
struct tm *date_tmp;
|
||||
struct timeval tv;
|
||||
char buf_time[256], *prefix_ansi, *message_ansi;
|
||||
const char *ptr_prefix, *ptr_message;
|
||||
int line_log_level, prefix_is_nick, color_lines;
|
||||
@@ -740,15 +741,12 @@ logger_print_cb (const void *pointer, void *data,
|
||||
ptr_prefix = prefix;
|
||||
ptr_message = message;
|
||||
}
|
||||
buf_time[0] = '\0';
|
||||
date_tmp = localtime (&date);
|
||||
if (date_tmp)
|
||||
{
|
||||
if (strftime (buf_time, sizeof (buf_time) - 1,
|
||||
weechat_config_string (logger_config_file_time_format),
|
||||
date_tmp) == 0)
|
||||
buf_time[0] = '\0';
|
||||
}
|
||||
tv.tv_sec = date;
|
||||
tv.tv_usec = date_usec;
|
||||
weechat_util_strftimeval (
|
||||
buf_time, sizeof (buf_time),
|
||||
weechat_config_string (logger_config_file_time_format),
|
||||
&tv);
|
||||
|
||||
logger_buffer_write_line (
|
||||
ptr_logger_buffer,
|
||||
|
||||
@@ -41,7 +41,8 @@ extern char *logger_build_option_name (struct t_gui_buffer *buffer);
|
||||
extern int logger_get_level_for_buffer (struct t_gui_buffer *buffer);
|
||||
extern char *logger_get_filename (struct t_gui_buffer *buffer);
|
||||
extern int logger_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer, time_t date,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date, int date_usec,
|
||||
int tags_count, const char **tags,
|
||||
int displayed, int highlight,
|
||||
const char *prefix, const char *message);
|
||||
|
||||
@@ -2107,6 +2107,33 @@ API_FUNC(print_date_tags)
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_datetime_tags)
|
||||
{
|
||||
const char *buffer, *tags, *message;
|
||||
long date;
|
||||
int date_usec;
|
||||
|
||||
API_INIT_FUNC(1, "print_datetime_tags", API_RETURN_ERROR);
|
||||
if (lua_gettop (L) < 5)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
buffer = lua_tostring (L, -5);
|
||||
date = lua_tonumber (L, -4);
|
||||
date_usec = lua_tonumber (L, -3);
|
||||
tags = lua_tostring (L, -2);
|
||||
message = lua_tostring (L, -1);
|
||||
|
||||
plugin_script_api_printf_datetime_tags (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
(time_t)date,
|
||||
date_usec,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_y)
|
||||
{
|
||||
const char *buffer, *message;
|
||||
@@ -2156,6 +2183,35 @@ API_FUNC(print_y_date_tags)
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_y_datetime_tags)
|
||||
{
|
||||
const char *buffer, *tags, *message;
|
||||
int y, date_usec;
|
||||
long date;
|
||||
|
||||
API_INIT_FUNC(1, "print_y_datetime_tags", API_RETURN_ERROR);
|
||||
if (lua_gettop (L) < 6)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
buffer = lua_tostring (L, -6);
|
||||
y = lua_tonumber (L, -5);
|
||||
date = lua_tonumber (L, -4);
|
||||
date_usec = lua_tonumber (L, -3);
|
||||
tags = lua_tostring (L, -2);
|
||||
message = lua_tostring (L, -1);
|
||||
|
||||
plugin_script_api_printf_y_datetime_tags (weechat_lua_plugin,
|
||||
lua_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
y,
|
||||
(time_t)date,
|
||||
date_usec,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(log_print)
|
||||
{
|
||||
const char *message;
|
||||
@@ -2891,7 +2947,7 @@ API_FUNC(hook_line)
|
||||
int
|
||||
weechat_lua_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
time_t date, int date_usec,
|
||||
int tags_count, const char **tags,
|
||||
int displayed, int highlight,
|
||||
const char *prefix, const char *message)
|
||||
@@ -2904,6 +2960,7 @@ weechat_lua_api_hook_print_cb (const void *pointer, void *data,
|
||||
int *rc, ret;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) date_usec;
|
||||
(void) tags_count;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
@@ -5662,8 +5719,10 @@ const struct luaL_Reg weechat_lua_api_funcs[] = {
|
||||
API_DEF_FUNC(color),
|
||||
API_DEF_FUNC(print),
|
||||
API_DEF_FUNC(print_date_tags),
|
||||
API_DEF_FUNC(print_datetime_tags),
|
||||
API_DEF_FUNC(print_y),
|
||||
API_DEF_FUNC(print_y_date_tags),
|
||||
API_DEF_FUNC(print_y_datetime_tags),
|
||||
API_DEF_FUNC(log_print),
|
||||
API_DEF_FUNC(hook_command),
|
||||
API_DEF_FUNC(hook_completion),
|
||||
|
||||
@@ -2015,6 +2015,30 @@ API_FUNC(print_date_tags)
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_datetime_tags)
|
||||
{
|
||||
char *buffer, *tags, *message;
|
||||
dXSARGS;
|
||||
|
||||
API_INIT_FUNC(1, "print_datetime_tags", API_RETURN_ERROR);
|
||||
if (items < 5)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
buffer = SvPV_nolen (ST (0));
|
||||
tags = SvPV_nolen (ST (3));
|
||||
message = SvPV_nolen (ST (4));
|
||||
|
||||
plugin_script_api_printf_datetime_tags (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
(time_t)(SvIV (ST (1))), /* date */
|
||||
SvIV (ST (2)), /* date_usec */
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_y)
|
||||
{
|
||||
char *buffer, *message;
|
||||
@@ -2030,7 +2054,7 @@ API_FUNC(print_y)
|
||||
plugin_script_api_printf_y (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
SvIV (ST (1)),
|
||||
SvIV (ST (1)), /* y */
|
||||
"%s", message);
|
||||
|
||||
API_RETURN_OK;
|
||||
@@ -2060,6 +2084,31 @@ API_FUNC(print_y_date_tags)
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_y_datetime_tags)
|
||||
{
|
||||
char *buffer, *tags, *message;
|
||||
dXSARGS;
|
||||
|
||||
API_INIT_FUNC(1, "print_y_datetime_tags", API_RETURN_ERROR);
|
||||
if (items < 5)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
buffer = SvPV_nolen (ST (0));
|
||||
tags = SvPV_nolen (ST (4));
|
||||
message = SvPV_nolen (ST (5));
|
||||
|
||||
plugin_script_api_printf_y_datetime_tags (weechat_perl_plugin,
|
||||
perl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
SvIV (ST (1)), /* y */
|
||||
(time_t)(SvIV (ST (2))), /* date */
|
||||
SvIV (ST (3)), /* date_usec */
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(log_print)
|
||||
{
|
||||
dXSARGS;
|
||||
@@ -2777,7 +2826,7 @@ API_FUNC(hook_line)
|
||||
int
|
||||
weechat_perl_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
time_t date, int date_usec,
|
||||
int tags_count, const char **tags,
|
||||
int displayed, int highlight,
|
||||
const char *prefix, const char *message)
|
||||
@@ -2790,6 +2839,7 @@ weechat_perl_api_hook_print_cb (const void *pointer, void *data,
|
||||
int *rc, ret;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) date_usec;
|
||||
(void) tags_count;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
@@ -5606,8 +5656,10 @@ weechat_perl_api_init (pTHX)
|
||||
API_DEF_FUNC(color);
|
||||
API_DEF_FUNC(print);
|
||||
API_DEF_FUNC(print_date_tags);
|
||||
API_DEF_FUNC(print_datetime_tags);
|
||||
API_DEF_FUNC(print_y);
|
||||
API_DEF_FUNC(print_y_date_tags);
|
||||
API_DEF_FUNC(print_y_datetime_tags);
|
||||
API_DEF_FUNC(log_print);
|
||||
API_DEF_FUNC(hook_command);
|
||||
API_DEF_FUNC(hook_completion);
|
||||
|
||||
@@ -2183,6 +2183,38 @@ API_FUNC(print_date_tags)
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_datetime_tags)
|
||||
{
|
||||
zend_string *z_buffer, *z_tags, *z_message;
|
||||
zend_long z_date, z_date_usec;
|
||||
struct t_gui_buffer *buffer;
|
||||
time_t date;
|
||||
int date_usec;
|
||||
char *tags, *message;
|
||||
|
||||
API_INIT_FUNC(1, "print_datetime_tags", API_RETURN_ERROR);
|
||||
if (zend_parse_parameters (ZEND_NUM_ARGS(), "SllSS", &z_buffer, &z_date,
|
||||
&z_date_usec, &z_tags, &z_message) == FAILURE)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
|
||||
date = (time_t)z_date;
|
||||
date_usec = (int)z_date_usec;
|
||||
tags = ZSTR_VAL(z_tags);
|
||||
message = ZSTR_VAL(z_message);
|
||||
|
||||
plugin_script_api_printf_datetime_tags (weechat_php_plugin,
|
||||
php_current_script,
|
||||
buffer,
|
||||
date,
|
||||
date_usec,
|
||||
(const char *)tags,
|
||||
"%s",
|
||||
message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_y)
|
||||
{
|
||||
zend_string *z_buffer, *z_message;
|
||||
@@ -2242,6 +2274,41 @@ API_FUNC(print_y_date_tags)
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_y_datetime_tags)
|
||||
{
|
||||
zend_string *z_buffer, *z_tags, *z_message;
|
||||
zend_long z_y, z_date, z_date_usec;
|
||||
struct t_gui_buffer *buffer;
|
||||
int y, date_usec;
|
||||
time_t date;
|
||||
char *tags, *message;
|
||||
|
||||
API_INIT_FUNC(1, "print_y_datetime_tags", API_RETURN_ERROR);
|
||||
if (zend_parse_parameters (ZEND_NUM_ARGS(), "SlllSS", &z_buffer, &z_y,
|
||||
&z_date, &z_date_usec, &z_tags,
|
||||
&z_message) == FAILURE)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
buffer = (struct t_gui_buffer *)API_STR2PTR(ZSTR_VAL(z_buffer));
|
||||
y = (int)z_y;
|
||||
date = (time_t)z_date;
|
||||
date_usec = (int)z_date_usec;
|
||||
tags = ZSTR_VAL(z_tags);
|
||||
message = ZSTR_VAL(z_message);
|
||||
|
||||
plugin_script_api_printf_y_datetime_tags (weechat_php_plugin,
|
||||
php_current_script,
|
||||
buffer,
|
||||
y,
|
||||
date,
|
||||
date_usec,
|
||||
(const char *)tags,
|
||||
"%s",
|
||||
message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(log_print)
|
||||
{
|
||||
zend_string *z_message;
|
||||
@@ -2871,7 +2938,8 @@ API_FUNC(hook_line)
|
||||
|
||||
static int
|
||||
weechat_php_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer, time_t date,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date, int date_usec,
|
||||
int tags_count, const char **tags,
|
||||
int displayed, int highlight,
|
||||
const char *prefix, const char *message)
|
||||
@@ -2879,6 +2947,9 @@ weechat_php_api_hook_print_cb (const void *pointer, void *data,
|
||||
int rc;
|
||||
void *func_argv[9];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) date_usec;
|
||||
|
||||
func_argv[1] = (char *)API_PTR2STR(buffer);
|
||||
func_argv[2] = &date;
|
||||
func_argv[3] = &tags_count;
|
||||
|
||||
@@ -129,8 +129,10 @@ PHP_FUNCTION(weechat_prefix);
|
||||
PHP_FUNCTION(weechat_color);
|
||||
PHP_FUNCTION(weechat_print);
|
||||
PHP_FUNCTION(weechat_print_date_tags);
|
||||
PHP_FUNCTION(weechat_print_datetime_tags);
|
||||
PHP_FUNCTION(weechat_print_y);
|
||||
PHP_FUNCTION(weechat_print_y_date_tags);
|
||||
PHP_FUNCTION(weechat_print_y_datetime_tags);
|
||||
PHP_FUNCTION(weechat_log_print);
|
||||
PHP_FUNCTION(weechat_hook_command);
|
||||
PHP_FUNCTION(weechat_hook_completion);
|
||||
|
||||
@@ -187,8 +187,10 @@ const zend_function_entry weechat_functions[] = {
|
||||
PHP_FE(weechat_color, arginfo_weechat_color)
|
||||
PHP_FE(weechat_print, arginfo_weechat_print)
|
||||
PHP_FE(weechat_print_date_tags, arginfo_weechat_print_date_tags)
|
||||
PHP_FE(weechat_print_datetime_tags, arginfo_weechat_print_datetime_tags)
|
||||
PHP_FE(weechat_print_y, arginfo_weechat_print_y)
|
||||
PHP_FE(weechat_print_y_date_tags, arginfo_weechat_print_y_date_tags)
|
||||
PHP_FE(weechat_print_y_datetime_tags, arginfo_weechat_print_y_datetime_tags)
|
||||
PHP_FE(weechat_log_print, arginfo_weechat_log_print)
|
||||
PHP_FE(weechat_hook_command, arginfo_weechat_hook_command)
|
||||
PHP_FE(weechat_hook_completion, arginfo_weechat_hook_completion)
|
||||
|
||||
@@ -95,8 +95,10 @@ function weechat_prefix(string $p0): string {}
|
||||
function weechat_color(string $p0): string {}
|
||||
function weechat_print(string $p0, string $p1): int {}
|
||||
function weechat_print_date_tags(string $p0, int $p1, string $p2, string $p3): int {}
|
||||
function weechat_print_datetime_tags(string $p0, int $p1, int $p2, string $p3, string $p4): int {}
|
||||
function weechat_print_y(string $p0, int $p1, string $p2): int {}
|
||||
function weechat_print_y_date_tags(string $p0, int $p1, int $p2, string $p3, string $p4): int {}
|
||||
function weechat_print_y_datetime_tags(string $p0, int $p1, int $p2, int $p3, string $p4, string $p5): int {}
|
||||
function weechat_log_print(string $p0): int {}
|
||||
function weechat_hook_command(string $p0, string $p1, string $p2, string $p3, string $p4, mixed $p5, string $p6): string {}
|
||||
function weechat_hook_completion(string $p0, string $p1, mixed $p2, string $p3): string {}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 614392b6be26030a5d7b12437562aec08ad7052c */
|
||||
* Stub hash: b6e9e3f12ed24566eb77aa0c08bf3e7c5d866b76 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_register, 0, 7, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0)
|
||||
@@ -239,18 +239,29 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_print_date_tags, 0, 4, I
|
||||
ZEND_ARG_TYPE_INFO(0, p3, IS_STRING, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_print_datetime_tags, 0, 5, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p1, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p2, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p3, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p4, IS_STRING, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_print_y, 0, 3, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p1, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p2, IS_STRING, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_print_y_date_tags, 0, 5, IS_LONG, 0)
|
||||
#define arginfo_weechat_print_y_date_tags arginfo_weechat_print_datetime_tags
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_weechat_print_y_datetime_tags, 0, 6, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p0, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p1, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p2, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p3, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p3, IS_LONG, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p4, IS_STRING, 0)
|
||||
ZEND_ARG_TYPE_INFO(0, p5, IS_STRING, 0)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_log_print arginfo_weechat_charset_set
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: 614392b6be26030a5d7b12437562aec08ad7052c */
|
||||
* Stub hash: b6e9e3f12ed24566eb77aa0c08bf3e7c5d866b76 */
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_register, 0, 0, 7)
|
||||
ZEND_ARG_INFO(0, p0)
|
||||
@@ -192,9 +192,7 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_print_date_tags arginfo_weechat_string_eval_expression
|
||||
|
||||
#define arginfo_weechat_print_y arginfo_weechat_ngettext
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_print_y_date_tags, 0, 0, 5)
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_print_datetime_tags, 0, 0, 5)
|
||||
ZEND_ARG_INFO(0, p0)
|
||||
ZEND_ARG_INFO(0, p1)
|
||||
ZEND_ARG_INFO(0, p2)
|
||||
@@ -202,6 +200,19 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_print_y_date_tags, 0, 0, 5)
|
||||
ZEND_ARG_INFO(0, p4)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_print_y arginfo_weechat_ngettext
|
||||
|
||||
#define arginfo_weechat_print_y_date_tags arginfo_weechat_print_datetime_tags
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_print_y_datetime_tags, 0, 0, 6)
|
||||
ZEND_ARG_INFO(0, p0)
|
||||
ZEND_ARG_INFO(0, p1)
|
||||
ZEND_ARG_INFO(0, p2)
|
||||
ZEND_ARG_INFO(0, p3)
|
||||
ZEND_ARG_INFO(0, p4)
|
||||
ZEND_ARG_INFO(0, p5)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_log_print arginfo_weechat_plugin_get_name
|
||||
|
||||
#define arginfo_weechat_hook_command arginfo_weechat_register
|
||||
@@ -214,28 +225,21 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_hook_command_run arginfo_weechat_ngettext
|
||||
|
||||
#define arginfo_weechat_hook_timer arginfo_weechat_print_y_date_tags
|
||||
#define arginfo_weechat_hook_timer arginfo_weechat_print_datetime_tags
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_weechat_hook_fd, 0, 0, 6)
|
||||
ZEND_ARG_INFO(0, p0)
|
||||
ZEND_ARG_INFO(0, p1)
|
||||
ZEND_ARG_INFO(0, p2)
|
||||
ZEND_ARG_INFO(0, p3)
|
||||
ZEND_ARG_INFO(0, p4)
|
||||
ZEND_ARG_INFO(0, p5)
|
||||
ZEND_END_ARG_INFO()
|
||||
#define arginfo_weechat_hook_fd arginfo_weechat_print_y_datetime_tags
|
||||
|
||||
#define arginfo_weechat_hook_process arginfo_weechat_string_eval_expression
|
||||
|
||||
#define arginfo_weechat_hook_process_hashtable arginfo_weechat_print_y_date_tags
|
||||
#define arginfo_weechat_hook_process_hashtable arginfo_weechat_print_datetime_tags
|
||||
|
||||
#define arginfo_weechat_hook_url arginfo_weechat_print_y_date_tags
|
||||
#define arginfo_weechat_hook_url arginfo_weechat_print_datetime_tags
|
||||
|
||||
#define arginfo_weechat_hook_connect arginfo_weechat_list_new
|
||||
|
||||
#define arginfo_weechat_hook_line arginfo_weechat_print_y_date_tags
|
||||
#define arginfo_weechat_hook_line arginfo_weechat_print_datetime_tags
|
||||
|
||||
#define arginfo_weechat_hook_print arginfo_weechat_hook_fd
|
||||
#define arginfo_weechat_hook_print arginfo_weechat_print_y_datetime_tags
|
||||
|
||||
#define arginfo_weechat_hook_signal arginfo_weechat_ngettext
|
||||
|
||||
@@ -251,11 +255,11 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_hook_modifier_exec arginfo_weechat_ngettext
|
||||
|
||||
#define arginfo_weechat_hook_info arginfo_weechat_print_y_date_tags
|
||||
#define arginfo_weechat_hook_info arginfo_weechat_print_datetime_tags
|
||||
|
||||
#define arginfo_weechat_hook_info_hashtable arginfo_weechat_register
|
||||
|
||||
#define arginfo_weechat_hook_infolist arginfo_weechat_hook_fd
|
||||
#define arginfo_weechat_hook_infolist arginfo_weechat_print_y_datetime_tags
|
||||
|
||||
#define arginfo_weechat_hook_focus arginfo_weechat_ngettext
|
||||
|
||||
@@ -265,9 +269,9 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_unhook_all arginfo_weechat_plugin_get_name
|
||||
|
||||
#define arginfo_weechat_buffer_new arginfo_weechat_print_y_date_tags
|
||||
#define arginfo_weechat_buffer_new arginfo_weechat_print_datetime_tags
|
||||
|
||||
#define arginfo_weechat_buffer_new_props arginfo_weechat_hook_fd
|
||||
#define arginfo_weechat_buffer_new_props arginfo_weechat_print_y_datetime_tags
|
||||
|
||||
#define arginfo_weechat_buffer_search arginfo_weechat_iconv_to_internal
|
||||
|
||||
@@ -307,7 +311,7 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_window_set_title arginfo_weechat_plugin_get_name
|
||||
|
||||
#define arginfo_weechat_nicklist_add_group arginfo_weechat_print_y_date_tags
|
||||
#define arginfo_weechat_nicklist_add_group arginfo_weechat_print_datetime_tags
|
||||
|
||||
#define arginfo_weechat_nicklist_search_group arginfo_weechat_ngettext
|
||||
|
||||
@@ -441,7 +445,7 @@ ZEND_END_ARG_INFO()
|
||||
|
||||
#define arginfo_weechat_hdata_hashtable arginfo_weechat_ngettext
|
||||
|
||||
#define arginfo_weechat_hdata_compare arginfo_weechat_print_y_date_tags
|
||||
#define arginfo_weechat_hdata_compare arginfo_weechat_print_datetime_tags
|
||||
|
||||
#define arginfo_weechat_hdata_update arginfo_weechat_ngettext
|
||||
|
||||
|
||||
@@ -390,6 +390,34 @@ plugin_script_api_printf_date_tags (struct t_weechat_plugin *weechat_plugin,
|
||||
free (vbuffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints a message, with optional date/time (with microseconds) and tags.
|
||||
*/
|
||||
|
||||
void
|
||||
plugin_script_api_printf_datetime_tags (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date, int date_usec,
|
||||
const char *tags,
|
||||
const char *format, ...)
|
||||
{
|
||||
char *buf2;
|
||||
|
||||
weechat_va_format (format);
|
||||
if (!vbuffer)
|
||||
return;
|
||||
|
||||
buf2 = (script && script->charset && script->charset[0]) ?
|
||||
weechat_iconv_to_internal (script->charset, vbuffer) : NULL;
|
||||
weechat_printf_datetime_tags (buffer, date, date_usec, tags,
|
||||
"%s", (buf2) ? buf2 : vbuffer);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
|
||||
free (vbuffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints a message on a buffer with free content.
|
||||
*/
|
||||
@@ -442,6 +470,35 @@ plugin_script_api_printf_y_date_tags (struct t_weechat_plugin *weechat_plugin,
|
||||
free (vbuffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints a message on a buffer with free content, with optional date/time
|
||||
* (with microseconds) and tags.
|
||||
*/
|
||||
|
||||
void
|
||||
plugin_script_api_printf_y_datetime_tags (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer, int y,
|
||||
time_t date, int date_usec,
|
||||
const char *tags,
|
||||
const char *format, ...)
|
||||
{
|
||||
char *buf2;
|
||||
|
||||
weechat_va_format (format);
|
||||
if (!vbuffer)
|
||||
return;
|
||||
|
||||
buf2 = (script && script->charset && script->charset[0]) ?
|
||||
weechat_iconv_to_internal (script->charset, vbuffer) : NULL;
|
||||
weechat_printf_y_datetime_tags (buffer, y, date, date_usec, tags,
|
||||
"%s", (buf2) ? buf2 : vbuffer);
|
||||
if (buf2)
|
||||
free (buf2);
|
||||
|
||||
free (vbuffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints a message in WeeChat log file.
|
||||
*/
|
||||
@@ -857,6 +914,7 @@ plugin_script_api_hook_print (struct t_weechat_plugin *weechat_plugin,
|
||||
void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
int date_usec,
|
||||
int tags_count,
|
||||
const char **tags,
|
||||
int displayed, int highlight,
|
||||
|
||||
@@ -126,6 +126,12 @@ extern void plugin_script_api_printf_date_tags (struct t_weechat_plugin *weechat
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date, const char *tags,
|
||||
const char *format, ...);
|
||||
extern void plugin_script_api_printf_datetime_tags (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date, int date_usec,
|
||||
const char *tags,
|
||||
const char *format, ...);
|
||||
extern void plugin_script_api_printf_y (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
@@ -136,6 +142,13 @@ extern void plugin_script_api_printf_y_date_tags (struct t_weechat_plugin *weech
|
||||
int y, time_t date,
|
||||
const char *tags,
|
||||
const char *format, ...);
|
||||
extern void plugin_script_api_printf_y_datetime_tags (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
struct t_gui_buffer *buffer,
|
||||
int y,
|
||||
time_t date, int date_usec,
|
||||
const char *tags,
|
||||
const char *format, ...);
|
||||
extern void plugin_script_api_log_printf (struct t_weechat_plugin *weechat_plugin,
|
||||
struct t_plugin_script *script,
|
||||
const char *format, ...);
|
||||
@@ -256,6 +269,7 @@ extern struct t_hook *plugin_script_api_hook_print (struct t_weechat_plugin *wee
|
||||
void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
int date_usec,
|
||||
int tags_count,
|
||||
const char **tags,
|
||||
int displayed,
|
||||
|
||||
@@ -694,6 +694,7 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
|
||||
new_plugin->util_timeval_diff = &util_timeval_diff;
|
||||
new_plugin->util_timeval_add = &util_timeval_add;
|
||||
new_plugin->util_get_time_string = &util_get_time_string;
|
||||
new_plugin->util_strftimeval = &util_strftimeval;
|
||||
new_plugin->util_version_number = &util_version_number;
|
||||
|
||||
new_plugin->list_new = &weelist_new;
|
||||
@@ -789,8 +790,8 @@ plugin_load (const char *filename, int init_plugin, int argc, char **argv)
|
||||
|
||||
new_plugin->prefix = &plugin_api_prefix;
|
||||
new_plugin->color = &plugin_api_color;
|
||||
new_plugin->printf_date_tags = &gui_chat_printf_date_tags;
|
||||
new_plugin->printf_y_date_tags = &gui_chat_printf_y_date_tags;
|
||||
new_plugin->printf_datetime_tags = &gui_chat_printf_datetime_tags;
|
||||
new_plugin->printf_y_datetime_tags = &gui_chat_printf_y_datetime_tags;
|
||||
new_plugin->log_printf = &log_printf;
|
||||
|
||||
new_plugin->hook_command = &hook_command;
|
||||
|
||||
@@ -2012,6 +2012,33 @@ API_FUNC(prnt_date_tags)
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(prnt_datetime_tags)
|
||||
{
|
||||
char *buffer, *tags, *message;
|
||||
long date;
|
||||
int date_usec;
|
||||
|
||||
API_INIT_FUNC(1, "prnt_datetime_tags", API_RETURN_ERROR);
|
||||
buffer = NULL;
|
||||
date = 0;
|
||||
date_usec = 0;
|
||||
tags = NULL;
|
||||
message = NULL;
|
||||
if (!PyArg_ParseTuple (args, "sliss", &buffer, &date, &date_usec, &tags,
|
||||
&message))
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
plugin_script_api_printf_datetime_tags (weechat_python_plugin,
|
||||
python_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
(time_t)date,
|
||||
date_usec,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(prnt_y)
|
||||
{
|
||||
char *buffer, *message;
|
||||
@@ -2059,6 +2086,36 @@ API_FUNC(prnt_y_date_tags)
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(prnt_y_datetime_tags)
|
||||
{
|
||||
char *buffer, *tags, *message;
|
||||
int y;
|
||||
long date;
|
||||
int date_usec;
|
||||
|
||||
API_INIT_FUNC(1, "prnt_y_datetime_tags", API_RETURN_ERROR);
|
||||
buffer = NULL;
|
||||
y = 0;
|
||||
date = 0;
|
||||
date_usec = 0;
|
||||
tags = NULL;
|
||||
message = NULL;
|
||||
if (!PyArg_ParseTuple (args, "siliss", &buffer, &y, &date, &date_usec,
|
||||
&tags, &message))
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
plugin_script_api_printf_y_datetime_tags (weechat_python_plugin,
|
||||
python_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
y,
|
||||
(time_t)date,
|
||||
date_usec,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(log_print)
|
||||
{
|
||||
char *message;
|
||||
@@ -2797,7 +2854,7 @@ API_FUNC(hook_line)
|
||||
int
|
||||
weechat_python_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
time_t date, int date_usec,
|
||||
int tags_count, const char **tags,
|
||||
int displayed, int highlight,
|
||||
const char *prefix, const char *message)
|
||||
@@ -2810,6 +2867,7 @@ weechat_python_api_hook_print_cb (const void *pointer, void *data,
|
||||
int *rc, ret;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) date_usec;
|
||||
(void) tags_count;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
@@ -5527,8 +5585,10 @@ PyMethodDef weechat_python_funcs[] =
|
||||
API_DEF_FUNC(color),
|
||||
API_DEF_FUNC(prnt),
|
||||
API_DEF_FUNC(prnt_date_tags),
|
||||
API_DEF_FUNC(prnt_datetime_tags),
|
||||
API_DEF_FUNC(prnt_y),
|
||||
API_DEF_FUNC(prnt_y_date_tags),
|
||||
API_DEF_FUNC(prnt_y_datetime_tags),
|
||||
API_DEF_FUNC(log_print),
|
||||
API_DEF_FUNC(hook_command),
|
||||
API_DEF_FUNC(hook_completion),
|
||||
|
||||
@@ -1156,6 +1156,20 @@ def prnt_date_tags(buffer: str, date: int, tags: str, message: str) -> int:
|
||||
...
|
||||
|
||||
|
||||
def prnt_datetime_tags(buffer: str, date: int, date_usec: int, tags: str, message: str) -> int:
|
||||
"""`prnt_datetime_tags in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_prnt_datetime_tags>`_
|
||||
::
|
||||
|
||||
# example
|
||||
now = time.time()
|
||||
time_sec = int(now)
|
||||
time_usec = int((now * 1000000) % 1000000)
|
||||
weechat.prnt_datetime_tags("", time_sec - 120, time_usec, "notify_message",
|
||||
"Message 2 minutes ago, with a tag 'notify_message'")
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
def prnt_y(buffer: str, y: int, message: str) -> int:
|
||||
"""`prnt_y in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_prnt_y>`_
|
||||
::
|
||||
@@ -1176,6 +1190,16 @@ def prnt_y_date_tags(buffer: str, y: int, date: int, tags: str, message: str) ->
|
||||
...
|
||||
|
||||
|
||||
def prnt_y_datetime_tags(buffer: str, y: int, date: int, date_usec: int, tags: str, message: str) -> int:
|
||||
"""`prnt_y_datetime_tags in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_prnt_y_datetime_tags>`_
|
||||
::
|
||||
|
||||
# example
|
||||
weechat.prnt_y_datetime_tags("", 2, 0, 0, "my_tag", "My message on third line with a tag")
|
||||
"""
|
||||
...
|
||||
|
||||
|
||||
def log_print(message: str) -> int:
|
||||
"""`log_print in WeeChat plugin API reference <https://weechat.org/doc/weechat/api/#_log_print>`_
|
||||
::
|
||||
|
||||
@@ -1143,11 +1143,11 @@ relay_weechat_protocol_signal_buffer_cb (const void *pointer, void *data,
|
||||
snprintf (cmd_hdata, sizeof (cmd_hdata),
|
||||
"line_data:0x%lx",
|
||||
(unsigned long)ptr_line_data);
|
||||
relay_weechat_msg_add_hdata (msg, cmd_hdata,
|
||||
"buffer,date,date_printed,"
|
||||
"displayed,notify_level,"
|
||||
"highlight,tags_array,prefix,"
|
||||
"message");
|
||||
relay_weechat_msg_add_hdata (
|
||||
msg, cmd_hdata,
|
||||
"buffer,date,date_usec,date_printed,date_usec_printed,"
|
||||
"displayed,notify_level,highlight,tags_array,"
|
||||
"prefix,message");
|
||||
relay_weechat_msg_send (ptr_client, msg);
|
||||
relay_weechat_msg_free (msg);
|
||||
}
|
||||
|
||||
@@ -2486,6 +2486,43 @@ weechat_ruby_api_print_date_tags (VALUE class, VALUE buffer, VALUE date,
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_print_datetime_tags (VALUE class, VALUE buffer, VALUE date,
|
||||
VALUE date_usec, VALUE tags,
|
||||
VALUE message)
|
||||
{
|
||||
char *c_buffer, *c_tags, *c_message;
|
||||
time_t c_date;
|
||||
int c_date_usec;
|
||||
|
||||
API_INIT_FUNC(1, "print_datetime_tags", API_RETURN_ERROR);
|
||||
if (NIL_P (buffer) || NIL_P (date) || NIL_P (date_usec) || NIL_P (tags)
|
||||
|| NIL_P (message))
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
Check_Type (buffer, T_STRING);
|
||||
CHECK_INTEGER(date);
|
||||
CHECK_INTEGER(date_usec);
|
||||
Check_Type (tags, T_STRING);
|
||||
Check_Type (message, T_STRING);
|
||||
|
||||
c_buffer = StringValuePtr (buffer);
|
||||
c_date = NUM2ULONG (date);
|
||||
c_date_usec = NUM2INT (date_usec);
|
||||
c_tags = StringValuePtr (tags);
|
||||
c_message = StringValuePtr (message);
|
||||
|
||||
plugin_script_api_printf_datetime_tags (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
API_STR2PTR(c_buffer),
|
||||
c_date,
|
||||
c_date_usec,
|
||||
c_tags,
|
||||
"%s", c_message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_print_y (VALUE class, VALUE buffer, VALUE y, VALUE message)
|
||||
{
|
||||
@@ -2549,6 +2586,46 @@ weechat_ruby_api_print_y_date_tags (VALUE class, VALUE buffer, VALUE y,
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_print_y_datetime_tags (VALUE class, VALUE buffer, VALUE y,
|
||||
VALUE date, VALUE date_usec, VALUE tags,
|
||||
VALUE message)
|
||||
{
|
||||
char *c_buffer, *c_tags, *c_message;
|
||||
int c_y, c_date_usec;
|
||||
time_t c_date;
|
||||
|
||||
API_INIT_FUNC(1, "print_y_datetime_tags", API_RETURN_ERROR);
|
||||
if (NIL_P (buffer) || NIL_P (y) || NIL_P (date) || NIL_P (date_usec)
|
||||
|| NIL_P (tags) || NIL_P (message))
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
Check_Type (buffer, T_STRING);
|
||||
CHECK_INTEGER(y);
|
||||
CHECK_INTEGER(date);
|
||||
CHECK_INTEGER(date_usec);
|
||||
Check_Type (tags, T_STRING);
|
||||
Check_Type (message, T_STRING);
|
||||
|
||||
c_buffer = StringValuePtr (buffer);
|
||||
c_y = NUM2INT (y);
|
||||
c_date = NUM2ULONG (date);
|
||||
c_date_usec = NUM2INT (date_usec);
|
||||
c_tags = StringValuePtr (tags);
|
||||
c_message = StringValuePtr (message);
|
||||
|
||||
plugin_script_api_printf_y_datetime_tags (weechat_ruby_plugin,
|
||||
ruby_current_script,
|
||||
API_STR2PTR(c_buffer),
|
||||
c_y,
|
||||
c_date,
|
||||
c_date_usec,
|
||||
c_tags,
|
||||
"%s", c_message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
weechat_ruby_api_log_print (VALUE class, VALUE message)
|
||||
{
|
||||
@@ -3400,7 +3477,7 @@ weechat_ruby_api_hook_line (VALUE class, VALUE buffer_type, VALUE buffer_name,
|
||||
int
|
||||
weechat_ruby_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
time_t date, int date_usec,
|
||||
int tags_count, const char **tags,
|
||||
int displayed, int highlight,
|
||||
const char *prefix, const char *message)
|
||||
@@ -3413,6 +3490,7 @@ weechat_ruby_api_hook_print_cb (const void *pointer, void *data,
|
||||
int *rc, ret;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) date_usec;
|
||||
(void) tags_count;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
@@ -6838,8 +6916,10 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
|
||||
API_DEF_FUNC(color, 1);
|
||||
API_DEF_FUNC(print, 2);
|
||||
API_DEF_FUNC(print_date_tags, 4);
|
||||
API_DEF_FUNC(print_datetime_tags, 5);
|
||||
API_DEF_FUNC(print_y, 3);
|
||||
API_DEF_FUNC(print_y_date_tags, 5);
|
||||
API_DEF_FUNC(print_y_datetime_tags, 6);
|
||||
API_DEF_FUNC(log_print, 1);
|
||||
API_DEF_FUNC(hook_command, 7);
|
||||
API_DEF_FUNC(hook_completion, 4);
|
||||
|
||||
@@ -2277,6 +2277,38 @@ API_FUNC(print_date_tags)
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_datetime_tags)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *buffer, *tags, *message;
|
||||
int i, date_usec;
|
||||
long date;
|
||||
|
||||
API_INIT_FUNC(1, "print_datetime_tags", API_RETURN_ERROR);
|
||||
if (objc < 6)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
if (Tcl_GetLongFromObj (interp, objv[2], &date) != TCL_OK)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
if (Tcl_GetIntFromObj (interp, objv[3], &date_usec) != TCL_OK)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
buffer = Tcl_GetStringFromObj (objv[1], &i);
|
||||
tags = Tcl_GetStringFromObj (objv[4], &i);
|
||||
message = Tcl_GetStringFromObj (objv[5], &i);
|
||||
|
||||
plugin_script_api_printf_datetime_tags (weechat_tcl_plugin,
|
||||
tcl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
(time_t)date,
|
||||
date_usec,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_y)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
@@ -2334,6 +2366,42 @@ API_FUNC(print_y_date_tags)
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(print_y_datetime_tags)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
char *buffer, *tags, *message;
|
||||
int i, y, date_usec;
|
||||
long date;
|
||||
|
||||
API_INIT_FUNC(1, "print_y_datetime_tags", API_RETURN_ERROR);
|
||||
if (objc < 7)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
if (Tcl_GetIntFromObj (interp, objv[2], &y) != TCL_OK)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
if (Tcl_GetLongFromObj (interp, objv[3], &date) != TCL_OK)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
if (Tcl_GetIntFromObj (interp, objv[4], &date_usec) != TCL_OK)
|
||||
API_WRONG_ARGS(API_RETURN_ERROR);
|
||||
|
||||
buffer = Tcl_GetStringFromObj (objv[1], &i);
|
||||
tags = Tcl_GetStringFromObj (objv[5], &i);
|
||||
message = Tcl_GetStringFromObj (objv[6], &i);
|
||||
|
||||
plugin_script_api_printf_y_datetime_tags (weechat_tcl_plugin,
|
||||
tcl_current_script,
|
||||
API_STR2PTR(buffer),
|
||||
y,
|
||||
(time_t)date,
|
||||
date_usec,
|
||||
tags,
|
||||
"%s", message);
|
||||
|
||||
API_RETURN_OK;
|
||||
}
|
||||
|
||||
API_FUNC(log_print)
|
||||
{
|
||||
Tcl_Obj *objp;
|
||||
@@ -3097,7 +3165,7 @@ API_FUNC(hook_line)
|
||||
int
|
||||
weechat_tcl_api_hook_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
time_t date, int date_usec,
|
||||
int tags_count, const char **tags,
|
||||
int displayed, int highlight,
|
||||
const char *prefix, const char *message)
|
||||
@@ -3110,6 +3178,7 @@ weechat_tcl_api_hook_print_cb (const void *pointer, void *data,
|
||||
int *rc, ret;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) date_usec;
|
||||
(void) tags_count;
|
||||
|
||||
script = (struct t_plugin_script *)pointer;
|
||||
@@ -6118,8 +6187,10 @@ void weechat_tcl_api_init (Tcl_Interp *interp)
|
||||
API_DEF_FUNC(color);
|
||||
API_DEF_FUNC(print);
|
||||
API_DEF_FUNC(print_date_tags);
|
||||
API_DEF_FUNC(print_datetime_tags);
|
||||
API_DEF_FUNC(print_y);
|
||||
API_DEF_FUNC(print_y_date_tags);
|
||||
API_DEF_FUNC(print_y_datetime_tags);
|
||||
API_DEF_FUNC(log_print);
|
||||
API_DEF_FUNC(hook_command);
|
||||
API_DEF_FUNC(hook_completion);
|
||||
|
||||
@@ -1143,13 +1143,14 @@ end:
|
||||
int
|
||||
trigger_callback_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date, int tags_count, const char **tags,
|
||||
time_t date, int date_usec,
|
||||
int tags_count, const char **tags,
|
||||
int displayed, int highlight, const char *prefix,
|
||||
const char *message)
|
||||
{
|
||||
char *str_tags, *str_tags2, str_temp[128], *str_no_color;
|
||||
int length;
|
||||
struct tm *date_tmp;
|
||||
struct timeval tv;
|
||||
|
||||
TRIGGER_CALLBACK_CB_INIT(WEECHAT_RC_OK);
|
||||
|
||||
@@ -1166,14 +1167,10 @@ trigger_callback_print_cb (const void *pointer, void *data,
|
||||
/* add data in hashtables used for conditions/replace/command */
|
||||
trigger_callback_set_common_vars (trigger, ctx.extra_vars);
|
||||
weechat_hashtable_set (ctx.pointers, "buffer", buffer);
|
||||
date_tmp = localtime (&date);
|
||||
if (date_tmp)
|
||||
{
|
||||
if (strftime (str_temp, sizeof (str_temp),
|
||||
"%Y-%m-%d %H:%M:%S", date_tmp) == 0)
|
||||
str_temp[0] = '\0';
|
||||
weechat_hashtable_set (ctx.extra_vars, "tg_date", str_temp);
|
||||
}
|
||||
tv.tv_sec = date;
|
||||
tv.tv_usec = date_usec;
|
||||
weechat_util_strftimeval (str_temp, sizeof (str_temp), "%FT%T.%f", &tv);
|
||||
weechat_hashtable_set (ctx.extra_vars, "tg_date", str_temp);
|
||||
snprintf (str_temp, sizeof (str_temp), "%d", displayed);
|
||||
weechat_hashtable_set (ctx.extra_vars, "tg_displayed", str_temp);
|
||||
snprintf (str_temp, sizeof (str_temp), "%d", highlight);
|
||||
@@ -1313,8 +1310,7 @@ trigger_callback_timer_cb (const void *pointer, void *data,
|
||||
{
|
||||
char str_temp[128];
|
||||
int i;
|
||||
time_t date;
|
||||
struct tm *date_tmp;
|
||||
struct timeval tv_now;
|
||||
|
||||
TRIGGER_CALLBACK_CB_INIT(WEECHAT_RC_OK);
|
||||
|
||||
@@ -1337,15 +1333,9 @@ trigger_callback_timer_cb (const void *pointer, void *data,
|
||||
trigger_callback_set_common_vars (trigger, ctx.extra_vars);
|
||||
snprintf (str_temp, sizeof (str_temp), "%d", remaining_calls);
|
||||
weechat_hashtable_set (ctx.extra_vars, "tg_remaining_calls", str_temp);
|
||||
date = time (NULL);
|
||||
date_tmp = localtime (&date);
|
||||
if (date_tmp)
|
||||
{
|
||||
if (strftime (str_temp, sizeof (str_temp),
|
||||
"%Y-%m-%d %H:%M:%S", date_tmp) == 0)
|
||||
str_temp[0] = '\0';
|
||||
weechat_hashtable_set (ctx.extra_vars, "tg_date", str_temp);
|
||||
}
|
||||
gettimeofday (&tv_now, NULL);
|
||||
weechat_util_strftimeval (str_temp, sizeof (str_temp), "%FT%T.%f", &tv_now);
|
||||
weechat_hashtable_set (ctx.extra_vars, "tg_date", str_temp);
|
||||
|
||||
/* execute the trigger (conditions, regex, command) */
|
||||
if (!trigger_callback_execute (trigger, &ctx))
|
||||
|
||||
@@ -122,10 +122,10 @@ extern struct t_hashtable *trigger_callback_line_cb (const void *pointer, void
|
||||
struct t_hashtable *line);
|
||||
extern int trigger_callback_print_cb (const void *pointer, void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date, int tags_count,
|
||||
const char **tags, int displayed,
|
||||
int highlight, const char *prefix,
|
||||
const char *message);
|
||||
time_t date, int date_usec,
|
||||
int tags_count, const char **tags,
|
||||
int displayed, int highlight,
|
||||
const char *prefix, const char *message);
|
||||
extern int trigger_callback_command_cb (const void *pointer,
|
||||
void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
|
||||
@@ -68,7 +68,7 @@ struct timeval;
|
||||
* please change the date with current one; for a second change at same
|
||||
* date, increment the 01, otherwise please keep 01.
|
||||
*/
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20231017-01"
|
||||
#define WEECHAT_PLUGIN_API_VERSION "20231226-01"
|
||||
|
||||
/* macros for defining plugin infos */
|
||||
#define WEECHAT_PLUGIN_NAME(__name) \
|
||||
@@ -240,8 +240,8 @@ struct timeval;
|
||||
#define WEECHAT_COMMAND_MIN_ARGS(__min_args, __option) \
|
||||
if (argc < __min_args) \
|
||||
{ \
|
||||
weechat_printf_date_tags ( \
|
||||
NULL, 0, "no_filter", \
|
||||
weechat_printf_datetime_tags ( \
|
||||
NULL, 0, 0, "no_filter", \
|
||||
_("%sToo few arguments for command \"%s%s%s\" " \
|
||||
"(help on command: /help %s)"), \
|
||||
weechat_prefix ("error"), \
|
||||
@@ -255,8 +255,8 @@ struct timeval;
|
||||
/* macro to return error in callback of hook_command */
|
||||
#define WEECHAT_COMMAND_ERROR \
|
||||
{ \
|
||||
weechat_printf_date_tags ( \
|
||||
NULL, 0, "no_filter", \
|
||||
weechat_printf_datetime_tags ( \
|
||||
NULL, 0, 0, "no_filter", \
|
||||
_("%sError with command \"%s\" " \
|
||||
"(help on command: /help %s)"), \
|
||||
weechat_prefix ("error"), \
|
||||
@@ -437,6 +437,8 @@ struct t_weechat_plugin
|
||||
long long (*util_timeval_diff) (struct timeval *tv1, struct timeval *tv2);
|
||||
void (*util_timeval_add) (struct timeval *tv, long long interval);
|
||||
const char *(*util_get_time_string) (const time_t *date);
|
||||
int (*util_strftimeval) (char *string, int max, const char *format,
|
||||
struct timeval *tv);
|
||||
int (*util_version_number) (const char *version);
|
||||
|
||||
/* sorted lists */
|
||||
@@ -695,11 +697,13 @@ struct t_weechat_plugin
|
||||
/* display */
|
||||
const char *(*prefix) (const char *prefix);
|
||||
const char *(*color) (const char *color_name);
|
||||
void (*printf_date_tags) (struct t_gui_buffer *buffer, time_t date,
|
||||
const char *tags, const char *message, ...);
|
||||
void (*printf_y_date_tags) (struct t_gui_buffer *buffer, int y,
|
||||
time_t date, const char *tags,
|
||||
const char *message, ...);
|
||||
void (*printf_datetime_tags) (struct t_gui_buffer *buffer,
|
||||
time_t date, int date_usec,
|
||||
const char *tags, const char *message, ...);
|
||||
void (*printf_y_datetime_tags) (struct t_gui_buffer *buffer, int y,
|
||||
time_t date, int date_usec,
|
||||
const char *tags,
|
||||
const char *message, ...);
|
||||
void (*log_printf) (const char *message, ...);
|
||||
|
||||
/* hooks */
|
||||
@@ -814,6 +818,7 @@ struct t_weechat_plugin
|
||||
void *data,
|
||||
struct t_gui_buffer *buffer,
|
||||
time_t date,
|
||||
int date_usec,
|
||||
int tags_count,
|
||||
const char **tags,
|
||||
int displayed,
|
||||
@@ -1492,6 +1497,8 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
(weechat_plugin->util_timeval_add)(__time, __interval)
|
||||
#define weechat_util_get_time_string(__date) \
|
||||
(weechat_plugin->util_get_time_string)(__date)
|
||||
#define weechat_util_strftimeval(__string, __max, __format, __tv) \
|
||||
(weechat_plugin->util_strftimeval)(__string, __max, __format, __tv)
|
||||
#define weechat_util_version_number(__version) \
|
||||
(weechat_plugin->util_version_number)(__version)
|
||||
|
||||
@@ -1790,19 +1797,32 @@ extern int weechat_plugin_end (struct t_weechat_plugin *plugin);
|
||||
#define weechat_color(__color_name) \
|
||||
(weechat_plugin->color)(__color_name)
|
||||
#define weechat_printf(__buffer, __message, __argz...) \
|
||||
(weechat_plugin->printf_date_tags)(__buffer, 0, NULL, __message, \
|
||||
##__argz)
|
||||
(weechat_plugin->printf_datetime_tags)(__buffer, 0, 0, NULL, \
|
||||
__message, ##__argz)
|
||||
#define weechat_printf_date_tags(__buffer, __date, __tags, __message, \
|
||||
__argz...) \
|
||||
(weechat_plugin->printf_date_tags)(__buffer, __date, __tags, \
|
||||
__message, ##__argz)
|
||||
(weechat_plugin->printf_datetime_tags)(__buffer, __date, 0, __tags, \
|
||||
__message, ##__argz)
|
||||
|
||||
#define weechat_printf_datetime_tags(__buffer, __date, __date_usec, \
|
||||
__tags, __message, __argz...) \
|
||||
(weechat_plugin->printf_datetime_tags)(__buffer, __date, \
|
||||
__date_usec, __tags, \
|
||||
__message, ##__argz)
|
||||
#define weechat_printf_y(__buffer, __y, __message, __argz...) \
|
||||
(weechat_plugin->printf_y_date_tags)(__buffer, __y, 0, NULL, \
|
||||
__message, ##__argz)
|
||||
(weechat_plugin->printf_y_datetime_tags)(__buffer, __y, 0, 0, NULL, \
|
||||
__message, ##__argz)
|
||||
#define weechat_printf_y_date_tags(__buffer, __y, __date, __tags, \
|
||||
__message, __argz...) \
|
||||
(weechat_plugin->printf_y_date_tags)(__buffer, __y, __date, __tags, \
|
||||
__message, ##__argz)
|
||||
(weechat_plugin->printf_y_datetime_tags)(__buffer, __y, __date, 0, \
|
||||
__tags, __message, \
|
||||
##__argz)
|
||||
#define weechat_printf_y_datetime_tags(__buffer, __y, __date, \
|
||||
__date_usec, __tags, \
|
||||
__message, __argz...) \
|
||||
(weechat_plugin->printf_y_datetime_tags)(__buffer, __y, __date, \
|
||||
__date_usec, __tags, \
|
||||
__message, ##__argz)
|
||||
#define weechat_log_printf(__message, __argz...) \
|
||||
(weechat_plugin->log_printf)(__message, ##__argz)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user