#include "client.h"
#include "ircd.h"
#include "numeric.h"
-#include "common.h"
#include "s_conf.h"
#include "s_serv.h"
#include "msg.h"
#include "tgchange.h"
#include "inline/stringops.h"
-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 m_message(enum message_type, struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void m_privmsg(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+static void m_notice(struct MsgBuf *, struct Client *, struct Client *, int, const char **);
+
static void expire_tgchange(void *unused);
static struct ev_entry *expire_tgchange_event;
struct Client *client_p,
struct Client *source_p, const char *nicks_channels, const char *text);
-static int flood_attack_client(enum message_type msgtype, struct Client *source_p, struct Client *target_p);
+static bool flood_attack_client(enum message_type msgtype, struct Client *source_p, struct Client *target_p);
/* Fifteen seconds should be plenty for a client to reply a ctcp */
#define LARGE_CTCP_TIME 15
static struct entity targets[512];
static int ntargets = 0;
-static int duplicate_ptr(void *);
+static bool duplicate_ptr(void *);
static void msg_channel(enum message_type msgtype,
struct Client *client_p,
[MESSAGE_TYPE_NOTICE] = "NOTICE",
};
-static int
+static void
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, msgbuf_p, client_p, source_p, parc, parv);
+ m_message(MESSAGE_TYPE_PRIVMSG, msgbuf_p, client_p, source_p, parc, parv);
}
-static int
+static void
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, msgbuf_p, client_p, source_p, parc, parv);
+ m_message(MESSAGE_TYPE_NOTICE, msgbuf_p, client_p, source_p, parc, parv);
}
/*
* - pointer to source_p
* - pointer to channel
*/
-static int
+static void
m_message(enum message_type msgtype, struct MsgBuf *msgbuf_p,
struct Client *client_p, struct Client *source_p, int parc, const char *parv[])
{
if(msgtype != MESSAGE_TYPE_NOTICE)
sendto_one(source_p, form_str(ERR_NORECIPIENT), me.name,
source_p->name, cmdname[msgtype]);
- return 0;
+ return;
}
if(parc < 3 || EmptyString(parv[2]))
{
if(msgtype != MESSAGE_TYPE_NOTICE)
sendto_one(source_p, form_str(ERR_NOTEXTTOSEND), me.name, source_p->name);
- return 0;
+ return;
}
/* Finish the flood grace period if theyre not messaging themselves
if(build_target_list(msgtype, client_p, source_p, parv[1], parv[2]) < 0)
{
- return 0;
+ return;
}
for(i = 0; i < ntargets; i++)
break;
}
}
-
- return 0;
}
/*
* inputs - pointer to check
* - pointer to table of entities
* - number of valid entities so far
- * output - YES if duplicate pointer in table, NO if not.
+ * output - true if duplicate pointer in table, false if not.
* note, this does the canonize using pointers
* side effects - NONE
*/
-static int
+static bool
duplicate_ptr(void *ptr)
{
int i;
for(i = 0; i < ntargets; i++)
if(targets[i].ptr == ptr)
- return YES;
- return NO;
+ return true;
+ return false;
}
/*
if (do_floodcount &&
flood_attack_client(msgtype, source_p, target_p))
return;
+
+ if (IsCapable(source_p, CLICAP_ECHO_MESSAGE) && target_p != source_p)
+ sendto_anywhere_echo(target_p, source_p, cmdname[msgtype], ":%s", text);
}
else if(source_p->from == target_p->from)
{
/*
* flood_attack_client
* inputs - flag 0 if PRIVMSG 1 if NOTICE. RFC
- * say NOTICE must not auto reply
+ * says NOTICE must not auto reply
* - pointer to source Client
* - pointer to target Client
- * output - 1 if target is under flood attack
+ * output - true if target is under flood attack
* side effects - check for flood attack on target target_p
*/
-static int
+static bool
flood_attack_client(enum message_type msgtype, struct Client *source_p, struct Client *target_p)
{
int delta;
sendto_one(source_p,
":%s NOTICE %s :*** Message to %s throttled due to flooding",
me.name, source_p->name, target_p->name);
- return 1;
+ return true;
}
else
target_p->received_number_of_privmsgs++;
}
- return 0;
+ return false;
}
/*
{
struct Client *target_p;
char *server;
- char *s;
/* user[%host]@server addressed?
* NOTE: users can send to user@server, but not user%host@server
return;
}
- if((s = strrchr(nick, '.')) == NULL)
- {
- sendto_one_numeric(source_p, ERR_NOTOPLEVEL,
- form_str(ERR_NOTOPLEVEL), nick);
- return;
- }
- while(*++s)
- if(*s == '.' || *s == '*' || *s == '?')
- break;
- if(*s == '*' || *s == '?')
- {
- sendto_one_numeric(source_p, ERR_WILDTOPLEVEL,
- form_str(ERR_WILDTOPLEVEL), nick);
- return;
- }
-
sendto_match_butone(IsServer(client_p) ? client_p : NULL, source_p,
nick + 1,
(*nick == '#') ? MATCH_HOST : MATCH_SERVER,