]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
ctcp action support
authorAkari <hetors.email@gmail.com>
Thu, 10 Feb 2011 09:15:14 +0000 (11:15 +0200)
committerAkari <hetors.email@gmail.com>
Thu, 10 Feb 2011 09:15:14 +0000 (11:15 +0200)
irc.c
irc.h

diff --git a/irc.c b/irc.c
index e621cc8f320f2a655c865cf915d55a29c59c3c59..cd06928f66b5c8f8a86b29d09eb3713a83e55d21 100755 (executable)
--- a/irc.c
+++ b/irc.c
@@ -157,6 +157,7 @@ static void CL_Irc_Connect_f(void)
     cb.event_kick    = event_kick;
     cb.event_notice  = event_notice;
     cb.event_invite  = event_invite;
+    cb.event_ctcp_action = event_ctcp_action;
 
     Cvar_SetQuick(&irc_current_nick, irc_nick.string);
 
@@ -276,8 +277,22 @@ static void CL_Irc_Say_Universal_f(void)
             
             break;
         
-        case MSGMODE_ACTION: //to-do
+        case MSGMODE_ACTION:
             irc_cmd_me(irc_session_global, dest, message);
+            
+            if(ISCHANNEL(dest)) Con_Printf("%s%s^3%s^0| ^2* %s ^7%s\n",
+                watched? "\001" : CHATWINDOW,
+                irc_msgprefix.string,
+                dest,
+                irc_current_nick.string,
+                message
+            ); else Con_Printf("%s%s^1Privmsg to ^2%s^7: ^2* %s ^3%s\n",
+                CHATWINDOW_URGENT,
+                irc_msgprefix.string,
+                dest,
+                irc_current_nick.string,
+                message
+            );
             break;
     }
 }
@@ -662,6 +677,65 @@ IRCEVENT(event_invite)
     );
 }
 
+IRCEVENT(event_ctcp_action)
+{
+    char* msgstr = "";
+    qboolean watched;
+    
+    if(!ISCHANNEL(params[0]))
+    {
+        event_ctcp_action_priv(session, event, origin, params, count);
+        return;
+    }
+    
+    if(count > 1)
+        msgstr = irc_color_strip_from_mirc(params[1]);
+    
+    watched = Irc_IsWatchedChannel(params[0]);
+    
+    if(Irc_CheckHilight(msgstr))
+    {   
+        UPDATETARGET(params[0])
+        
+        Con_Printf("%s%s^3%s^0| ^1* %s ^7%s\n",
+            watched? "\001" : CHATWINDOW_URGENT,
+            irc_msgprefix.string,
+            params[0],
+            origin,
+            msgstr
+        );
+    }
+    else Con_Printf("%s%s^3%s^0| ^2* %s ^7%s\n",
+        watched? "\001" : CHATWINDOW,
+        irc_msgprefix.string,
+        params[0],
+        origin,
+        msgstr
+    );
+    
+    if(count > 1) free(msgstr);
+}
+
+//called by event_ctcp_action
+IRCEVENT(event_ctcp_action_priv)
+{
+    char* msgstr = "";
+    
+    if(count > 1)
+        msgstr = irc_color_strip_from_mirc(params[1]);
+    
+    UPDATETARGET(origin)
+    
+    Con_Printf("%s%s^1Privmsg^7: ^2* %s ^3%s\n",
+        CHATWINDOW_URGENT,
+        irc_msgprefix.string,
+        origin,
+        msgstr
+    );
+    
+    if(count > 1) free(msgstr);
+}
+
 //
 //  Function that checks if a message contains hilights
 //
diff --git a/irc.h b/irc.h
index bd1cec4586c60659888c2a54855896f13c853c32..9444fb875a20c2edcdb08d48fbb2954438cd3400 100755 (executable)
--- a/irc.h
+++ b/irc.h
@@ -54,6 +54,8 @@ IRCEVENT(event_topic);
 IRCEVENT(event_kick);
 IRCEVENT(event_notice);
 IRCEVENT(event_invite);
+IRCEVENT(event_ctcp_action);
+IRCEVENT(event_ctcp_action_priv);
 
 #define MSGMODE_PRIVMSG 0
 #define MSGMODE_NOTICE  1