about summary refs log tree commit diff stats
path: root/app.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2012-02-09 21:45:31 +0000
committerJames Booth <boothj5@gmail.com>2012-02-09 21:45:31 +0000
commit4148f0530711dc53e34c6ad6c0c3eefe14cf0090 (patch)
tree4d0d6c275644bb63d03457068f1278a7f5e0b287 /app.c
parentd77c397b180c337c4215cf3b97d80bd58ecd297a (diff)
downloadprofani-tty-4148f0530711dc53e34c6ad6c0c3eefe14cf0090.tar.gz
Added msg command
Diffstat (limited to 'app.c')
-rw-r--r--app.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/app.c b/app.c
index c43ce8da..0b2ebe8b 100644
--- a/app.c
+++ b/app.c
@@ -101,6 +101,25 @@ static void main_event_loop(void)
             jabber_roster_request();
             inp_clear();
 
+        // /msg -> send message to a user
+        } else if (strncmp(command, "/msg ", 5) == 0) {
+            char *usr_msg = NULL;
+            char *usr = NULL;
+            char *msg = NULL;
+            
+            usr_msg = strndup(command+5, strlen(command)-5);
+            cons_show(usr_msg);
+            
+            usr = strtok(usr_msg, " ");
+            if (usr != NULL) {
+                msg = strndup(command+5+strlen(usr)+1, strlen(command)-(5+strlen(usr)+1));
+                if (msg != NULL) {
+                    jabber_send(msg, usr);
+                    show_outgoing_msg("me", usr, msg);
+                }
+            }
+            inp_clear();
+
         // /close -> close the current chat window, if in chat
         } else if (strncmp(command, "/close", 6) == 0) {
             if (in_chat()) {
@@ -116,7 +135,7 @@ static void main_event_loop(void)
                 char recipient[100] = "";
                 get_recipient(recipient);
                 jabber_send(command, recipient);
-                show_outgoing_msg("me", command);
+                show_outgoing_msg("me", recipient, command);
             } else {
                 cons_bad_command(command);
             }