Fixed sending to chatrooms, version bump
authorTomas Mudrunka <tomas@mudrunka.cz>
Wed, 18 Feb 2015 12:05:03 +0000 (13:05 +0100)
committerTomas Mudrunka <tomas@mudrunka.cz>
Wed, 18 Feb 2015 12:14:44 +0000 (13:14 +0100)
TODO.md
answerscripts.c

diff --git a/TODO.md b/TODO.md
index 65fbdd00c3b93a09290a0dde7c4e31ebf0d8a85e..d56087a386b3653a3fe100f55760fa4f09fb6118 100644 (file)
--- 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
index d24e58f9ad1104465d35fafd1be9c22721fe4b05..bb3d8498458b9f7d5962d76d6847db7bf57e6379 100755 (executable)
@@ -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()) "
This page took 0.36449 seconds and 4 git commands to generate.