mirror of
https://github.com/msantos/xmppipe
synced 2024-11-13 13:10:32 +00:00
Add "to" field to message
Distinguish which user received a message. Possibly useful if multiple sessions are logged in or someone directly messages the bot.
This commit is contained in:
parent
4310fe0e6b
commit
69f97cd872
@ -35,7 +35,7 @@ bot() {
|
||||
elif [ "$1" = "m" ]; then
|
||||
USER="$(decode ${3#*%2F})"
|
||||
IFS=$OFS
|
||||
MSG="$(decode $4)"
|
||||
MSG="$(decode ${!#})"
|
||||
case $MSG in
|
||||
*"has set the subject to:"*) ;;
|
||||
"sudo make me a sandwich")
|
||||
|
@ -30,7 +30,7 @@ decode() {
|
||||
OFS=$IFS
|
||||
IFS=:
|
||||
set -- $line
|
||||
[ "$1" = "m" ] && printf '%b' "${4//%/\\x}"
|
||||
[ "$1" = "m" ] && printf '%b' "${!#//%/\\x}"
|
||||
IFS=$OFS
|
||||
done
|
||||
}
|
||||
|
@ -916,9 +916,11 @@ handle_message(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
char *message = NULL;
|
||||
char *type = NULL;
|
||||
char *from = NULL;
|
||||
char *to = NULL;
|
||||
|
||||
char *etype = NULL;
|
||||
char *efrom = NULL;
|
||||
char *eto = NULL;
|
||||
char *emessage = NULL;
|
||||
|
||||
if (xmpp_stanza_get_child_by_name(stanza, "delay"))
|
||||
@ -928,6 +930,10 @@ handle_message(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
if (!from)
|
||||
return 1;
|
||||
|
||||
to = xmpp_stanza_get_attribute(stanza, "to");
|
||||
if (!to)
|
||||
return 1;
|
||||
|
||||
type = xmpp_stanza_get_type(stanza);
|
||||
if (!type)
|
||||
return 1;
|
||||
@ -963,13 +969,15 @@ handle_message(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
|
||||
etype = xmppipe_fmt(type);
|
||||
efrom = xmppipe_fmt(from);
|
||||
eto = xmppipe_fmt(to);
|
||||
|
||||
(void)printf("m:%s:%s:%s\n", etype, efrom, emessage);
|
||||
(void)printf("m:%s:%s:%s:%s\n", etype, efrom, eto, emessage);
|
||||
state->interval = 0;
|
||||
|
||||
free(message);
|
||||
free(etype);
|
||||
free(efrom);
|
||||
free(eto);
|
||||
free(emessage);
|
||||
|
||||
return 1;
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include <strophe.h>
|
||||
|
||||
#define XMPPIPE_VERSION "0.6.1"
|
||||
#define XMPPIPE_VERSION "0.7.0"
|
||||
|
||||
#define XMPPIPE_STREQ(a,b) !strcmp((a),(b))
|
||||
#define XMPPIPE_STRNEQ(a,b) strcmp((a),(b))
|
||||
|
Loading…
Reference in New Issue
Block a user