From: Tomas Mudrunka Date: Wed, 18 Feb 2015 12:05:03 +0000 (+0100) Subject: Fixed sending to chatrooms, version bump X-Git-Url: http://git.harvie.cz/?p=mirrors%2Flibpurple-core-answerscripts.git;a=commitdiff_plain;h=5cd90c724ea732d22049421acc0e5da739af7076 Fixed sending to chatrooms, version bump --- diff --git a/TODO.md b/TODO.md index 65fbdd0..d56087a 100644 --- a/TODO.md +++ b/TODO.md @@ -8,3 +8,6 @@ * Make this answerscript API stable * Port whole idea and plugin to other (non-purple) libraries/clients while maintaining compatibility of existing answerscripts and API * probably move answerscripts out of ~/.purple/ to ~/.config/answ/ or something, so they can be shared between multiple agents + * Figure out why is first reply always followed by some ugly binary mess + * visible in irssi + * but it happens even for messages not sent by this plugin, so probably not my fault diff --git a/answerscripts.c b/answerscripts.c index d24e58f..bb3d849 100755 --- a/answerscripts.c +++ b/answerscripts.c @@ -49,9 +49,14 @@ int answerscripts_process_message_cb(answerscripts_job *job) { && (errno == EWOULDBLOCK || errno == EAGAIN) //WARNING! Not compatible with windows :-( ) return 1; - for(i=0;response[i];i++) if(response[i]=='\n') response[i]=0; - if(response[0]!='\0') purple_conv_im_send(purple_conversation_get_im_data(conv), response); - + for(i=0;response[i];i++) if(response[i]=='\n') response[i]='\0'; + if(response[0]!='\0') { + if(purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) { + purple_conv_chat_send(purple_conversation_get_chat_data(conv), response); + } else { + purple_conv_im_send(purple_conversation_get_im_data(conv), response); + } + } if(!feof(pipe)) return 1; } pclose(pipe); @@ -89,6 +94,9 @@ static void received_msg_cb(PurpleAccount *account, char *who, char *buffer, Pur const char* local_alias = purple_account_get_alias(account); if(local_alias == NULL) local_alias = local_name; + //Do not respond to messages sent by myself + if(strcmp(local_name, who) == 0) return; + //Was my nick said? char *highlighted; if(flags & PURPLE_MESSAGE_NICK || purple_utf8_has_word(buffer, local_name)) @@ -200,7 +208,7 @@ static PurplePluginInfo info = { "core-answerscripts", "AnswerScripts", - "0.5.2", + "0.5.3", "Framework for hooking scripts to process received messages for libpurple clients", "\nThis plugin will execute script \"~/.purple/" ANSWERSCRIPT "\" " "(or any other executable called \"" ANSWERSCRIPT "\" and found in purple_user_dir()) "