Added FROM_GROUP to README
[mirrors/libpurple-core-answerscripts.git] / answerscripts.c
index ca1a412..d562e51 100755 (executable)
@@ -61,15 +61,34 @@ int answerscripts_process_message_cb(answerscripts_job *job) {
 
 static void received_im_msg_cb(PurpleAccount *account, char *who, char *buffer, PurpleConversation *conv, PurpleMessageFlags flags, void *data) {
        if (conv == NULL) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, who); //* A workaround to avoid skipping of the first message as a result on NULL-conv: */
+       PurpleBuddy *buddy = purple_find_buddy(account, who);
 
        //Get message
        message = purple_markup_strip_html(buffer);
-       //printf("\nHarvie received: %s: %s\n", who, message); //debug
-       //purple_conv_im_send(purple_conversation_get_im_data(conv), ":-*"); //debug
+
+       /* Here are prototypes of some functions interesting to implement github feature request #3
+
+       LOCAL USER:
+       const char* purple_account_get_alias    (       const PurpleAccount *            account         )
+       const gchar* purple_account_get_name_for_display        (       const PurpleAccount *            account         )
+       REMOTE USER (Buddy):
+       const char *    purple_contact_get_alias (PurpleContact *contact)
+       const char *    purple_buddy_get_name (const PurpleBuddy *buddy)
+       const char *    purple_buddy_get_alias_only (PurpleBuddy *buddy)
+       const char *    purple_buddy_get_server_alias (PurpleBuddy *buddy)
+       const char *    purple_buddy_get_contact_alias (PurpleBuddy *buddy)
+       const char *    purple_buddy_get_local_alias (PurpleBuddy *buddy)
+       const char *    purple_buddy_get_alias (PurpleBuddy *buddy)
+       PurpleGroup *   purple_buddy_get_group (PurpleBuddy *buddy)
+       const char *    purple_group_get_name (PurpleGroup *group)
+       */
+
+       //Get buddy group
+       const char *from_group = purple_group_get_name(purple_buddy_get_group(buddy));
 
        //Get protocol ID
        const char *protocol_id = purple_account_get_protocol_id(account);
-       if(!strncmp(protocol_id,PROTOCOL_PREFIX,strlen(PROTOCOL_PREFIX))) protocol_id += strlen(PROTOCOL_PREFIX); //trim out protocol prefix (eg.: "prpl-irc" => "irc")
+       if(!strncmp(protocol_id,PROTOCOL_PREFIX,strlen(PROTOCOL_PREFIX))) protocol_id += strlen(PROTOCOL_PREFIX); //trim out PROTOCOL_PREFIX (eg.: "prpl-irc" => "irc")
 
        //Get status
        PurpleStatus *status = purple_account_get_active_status(account);
@@ -90,6 +109,7 @@ static void received_im_msg_cb(PurpleAccount *account, char *who, char *buffer,
        //Export variables to environment
        setenv(ENV_PREFIX "MSG", message, 1);
        setenv(ENV_PREFIX "FROM", who, 1);
+       setenv(ENV_PREFIX "FROM_GROUP", from_group, 1);
        setenv(ENV_PREFIX "PROTOCOL", protocol_id, 1);
        setenv(ENV_PREFIX "STATUS", status_id, 1);
        setenv(ENV_PREFIX "STATUS_MSG", status_msg, 1);
This page took 0.114797 seconds and 4 git commands to generate.