sas             Thu Jun 26 14:06:20 2003 EDT

  Modified files:              
    /php-src/ext/ircg   ircg.c php_ircg_formats.h 
  Log:
  Add NOTICE handling
  
  
Index: php-src/ext/ircg/ircg.c
diff -u php-src/ext/ircg/ircg.c:1.189 php-src/ext/ircg/ircg.c:1.190
--- php-src/ext/ircg/ircg.c:1.189       Tue Jun 17 19:35:19 2003
+++ php-src/ext/ircg/ircg.c     Thu Jun 26 14:06:20 2003
@@ -16,7 +16,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: ircg.c,v 1.189 2003/06/17 23:35:19 sas Exp $ */
+/* $Id: ircg.c,v 1.190 2003/06/26 18:06:20 sas Exp $ */
 
 /* {{{ includes */
 
@@ -184,8 +184,8 @@
 
 static char *fmt_msgs_default[] = {
        "[%c] %f: %m<br />",
-       "privat from %f: %m<br />",
-       "%f privat to %t: %m<br />",
+       "private from %f: %m<br />",
+       "%f private to %t: %m<br />",
        "%f leaves %c<br />",
        "%f joins %c<br />",
        "%t was kicked by %f from %c (%m)<br />",
@@ -215,6 +215,9 @@
        "is on server %t, has flag %f, hopcount %m, and channel %c.<br />",
        "end of who<br />",
        "%f is inviting %t to %c<br />",
+       "[notice %c] %f: %m<br />",
+       "notice from %f: %m<br />",
+       "notice to %t: %m<br />",
 };
 
 ZEND_DECLARE_MODULE_GLOBALS(ircg);
@@ -560,7 +563,6 @@
                }
        }
 }
-       
 
 static void msg_handler(irconn_t *ircc, smart_str *chan, smart_str *from,
                smart_str *msg, void *conn_data, void *chan_data)
@@ -583,6 +585,27 @@
        msg_send(conn, &m);
 }
 
+static void notice_handler(irconn_t *ircc, smart_str *chan, smart_str *from,
+               smart_str *msg, void *conn_data, void *chan_data)
+{
+       php_irconn_t *conn = conn_data;
+       smart_str m = {0};
+       smart_str s_username;
+
+       smart_str_setl(&s_username, ircc->username, ircc->username_len);
+
+       if (msg->c[0] == '\001') {
+               handle_ctcp(conn, chan, from, chan?chan:NULL, msg, &m);
+       } else if (chan) {
+               FORMAT_MSG(conn, FMT_MSG_NOTICE_CHAN, chan, &s_username, from, msg, 
&m, conn->conn.username, conn->conn.username_len);
+       } else {
+               FORMAT_MSG(conn, FMT_MSG_NOTICE_TO_ME, NULL, &s_username, from,
+                               msg, &m, conn->conn.username, conn->conn.username_len);
+       }
+
+       msg_send(conn, &m);
+}
+
 static void nick_handler(irconn_t *c, smart_str *oldnick, smart_str *newnick,
                void *dummy)
 {
@@ -1803,6 +1826,7 @@
        IRCG_CB_MAP_ENTRY(whoreply_handler)
        IRCG_CB_MAP_ENTRY(endofwho_handler)
        IRCG_CB_MAP_ENTRY(invite_handler)
+       IRCG_CB_MAP_ENTRY(notice_handler)
 IRCG_CB_MAP_END()
 
 /* {{{ register_hooks */
@@ -1892,6 +1916,8 @@
        IFMSG(FMT_MSG_INVITE, IRCG_INVITE, invite_handler);
 #endif
 
+       irc_register_hook(conn, IRCG_NOTICE, notice_handler);
+       
        irc_set_map_handle(conn, php_ircg_cb_msg_handle);
 }
 /* }}} */
Index: php-src/ext/ircg/php_ircg_formats.h
diff -u php-src/ext/ircg/php_ircg_formats.h:1.1 php-src/ext/ircg/php_ircg_formats.h:1.2
--- php-src/ext/ircg/php_ircg_formats.h:1.1     Mon Dec  9 07:42:28 2002
+++ php-src/ext/ircg/php_ircg_formats.h Thu Jun 26 14:06:20 2003
@@ -32,6 +32,9 @@
        FMT_MSG_WHOREPLY2,
        FMT_MSG_ENDOFWHO,
        FMT_MSG_INVITE,
+       FMT_MSG_NOTICE_CHAN,
+       FMT_MSG_NOTICE_TO_ME,
+       FMT_MSG_NOTICE_FROM_ME,
        NO_FMTS
 };
 /* }}} */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to