Add option 'eventcmd_use_nickname'
This is based on a patch from "bebebe".
When this option is set, a nickname is passed to the event script in
place of the JID.
--- a/mcabber/mcabberrc.example Fri Mar 21 19:27:52 2008 +0100
+++ b/mcabber/mcabberrc.example Fri Mar 21 19:49:27 2008 +0100
@@ -204,6 +204,10 @@
#set event_log_files = 0
#set event_log_dir = ~/.mcabber/event_files
+# If you set 'eventcmd_use_nickname' to 1, mcabber will pass the nickname
+# (if it is defined) to the event script instead of the JID (default: 0).
+#set eventcmd_use_nickname = 0
+
# External command status check
# You can request mcabber to inspect exit status value after each
# events_command. If this option is set, mcabber will beep if the
--- a/mcabber/src/hooks.c Fri Mar 21 19:27:52 2008 +0100
+++ b/mcabber/src/hooks.c Fri Mar 21 19:49:27 2008 +0100
@@ -73,6 +73,7 @@
char *wmsg = NULL, *bmsg = NULL, *mmsg = NULL;
GSList *roster_usr;
unsigned mucnicklen = 0;
+ const char *name = NULL;
if (encrypted)
message_flags |= HBB_PREFIX_PGPCRYPT;
@@ -206,17 +207,19 @@
}
}
+ if (settings_opt_get_int("eventcmd_use_nickname"))
+ name = roster_getname(bjid);
+
// External command
// - We do not call hk_ext_cmd() for history lines in MUC
// - We do call hk_ext_cmd() for private messages in a room
// - We do call hk_ext_cmd() for messages to the current window
if (!active_window && ((is_groupchat && !timestamp) || !is_groupchat))
- hk_ext_cmd(bjid, (is_groupchat ? 'G' : 'M'), 'R', wmsg);
+ hk_ext_cmd(name ? name : bjid, (is_groupchat ? 'G' : 'M'), 'R', wmsg);
// Display the sender in the log window
if ((!is_groupchat) && !(message_flags & HBB_PREFIX_ERR) &&
settings_opt_get_int("log_display_sender")) {
- const char *name = roster_getname(bjid);
if (!name) name = "";
scr_LogPrint(LPRINT_NORMAL, "Message received from %s <%s/%s>",
name, bjid, (resname ? resname : ""));
@@ -295,11 +298,14 @@
char *bn = NULL;
char *logsmsg;
const char *rn = (resname ? resname : "");
+ const char *name = NULL;
+
+ if (settings_opt_get_int("eventcmd_use_nickname"))
+ name = roster_getname(bjid);
st_in_buf = settings_opt_get_int("show_status_in_buffer");
buddy_format = settings_opt_get_int("buddy_format");
if (buddy_format) {
- const char *name = roster_getname(bjid);
if (name && strcmp(name, bjid)) {
if (buddy_format == 1)
bn = g_strdup_printf("%s <%s/%s>", name, bjid, rn);
@@ -342,7 +348,7 @@
scr_DrawRoster();
hlog_write_status(bjid, timestamp, status, status_msg);
// External command
- hk_ext_cmd(bjid, 'S', imstatus2char[status], NULL);
+ hk_ext_cmd(name ? name : bjid, 'S', imstatus2char[status], NULL);
}
void hk_mystatuschange(time_t timestamp, enum imstatus old_status,