From 74112dcee5dad56a5b883221835f5cc1fa17319f Mon Sep 17 00:00:00 2001 From: Ben Date: Tue, 15 Dec 2009 18:43:24 -0500 Subject: [PATCH] Map auto-reply messages. --- perl/lib/Thrasher/Protocol/Purple.pm | 9 +++++---- thconversations.c | 5 +++-- thperl.c | 4 +++- thperl.h | 3 ++- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/perl/lib/Thrasher/Protocol/Purple.pm b/perl/lib/Thrasher/Protocol/Purple.pm index 98051d8..8bc4eda 100644 --- a/perl/lib/Thrasher/Protocol/Purple.pm +++ b/perl/lib/Thrasher/Protocol/Purple.pm @@ -464,10 +464,7 @@ sub _connection_error { # Callback for incoming messages sub _incoming_msg { - my $jid = shift; - my $sender = shift; - my $alias = shift; - my $message = shift; + my ($jid, $sender, $alias, $message, $flags) = @_; $jid = Encode::decode("UTF-8", $jid); $sender = Encode::decode("UTF-8", $sender); @@ -480,6 +477,10 @@ sub _incoming_msg { my $clean_sender = $session->{protocol}->process_remote_username($sender); + if ($flags & $THPPW::PURPLE_MESSAGE_AUTO_RESP) { + $message = '(auto-reply) ' . $message; + } + # Type is currently hard coded... $protocol->sending_message($clean_sender, $session->{legacy_login}, $message, 1); diff --git a/thconversations.c b/thconversations.c index 44ecaea..831f366 100644 --- a/thconversations.c +++ b/thconversations.c @@ -60,7 +60,7 @@ thrasher_write_conv(PurpleConversation *conv, account = purple_conversation_get_account(conv); /* libpurple throws write_conv on every recv and send */ - if (flags != PURPLE_MESSAGE_RECV) + if (! (flags & PURPLE_MESSAGE_RECV)) return; purple_debug_info("thrasher", @@ -69,7 +69,8 @@ thrasher_write_conv(PurpleConversation *conv, thrasher_wrapper_incoming_msg(thrasher_account_get_jid(account), who, alias, - message); + message, + flags); #ifdef TH_DEBUG purple_debug_info("thrasher", diff --git a/thperl.c b/thperl.c index 4600b4d..ba2fb53 100644 --- a/thperl.c +++ b/thperl.c @@ -925,7 +925,8 @@ long thrasher_wrapper_set_timeout_add (guint interval, GSourceFunc function, gpo int thrasher_wrapper_incoming_msg (const char *jid, const char *sender, const char *alias, - const char *message) + const char *message, + PurpleMessageFlags flags) { int ret = 0; @@ -949,6 +950,7 @@ int thrasher_wrapper_incoming_msg (const char *jid, XPUSHs(sv_2mortal(newSVpvn(sender, strlen(sender)))); XPUSHs(sv_2mortal(newSVpvn(alias, strlen(alias)))); XPUSHs(sv_2mortal(newSVpvn(message, strlen(message)))); + XPUSHs(sv_2mortal(newSViv(flags))); PUTBACK; diff --git a/thperl.h b/thperl.h index 6ade392..6ea02eb 100644 --- a/thperl.h +++ b/thperl.h @@ -214,7 +214,8 @@ int thrasher_wrapper_subscription_add(const char *jid, int thrasher_wrapper_incoming_msg (const char *jid, const char *sender, const char *alias, - const char *message); + const char *message, + PurpleMessageFlags flags); int thrasher_wrapper_connection (const char *jid); -- 2.11.4.GIT