]> jfr.im git - solanum.git/blobdiff - modules/core/m_message.c
core/m_message: Add AV2 description
[solanum.git] / modules / core / m_message.c
index daff1b5b0569d5bc8cd828d963f8d7f9bbb76fb3..dd6b7bee879bfa84bec98689178cb880684e3091 100644 (file)
@@ -20,8 +20,6 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  *  USA
- *
- *  $Id: m_message.c 3173 2007-01-31 23:57:18Z jilles $
  */
 
 #include "stdinc.h"
 #include "tgchange.h"
 #include "inline/stringops.h"
 
-static int m_message(enum message_type, struct Client *, struct Client *, int, const char **);
-static int m_privmsg(struct Client *, struct Client *, int, const char **);
-static int m_notice(struct Client *, struct Client *, int, const char **);
+static int m_message(enum message_type, struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static int m_privmsg(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static int m_notice(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static const char message_desc[] =
+       "Provides the PRIVMSG and NOTICE commands to send messages to users and channels";
 
 static void expire_tgchange(void *unused);
 static struct ev_entry *expire_tgchange_event;
@@ -68,17 +68,17 @@ moddeinit(void)
 }
 
 struct Message privmsg_msgtab = {
-       "PRIVMSG", 0, 0, 0, MFLG_SLOW | MFLG_UNREG,
+       "PRIVMSG", 0, 0, 0, 0,
        {mg_unreg, {m_privmsg, 0}, {m_privmsg, 0}, mg_ignore, mg_ignore, {m_privmsg, 0}}
 };
 struct Message notice_msgtab = {
-       "NOTICE", 0, 0, 0, MFLG_SLOW,
+       "NOTICE", 0, 0, 0, 0,
        {mg_unreg, {m_notice, 0}, {m_notice, 0}, {m_notice, 0}, mg_ignore, {m_notice, 0}}
 };
 
 mapi_clist_av1 message_clist[] = { &privmsg_msgtab, &notice_msgtab, NULL };
 
-DECLARE_MODULE_AV1(message, modinit, moddeinit, message_clist, NULL, NULL, "$Revision: 3173 $");
+DECLARE_MODULE_AV2(message, modinit, moddeinit, message_clist, NULL, NULL, NULL, NULL, message_desc);
 
 struct entity
 {
@@ -152,15 +152,15 @@ const char *cmdname[MESSAGE_TYPE_COUNT] = {
 };
 
 static int
-m_privmsg(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+m_privmsg(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
-       return m_message(MESSAGE_TYPE_PRIVMSG, client_p, source_p, parc, parv);
+       return m_message(MESSAGE_TYPE_PRIVMSG, msgbuf_p, client_p, source_p, parc, parv);
 }
 
 static int
-m_notice(struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
+m_notice(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
-       return m_message(MESSAGE_TYPE_NOTICE, client_p, source_p, parc, parv);
+       return m_message(MESSAGE_TYPE_NOTICE, msgbuf_p, client_p, source_p, parc, parv);
 }
 
 /*
@@ -170,7 +170,7 @@ m_notice(struct Client *client_p, struct Client *source_p, int parc, const char
  *             - pointer to channel
  */
 static int
-m_message(enum message_type msgtype,
+m_message(enum message_type msgtype, struct MsgBuf *msgbuf_p,
          struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
 {
        int i;
@@ -246,7 +246,6 @@ m_message(enum message_type msgtype,
  *               all the classic old bizzare oper privmsg tricks
  *               are parsed and sent as is, if prefixed with $
  *               to disambiguate.
- *
  */
 
 static int
@@ -364,7 +363,7 @@ build_target_list(enum message_type msgtype, struct Client *client_p,
                                                   get_id(&me, source_p),
                                                   get_id(source_p, source_p),
                                                   with_prefix);
-                                       return (-1);
+                                       continue;
                                }
 
                                if(!duplicate_ptr(chptr))
@@ -618,7 +617,7 @@ msg_channel_opmod(enum message_type msgtype,
 /*
  * msg_channel_flags
  *
- * inputs      - flag 0 if PRIVMSG 1 if NOTICE. RFC 
+ * inputs      - flag 0 if PRIVMSG 1 if NOTICE. RFC
  *               say NOTICE must not auto reply
  *             - pointer to client_p
  *             - pointer to source_p
@@ -704,7 +703,7 @@ expire_tgchange(void *unused)
 /*
  * msg_client
  *
- * inputs      - flag 0 if PRIVMSG 1 if NOTICE. RFC 
+ * inputs      - flag 0 if PRIVMSG 1 if NOTICE. RFC
  *               say NOTICE must not auto reply
  *             - pointer to source_p source (struct Client *)
  *             - pointer to target_p target (struct Client *)
@@ -727,12 +726,14 @@ msg_client(enum message_type msgtype,
                 * as a way to taunt users, e.g. harass them and hide behind +g
                 * as a way of griefing.  --nenolod
                 */
-               if(msgtype != MESSAGE_TYPE_NOTICE && IsSetCallerId(source_p) &&
+               if(msgtype != MESSAGE_TYPE_NOTICE &&
+                               (IsSetCallerId(source_p) ||
+                                (IsSetRegOnlyMsg(source_p) && !target_p->user->suser[0])) &&
                                !accept_message(target_p, source_p) &&
                                !IsOper(target_p))
                {
                        if(rb_dlink_list_length(&source_p->localClient->allow_list) <
-                                       ConfigFileEntry.max_accept)
+                                       (unsigned long)ConfigFileEntry.max_accept)
                        {
                                rb_dlinkAddAlloc(target_p, &source_p->localClient->allow_list);
                                rb_dlinkAddAlloc(source_p, &target_p->on_allow_list);
@@ -746,7 +747,7 @@ msg_client(enum message_type msgtype,
                        }
                }
 
-               /* reset idle time for message only if its not to self 
+               /* reset idle time for message only if its not to self
                 * and its not a notice */
                if(msgtype != MESSAGE_TYPE_NOTICE)
                        source_p->localClient->last = rb_current_time();
@@ -878,7 +879,7 @@ msg_client(enum message_type msgtype,
  * flood_attack_client
  * inputs       - flag 0 if PRIVMSG 1 if NOTICE. RFC
  *                say NOTICE must not auto reply
- *              - pointer to source Client 
+ *              - pointer to source Client
  *             - pointer to target Client
  * output      - 1 if target is under flood attack
  * side effects        - check for flood attack on target target_p