Sun, 10 Nov 2024 03:49:39 -0600
Add very basic command support to Pidgin
In the future we'll add a popover and stuff, but for now this just attempts to
run commands that were input.
Testing Done:
Used the say command in an ircv3 channel.
Bugs closed: PIDGIN-17970
Reviewed at https://reviews.imfreedom.org/r/3645/
| pidgin/pidginconversation.c | file | annotate | diff | comparison | revisions |
--- a/pidgin/pidginconversation.c Sun Nov 10 03:48:06 2024 -0600 +++ b/pidgin/pidginconversation.c Sun Nov 10 03:49:39 2024 -0600 @@ -140,6 +140,7 @@ GtkTextIter start; GtkTextIter end; char *contents = NULL; + gboolean command_executed = FALSE; account = purple_conversation_get_account(conversation->conversation); @@ -150,17 +151,29 @@ contents = gtk_text_buffer_get_text(buffer, &start, &end, TRUE); - /* Create the message. */ - info = purple_account_get_contact_info(account); - message = purple_message_new(info, contents); + if(contents != NULL && contents[0] == '/') { + PurpleCommandManager *manager = NULL; + + manager = purple_command_manager_get_default(); + command_executed = purple_command_manager_find_and_execute(manager, + conversation->conversation, + contents + 1); + } - /* Send the message and clean up. We don't worry about the callback as we - * don't have anything to do in it right now. - */ - purple_conversation_send_message_async(conversation->conversation, message, - NULL, NULL, NULL); + if(!command_executed) { + /* Create the message. */ + info = purple_account_get_contact_info(account); + message = purple_message_new(info, contents); - g_clear_object(&message); + /* Send the message and clean up. We don't worry about the callback as we + * don't have anything to do in it right now. + */ + purple_conversation_send_message_async(conversation->conversation, message, + NULL, NULL, NULL); + + g_clear_object(&message); + } + g_clear_pointer(&contents, g_free); gtk_text_buffer_set_text(buffer, "", -1);