mirror of
https://github.com/anope/anope.git
synced 2026-06-29 23:36:39 +02:00
Changed the protocol handling system to use a vector of strings instead of C style arrays. Burned the old process/split_buf/memory.c code
This commit is contained in:
+1
-1
@@ -309,7 +309,7 @@ namespace Anope
|
||||
* @param func A callback function that will be called when this message is received
|
||||
* @return The new message object
|
||||
*/
|
||||
extern CoreExport Message *AddMessage(const string &name, int (*func)(const string &source, int ac, const char **av));
|
||||
extern CoreExport Message *AddMessage(const string &name, bool (*func)(const string &source, const std::vector<Anope::string> ¶ms));
|
||||
|
||||
/** Deletes a message from Anope
|
||||
* XXX Im not sure what will happen if this function is called indirectly from message function pointed to by this message.. must check
|
||||
|
||||
@@ -248,6 +248,13 @@ class CoreExport Channel : public Extensible, public Flags<ChannelFlags>
|
||||
*/
|
||||
void SetModes(BotInfo *bi, bool EnforceMLock, const char *cmodes, ...);
|
||||
|
||||
/** Set a string of modes internally on a channel
|
||||
* @param setter the setter (if it is a user)
|
||||
* @param mode the modes
|
||||
* @param EnforceMLock true to enforce mlock
|
||||
*/
|
||||
void SetModesInternal(User *setter, const Anope::string &modes, bool EnforceMLock = false);
|
||||
|
||||
/** Kick a user from a channel internally
|
||||
* @param source The sender of the kick
|
||||
* @param nick The nick being kicked
|
||||
|
||||
+9
-18
@@ -61,18 +61,16 @@ E void get_channel_stats(long *nrec, long *memuse);
|
||||
|
||||
E Channel *findchan(const Anope::string &chan);
|
||||
|
||||
E void ChanSetInternalModes(Channel *c, int ac, const char **av, User *setter = NULL); /* this is dieing soon anyway */
|
||||
|
||||
E User *nc_on_chan(Channel *c, const NickCore *nc);
|
||||
|
||||
E int get_access_level(ChannelInfo *ci, NickAlias *na);
|
||||
E int get_access_level(ChannelInfo *ci, NickCore *nc);
|
||||
E Anope::string get_xop_level(int level);
|
||||
|
||||
E void do_cmode(const Anope::string &source, int ac, const char **av);
|
||||
E void do_join(const Anope::string &source, int ac, const char **av);
|
||||
E void do_kick(const Anope::string &source, int ac, const char **av);
|
||||
E void do_part(const Anope::string &source, int ac, const char **av);
|
||||
E void do_cmode(const Anope::string &source, const Anope::string &channel, const Anope::string &modes, const Anope::string &ts);
|
||||
E void do_join(const Anope::string &source, const Anope::string &channels, const Anope::string &ts);
|
||||
E void do_kick(const Anope::string &source, const Anope::string &channel, const Anope::string &users, const Anope::string &reason);
|
||||
E void do_part(const Anope::string &source, const Anope::string &channels, const Anope::string &reason);
|
||||
E void MassChannelModes(BotInfo *bi, const Anope::string &modes);
|
||||
|
||||
E void chan_set_correct_modes(User *user, Channel *c, int give_modes);
|
||||
@@ -201,11 +199,6 @@ class UplinkSocket : public ConnectionSocket
|
||||
bool Read(const Anope::string &buf);
|
||||
};
|
||||
|
||||
/**** memory.c ****/
|
||||
|
||||
E void *scalloc(long elsize, long els);
|
||||
E void *srealloc(void *oldptr, long newsize);
|
||||
|
||||
/**** memoserv.c ****/
|
||||
|
||||
E void ms_init();
|
||||
@@ -222,10 +215,10 @@ E int m_away(const Anope::string &source, const Anope::string &msg);
|
||||
E int m_kill(const Anope::string &nick, const Anope::string &msg);
|
||||
E int m_motd(const Anope::string &source);
|
||||
E int m_privmsg(const Anope::string &source, const Anope::string &receiver, const Anope::string &message);
|
||||
E int m_stats(const Anope::string &source, int ac, const char **av);
|
||||
E bool m_stats(const Anope::string &source, const std::vector<Anope::string> &);
|
||||
E int m_whois(const Anope::string &source, const Anope::string &who);
|
||||
E int m_time(const Anope::string &source, int ac, const char **av);
|
||||
E int m_version(const Anope::string &source, int ac, const char **av);
|
||||
E bool m_time(const Anope::string &source, const std::vector<Anope::string> &);
|
||||
E bool m_version(const Anope::string &source, const std::vector<Anope::string> &);
|
||||
|
||||
/**** misc.c ****/
|
||||
|
||||
@@ -255,7 +248,6 @@ E bool isvalidchar(char c);
|
||||
E Anope::string myStrGetToken(const Anope::string &str, char dilim, int token_number);
|
||||
E Anope::string myStrGetTokenRemainder(const Anope::string &str, char dilim, int token_number);
|
||||
E int myNumToken(const Anope::string &str, char dilim);
|
||||
E void doCleanBuffer(char *str);
|
||||
E void EnforceQlinedNick(const Anope::string &nick, const Anope::string &killer);
|
||||
E bool nickIsServices(const Anope::string &nick, bool bot);
|
||||
|
||||
@@ -313,7 +305,6 @@ E IgnoreData *get_ignore(const Anope::string &nick);
|
||||
E int delete_ignore(const Anope::string &nick);
|
||||
E int clear_ignores();
|
||||
|
||||
E int split_buf(char *buf, const char ***argv, int colon_special);
|
||||
E void process(const Anope::string &buf);
|
||||
|
||||
/**** send.c ****/
|
||||
@@ -361,8 +352,8 @@ E Anope::string TS6SID;
|
||||
|
||||
E User *do_nick(const Anope::string &source, const Anope::string &nick, const Anope::string &username, const Anope::string &host, const Anope::string &server, const Anope::string &realname, time_t ts, const Anope::string &ip, const Anope::string &vhost, const Anope::string &uid, const Anope::string &modes);
|
||||
|
||||
E void do_umode(const Anope::string &source, int ac, const char **av);
|
||||
E void do_quit(const Anope::string &source, int ac, const char **av);
|
||||
E void do_umode(const Anope::string &, const Anope::string &user, const Anope::string &modes);
|
||||
E void do_quit(const Anope::string &source, const Anope::string &reason);
|
||||
E void do_kill(const Anope::string &source, const Anope::string &reason);
|
||||
|
||||
E bool is_oper(User *user);
|
||||
|
||||
+1
-2
@@ -159,7 +159,6 @@ enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFOR
|
||||
/* Module types, in the order in which they are unloaded. The order these are in is IMPORTANT */
|
||||
enum MODType { MT_BEGIN, THIRD, QATESTED, SUPPORTED, CORE, DATABASE, ENCRYPTION, PROTOCOL, SOCKETENGINE, MT_END };
|
||||
|
||||
struct Message;
|
||||
typedef std::multimap<Anope::string, Message *> message_map;
|
||||
extern CoreExport message_map MessageMap;
|
||||
class Module;
|
||||
@@ -1269,7 +1268,7 @@ class service_reference : public dynamic_reference<T>
|
||||
struct Message
|
||||
{
|
||||
Anope::string name;
|
||||
int (*func)(const Anope::string &source, int ac, const char **av);
|
||||
bool (*func)(const Anope::string &source, const std::vector<Anope::string> ¶ms);
|
||||
};
|
||||
|
||||
#endif // MODULES_H
|
||||
|
||||
+2
-2
@@ -4,10 +4,10 @@
|
||||
/* Anope */
|
||||
extern CoreExport Server *Me;
|
||||
|
||||
extern CoreExport void CapabParse(int ac, const char **av);
|
||||
extern CoreExport void CapabParse(const std::vector<Anope::string> ¶ms);
|
||||
|
||||
extern CoreExport void do_server(const Anope::string &source, const Anope::string &servername, unsigned int hops, const Anope::string &descript, const Anope::string &numeric);
|
||||
extern CoreExport void do_squit(const Anope::string &source, int ac, const char **av);
|
||||
extern CoreExport void do_squit(const Anope::string &source, const Anope::string &server);
|
||||
|
||||
extern CoreExport const char *ts6_uid_retrieve();
|
||||
extern CoreExport const char *ts6_sid_retrieve();
|
||||
|
||||
+142
-152
@@ -293,15 +293,15 @@ class BahamutIRCdProto : public IRCDProto
|
||||
} ircd_proto;
|
||||
|
||||
/* EVENT: SJOIN */
|
||||
int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
|
||||
bool event_sjoin(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Channel *c = findchan(av[1]);
|
||||
time_t ts = Anope::string(av[0]).is_pos_number_only() ? convertTo<time_t>(av[0]) : 0;
|
||||
Channel *c = findchan(params[1]);
|
||||
time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0;
|
||||
bool keep_their_modes = false;
|
||||
|
||||
if (!c)
|
||||
{
|
||||
c = new Channel(av[1], ts);
|
||||
c = new Channel(params[1], ts);
|
||||
c->SetFlag(CH_SYNCING);
|
||||
}
|
||||
/* Our creation time is newer than what the server gave us */
|
||||
@@ -318,16 +318,21 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
|
||||
keep_their_modes = false;
|
||||
|
||||
/* If we need to keep their modes, and this SJOIN string contains modes */
|
||||
if (keep_their_modes && ac >= 4)
|
||||
if (keep_their_modes && params.size() >= 4)
|
||||
{
|
||||
/* Set the modes internally */
|
||||
ChanSetInternalModes(c, ac - 3, av + 2);
|
||||
Anope::string modes;
|
||||
for (unsigned i = 2; i < params.size(); ++i)
|
||||
modes += " " + params[i];
|
||||
if (!modes.empty())
|
||||
modes.erase(modes.begin());
|
||||
c->SetModesInternal(NULL, modes);
|
||||
}
|
||||
|
||||
/* For a reason unknown to me, bahamut will send a SJOIN from the user joining a channel
|
||||
* if the channel already existed
|
||||
*/
|
||||
if (!c->HasFlag(CH_SYNCING) && ac == 2)
|
||||
if (!c->HasFlag(CH_SYNCING) && params.size() == 2)
|
||||
{
|
||||
User *u = finduser(source);
|
||||
if (!u)
|
||||
@@ -355,7 +360,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
|
||||
}
|
||||
else
|
||||
{
|
||||
spacesepstream sep(av[ac - 1]);
|
||||
spacesepstream sep(params[params.size() - 1]);
|
||||
Anope::string buf;
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
@@ -418,7 +423,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
|
||||
c->Sync();
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -439,17 +444,17 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
|
||||
** parv[0] = new nickname
|
||||
** parv[1] = hopcount
|
||||
*/
|
||||
int anope_event_nick(const Anope::string &source, int ac, const char **av)
|
||||
bool event_nick(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *user;
|
||||
|
||||
if (ac != 2)
|
||||
if (params.size() != 2)
|
||||
{
|
||||
user = do_nick(source, av[0], av[4], av[5], av[6], av[9], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, av[8], "", "", av[3]);
|
||||
user = do_nick(source, params[0], params[4], params[5], params[6], params[9], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[8], "", "", params[3]);
|
||||
if (user)
|
||||
{
|
||||
NickAlias *na;
|
||||
if (user->timestamp == convertTo<time_t>(av[7]) && (na = findnick(user->nick)))
|
||||
if (user->timestamp == convertTo<time_t>(params[7]) && (na = findnick(user->nick)))
|
||||
{
|
||||
user->Login(na->nc);
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
@@ -459,214 +464,199 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
|
||||
}
|
||||
}
|
||||
else
|
||||
do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0, "", "", "", "");
|
||||
return MOD_CONT;
|
||||
do_nick(source, params[0], "", "", "", "", Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0, "", "", "", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT : CAPAB */
|
||||
int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
bool event_capab(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
CapabParse(ac, av);
|
||||
return MOD_CONT;
|
||||
CapabParse(params);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT : OS */
|
||||
int anope_event_os(const Anope::string &source, int ac, const char **av)
|
||||
bool event_os(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
m_privmsg(source, Config->s_OperServ, av[0]);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
m_privmsg(source, Config->s_OperServ, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT : NS */
|
||||
int anope_event_ns(const Anope::string &source, int ac, const char **av)
|
||||
bool event_ns(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
m_privmsg(source, Config->s_NickServ, av[0]);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
m_privmsg(source, Config->s_NickServ, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT : MS */
|
||||
int anope_event_ms(const Anope::string &source, int ac, const char **av)
|
||||
bool event_ms(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
m_privmsg(source, Config->s_MemoServ, av[0]);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
m_privmsg(source, Config->s_MemoServ, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT : HS */
|
||||
int anope_event_hs(const Anope::string &source, int ac, const char **av)
|
||||
bool event_hs(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
m_privmsg(source, Config->s_HostServ, av[0]);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
m_privmsg(source, Config->s_HostServ, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT : CS */
|
||||
int anope_event_cs(const Anope::string &source, int ac, const char **av)
|
||||
bool event_cs(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
m_privmsg(source, Config->s_ChanServ, av[0]);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
m_privmsg(source, Config->s_ChanServ, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_436(const Anope::string &source, int ac, const char **av)
|
||||
bool event_436(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
|
||||
m_nickcoll(av[0]);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
m_nickcoll(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT : SERVER */
|
||||
int anope_event_server(const Anope::string &source, int ac, const char **av)
|
||||
bool event_server(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_server(source, av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo<unsigned>(av[1]) : 0, av[2], "");
|
||||
return MOD_CONT;
|
||||
do_server(source, params[0], Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, params[2], "");
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT : PRIVMSG */
|
||||
int anope_event_privmsg(const Anope::string &source, int ac, const char **av)
|
||||
bool event_privmsg(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
m_privmsg(source, av[0], av[1]);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 1)
|
||||
m_privmsg(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_part(const Anope::string &source, int ac, const char **av)
|
||||
bool event_part(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1 || ac > 2)
|
||||
return MOD_CONT;
|
||||
do_part(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
do_part(source, params[0], params.size() > 1 ? params[1] : "");
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_whois(const Anope::string &source, int ac, const char **av)
|
||||
bool event_whois(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!source.empty() && ac >= 1)
|
||||
m_whois(source, av[0]);
|
||||
return MOD_CONT;
|
||||
if (!source.empty() && params.size() > 0)
|
||||
m_whois(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_topic(const Anope::string &source, int ac, const char **av)
|
||||
bool event_topic(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 4)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 4)
|
||||
return true;
|
||||
|
||||
Channel *c = findchan(av[0]);
|
||||
Channel *c = findchan(params[0]);
|
||||
if (!c)
|
||||
{
|
||||
Log() << "TOPIC for nonexistant channel " << av[0];
|
||||
return MOD_CONT;
|
||||
Log() << "TOPIC for nonexistant channel " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
c->ChangeTopicInternal(av[1], av[3], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : Anope::CurTime);
|
||||
c->ChangeTopicInternal(params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_squit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_squit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
do_squit(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 0)
|
||||
do_squit(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_quit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_quit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
do_quit(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 0)
|
||||
do_quit(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT: MODE */
|
||||
int anope_event_mode(const Anope::string &source, int ac, const char **av)
|
||||
bool event_mode(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 2)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 3)
|
||||
return true;
|
||||
|
||||
if (*av[0] == '#' || *av[0] == '&')
|
||||
do_cmode(source, ac, av);
|
||||
if (params[0][0] == '#' || params[0][0] == '&')
|
||||
do_cmode(source, params[0], params[2], params[1]);
|
||||
else
|
||||
do_umode(source, ac, av);
|
||||
return MOD_CONT;
|
||||
do_umode(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT: KILL */
|
||||
int anope_event_kill(const Anope::string &source, int ac, const char **av)
|
||||
bool event_kill(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
|
||||
m_kill(av[0], av[1]);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 1)
|
||||
m_kill(params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT: KICK */
|
||||
int anope_event_kick(const Anope::string &source, int ac, const char **av)
|
||||
bool event_kick(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 3)
|
||||
return MOD_CONT;
|
||||
do_kick(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 2)
|
||||
do_kick(source, params[0], params[1], params[2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT: JOIN */
|
||||
int anope_event_join(const Anope::string &source, int ac, const char **av)
|
||||
bool event_join(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
do_join(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (params.size() >= 2)
|
||||
do_join(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT: MOTD */
|
||||
int anope_event_motd(const Anope::string &source, int ac, const char **av)
|
||||
bool event_motd(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (source.empty())
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
|
||||
m_motd(source);
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_away(const Anope::string &source, int ac, const char **av)
|
||||
bool event_away(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (source.empty())
|
||||
return MOD_CONT;
|
||||
m_away(source, ac ? av[0] : "");
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
m_away(source, !params.empty() ? params[0] : "");
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_ping(const Anope::string &source, int ac, const char **av)
|
||||
bool event_ping(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
ircdproto->SendPong(ac > 1 ? av[1] : Config->ServerName, av[0]);
|
||||
return MOD_CONT;
|
||||
if (params.size() < 1)
|
||||
return true;
|
||||
ircdproto->SendPong(params.size() > 1 ? params[1] : Config->ServerName, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_error(const Anope::string &source, int ac, const char **av)
|
||||
bool event_error(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac >= 1)
|
||||
Log(LOG_DEBUG) << av[0];
|
||||
return MOD_CONT;
|
||||
if (params.size() > 0)
|
||||
Log(LOG_DEBUG) << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_burst(const Anope::string &source, int ac, const char **av)
|
||||
bool event_burst(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Server *s = Server::Find(source);
|
||||
|
||||
if (!ac)
|
||||
if (params.empty())
|
||||
{
|
||||
/* for future use - start burst */
|
||||
}
|
||||
@@ -681,7 +671,7 @@ int anope_event_burst(const Anope::string &source, int ac, const char **av)
|
||||
if (s)
|
||||
s->Sync(true);
|
||||
}
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChannelModeFlood::IsValid(const Anope::string &value) const
|
||||
@@ -695,32 +685,32 @@ bool ChannelModeFlood::IsValid(const Anope::string &value) const
|
||||
|
||||
void moduleAddIRCDMsgs()
|
||||
{
|
||||
Anope::AddMessage("436", anope_event_436);
|
||||
Anope::AddMessage("AWAY", anope_event_away);
|
||||
Anope::AddMessage("JOIN", anope_event_join);
|
||||
Anope::AddMessage("KICK", anope_event_kick);
|
||||
Anope::AddMessage("KILL", anope_event_kill);
|
||||
Anope::AddMessage("MODE", anope_event_mode);
|
||||
Anope::AddMessage("MOTD", anope_event_motd);
|
||||
Anope::AddMessage("NICK", anope_event_nick);
|
||||
Anope::AddMessage("PART", anope_event_part);
|
||||
Anope::AddMessage("PING", anope_event_ping);
|
||||
Anope::AddMessage("PRIVMSG", anope_event_privmsg);
|
||||
Anope::AddMessage("QUIT", anope_event_quit);
|
||||
Anope::AddMessage("SERVER", anope_event_server);
|
||||
Anope::AddMessage("SQUIT", anope_event_squit);
|
||||
Anope::AddMessage("TOPIC", anope_event_topic);
|
||||
Anope::AddMessage("WHOIS", anope_event_whois);
|
||||
Anope::AddMessage("SVSMODE", anope_event_mode);
|
||||
Anope::AddMessage("CAPAB", anope_event_capab);
|
||||
Anope::AddMessage("CS", anope_event_cs);
|
||||
Anope::AddMessage("HS", anope_event_hs);
|
||||
Anope::AddMessage("MS", anope_event_ms);
|
||||
Anope::AddMessage("NS", anope_event_ns);
|
||||
Anope::AddMessage("OS", anope_event_os);
|
||||
Anope::AddMessage("SJOIN", anope_event_sjoin);
|
||||
Anope::AddMessage("ERROR", anope_event_error);
|
||||
Anope::AddMessage("BURST", anope_event_burst);
|
||||
Anope::AddMessage("436", event_436);
|
||||
Anope::AddMessage("AWAY", event_away);
|
||||
Anope::AddMessage("JOIN", event_join);
|
||||
Anope::AddMessage("KICK", event_kick);
|
||||
Anope::AddMessage("KILL", event_kill);
|
||||
Anope::AddMessage("MODE", event_mode);
|
||||
Anope::AddMessage("MOTD", event_motd);
|
||||
Anope::AddMessage("NICK", event_nick);
|
||||
Anope::AddMessage("PART", event_part);
|
||||
Anope::AddMessage("PING", event_ping);
|
||||
Anope::AddMessage("PRIVMSG", event_privmsg);
|
||||
Anope::AddMessage("QUIT", event_quit);
|
||||
Anope::AddMessage("SERVER", event_server);
|
||||
Anope::AddMessage("SQUIT", event_squit);
|
||||
Anope::AddMessage("TOPIC", event_topic);
|
||||
Anope::AddMessage("WHOIS", event_whois);
|
||||
Anope::AddMessage("SVSMODE", event_mode);
|
||||
Anope::AddMessage("CAPAB", event_capab);
|
||||
Anope::AddMessage("CS", event_cs);
|
||||
Anope::AddMessage("HS", event_hs);
|
||||
Anope::AddMessage("MS", event_ms);
|
||||
Anope::AddMessage("NS", event_ns);
|
||||
Anope::AddMessage("OS", event_os);
|
||||
Anope::AddMessage("SJOIN", event_sjoin);
|
||||
Anope::AddMessage("ERROR", event_error);
|
||||
Anope::AddMessage("BURST", event_burst);
|
||||
}
|
||||
|
||||
static void AddModes()
|
||||
|
||||
+220
-256
@@ -66,11 +66,11 @@ void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost)
|
||||
ircdproto->SendGlobops(OperServ, "CHGHOST not loaded!");
|
||||
}
|
||||
|
||||
int anope_event_idle(const Anope::string &source, int ac, const char **av)
|
||||
bool event_idle(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac == 1)
|
||||
send_cmd(av[0], "IDLE %s %ld 0", source.c_str(), static_cast<long>(Anope::CurTime));
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
send_cmd(params[0], "IDLE %s %ld 0", source.c_str(), static_cast<long>(Anope::CurTime));
|
||||
return true;
|
||||
}
|
||||
|
||||
static Anope::string currentpass;
|
||||
@@ -296,112 +296,105 @@ class InspIRCdProto : public IRCDProto
|
||||
|
||||
} ircd_proto;
|
||||
|
||||
int anope_event_ftopic(const Anope::string &source, int ac, const char **av)
|
||||
bool event_ftopic(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
/* :source FTOPIC channel ts setby :topic */
|
||||
if (ac < 4)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 4)
|
||||
return true;
|
||||
|
||||
Channel *c = findchan(av[0]);
|
||||
Channel *c = findchan(params[0]);
|
||||
if (!c)
|
||||
{
|
||||
Log() << "TOPIC for nonexistant channel " << av[0];
|
||||
return MOD_CONT;
|
||||
Log() << "TOPIC for nonexistant channel " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
c->ChangeTopicInternal(av[2], av[3], Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : Anope::CurTime);
|
||||
c->ChangeTopicInternal(params[2], params[3], Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_mode(const Anope::string &source, int ac, const char **av)
|
||||
bool event_mode(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 2)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 2)
|
||||
return true;
|
||||
|
||||
if (*av[0] == '#' || *av[0] == '&')
|
||||
do_cmode(source, ac, av);
|
||||
if (params[0][0] == '#' || params[0][0] == '&')
|
||||
do_cmode(source, params[0], params[1], params[2]);
|
||||
else
|
||||
{
|
||||
/* InspIRCd lets opers change another
|
||||
users modes, we have to kludge this
|
||||
as it slightly breaks RFC1459
|
||||
users modes
|
||||
*/
|
||||
if (source.equals_ci(av[0]))
|
||||
do_umode(source, ac, av);
|
||||
else
|
||||
do_umode(av[0], ac, av);
|
||||
do_umode(source, params[0], params[1]);
|
||||
}
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_opertype(const Anope::string &source, int ac, const char **av)
|
||||
bool event_opertype(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
/* opertype is equivalent to mode +o because servers
|
||||
dont do this directly */
|
||||
User *u;
|
||||
u = finduser(source);
|
||||
User *u = finduser(source);
|
||||
if (u && !is_oper(u))
|
||||
{
|
||||
const char *newav[2];
|
||||
newav[0] = source.c_str();
|
||||
newav[1] = "+o";
|
||||
return anope_event_mode(source, 2, newav);
|
||||
std::vector<Anope::string> newparams;
|
||||
newparams.push_back(source);
|
||||
newparams.push_back("+o");
|
||||
return event_mode(source, newparams);
|
||||
}
|
||||
else
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_fmode(const Anope::string &source, int ac, const char **av)
|
||||
bool event_fmode(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
const char *newav[128];
|
||||
int n, o;
|
||||
Channel *c;
|
||||
|
||||
/* :source FMODE #test 12345678 +nto foo */
|
||||
if (ac < 3)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 3)
|
||||
return true;
|
||||
|
||||
Channel *c = findchan(params[0]);
|
||||
/* Checking the TS for validity to avoid desyncs */
|
||||
if ((c = findchan(av[0])))
|
||||
if (c)
|
||||
{
|
||||
time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0;
|
||||
time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0;
|
||||
if (c->creation_time > ts)
|
||||
{
|
||||
/* Our TS is bigger, we should lower it */
|
||||
c->creation_time = ts;
|
||||
c->Reset();
|
||||
}
|
||||
else if (c->creation_time < ts)
|
||||
/* The TS we got is bigger, we should ignore this message. */
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
/* Got FMODE for a non-existing channel */
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
|
||||
/* TS's are equal now, so we can proceed with parsing */
|
||||
n = o = 0;
|
||||
while (n < ac)
|
||||
std::vector<Anope::string> newparams;
|
||||
for (unsigned n = 0; n < params.size(); ++n)
|
||||
{
|
||||
if (n != 1)
|
||||
{
|
||||
newav[o] = av[n];
|
||||
++o;
|
||||
Log(LOG_DEBUG) << "Param: " << newav[o - 1];
|
||||
newparams.push_back(params[n]);
|
||||
Log(LOG_DEBUG) << "Param: " << params[n];
|
||||
}
|
||||
++n;
|
||||
}
|
||||
|
||||
return anope_event_mode(source, ac - 1, newav);
|
||||
return event_mode(source, newparams);
|
||||
}
|
||||
|
||||
int anope_event_fjoin(const Anope::string &source, int ac, const char **av)
|
||||
bool event_fjoin(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Channel *c = findchan(av[0]);
|
||||
time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0;
|
||||
Channel *c = findchan(params[0]);
|
||||
time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0;
|
||||
bool keep_their_modes = true;
|
||||
|
||||
if (!c)
|
||||
{
|
||||
c = new Channel(av[0], ts);
|
||||
c = new Channel(params[0], ts);
|
||||
c->SetFlag(CH_SYNCING);
|
||||
}
|
||||
/* Our creation time is newer than what the server gave us */
|
||||
@@ -417,7 +410,7 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av)
|
||||
else if (ts > c->creation_time)
|
||||
keep_their_modes = false;
|
||||
|
||||
spacesepstream sep(av[ac - 1]);
|
||||
spacesepstream sep(params[params.size() - 1]);
|
||||
Anope::string buf;
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
@@ -481,291 +474,262 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av)
|
||||
c->Sync();
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Events */
|
||||
int anope_event_ping(const Anope::string &source, int ac, const char **av)
|
||||
bool event_ping(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
ircdproto->SendPong(Config->ServerName, av[0]);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
ircdproto->SendPong(Config->ServerName, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_436(const Anope::string &source, int ac, const char **av)
|
||||
bool event_436(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
|
||||
m_nickcoll(av[0]);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
m_nickcoll(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_away(const Anope::string &source, int ac, const char **av)
|
||||
bool event_away(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (source.empty())
|
||||
return MOD_CONT;
|
||||
m_away(source, ac ? av[0] : "");
|
||||
return MOD_CONT;
|
||||
if (!source.empty())
|
||||
m_away(source, !params.empty() ? params[0] : "");
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Taken from hybrid.c, topic syntax is identical */
|
||||
|
||||
int anope_event_topic(const Anope::string &source, int ac, const char **av)
|
||||
bool event_topic(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Channel *c = findchan(av[0]);
|
||||
Channel *c = findchan(params[0]);
|
||||
|
||||
if (!c)
|
||||
{
|
||||
Log() << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
|
||||
return MOD_CONT;
|
||||
Log() << "TOPIC " << (params.size() > 1 ? params[1] : "") << " for nonexistent channel " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
c->ChangeTopicInternal(source, (ac > 1 && *av[1] ? av[1] : ""), Anope::CurTime);
|
||||
c->ChangeTopicInternal(source, (params.size() > 1 ? params[1] : ""), Anope::CurTime);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_squit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_squit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
do_squit(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
do_squit(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_rsquit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_rsquit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1 || ac > 3)
|
||||
return MOD_CONT;
|
||||
if (params.empty() || params.size() > 3)
|
||||
return true;
|
||||
|
||||
/* Horrible workaround to an insp bug (#) in how RSQUITs are sent - mark */
|
||||
if (ac > 1 && Config->ServerName.equals_cs(av[0]))
|
||||
do_squit(source, ac - 1, av + 1);
|
||||
if (params.size() > 1 && Config->ServerName.equals_cs(params[0]))
|
||||
do_squit(source, params[1]);
|
||||
else
|
||||
do_squit(source, ac, av);
|
||||
do_squit(source, params[0]);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_quit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_quit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
do_quit(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
do_quit(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_kill(const Anope::string &source, int ac, const char **av)
|
||||
bool event_kill(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
|
||||
m_kill(av[0], av[1]);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 1)
|
||||
m_kill(params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_kick(const Anope::string &source, int ac, const char **av)
|
||||
bool event_kick(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 3)
|
||||
return MOD_CONT;
|
||||
do_kick(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 2)
|
||||
do_kick(source, params[0], params[1], params[2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_join(const Anope::string &source, int ac, const char **av)
|
||||
bool event_join(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
do_join(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 1)
|
||||
do_join(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_motd(const Anope::string &source, int ac, const char **av)
|
||||
bool event_motd(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (source.empty())
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
|
||||
m_motd(source);
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_setname(const Anope::string &source, int ac, const char **av)
|
||||
bool event_setname(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (params.empty())
|
||||
return true;
|
||||
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(source);
|
||||
User *u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "SETNAME for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetRealname(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetRealname(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_chgname(const Anope::string &source, int ac, const char **av)
|
||||
bool event_chgname(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (params.size() < 2)
|
||||
return true;
|
||||
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(source);
|
||||
User *u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "FNAME for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetRealname(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetRealname(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_setident(const Anope::string &source, int ac, const char **av)
|
||||
bool event_setident(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (!params.empty())
|
||||
return true;
|
||||
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(source);
|
||||
User *u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "SETIDENT for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetIdent(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetIdent(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_chgident(const Anope::string &source, int ac, const char **av)
|
||||
bool event_chgident(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (params.size() < 2)
|
||||
return true;
|
||||
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(av[0]);
|
||||
User *u = finduser(params[0]);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "CHGIDENT for nonexistent user " << av[0];
|
||||
return MOD_CONT;
|
||||
Log(LOG_DEBUG) << "CHGIDENT for nonexistent user " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetIdent(av[1]);
|
||||
return MOD_CONT;
|
||||
u->SetIdent(params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_sethost(const Anope::string &source, int ac, const char **av)
|
||||
bool event_sethost(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (params.empty())
|
||||
return true;
|
||||
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(source);
|
||||
User *u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "SETHOST for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetDisplayedHost(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetDisplayedHost(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int anope_event_nick(const Anope::string &source, int ac, const char **av)
|
||||
bool event_nick(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *user;
|
||||
|
||||
if (ac != 1)
|
||||
if (params.size() == 8)
|
||||
{
|
||||
if (ac == 8)
|
||||
time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0;
|
||||
|
||||
User *user = do_nick("", params[1], params[4], params[2], source, params[7], ts, params[6], params[3], "", params[5]);
|
||||
if (user)
|
||||
{
|
||||
time_t ts = Anope::string(av[0]).is_pos_number_only() ? convertTo<time_t>(av[0]) : 0;
|
||||
user->SetCloakedHost(params[3]);
|
||||
|
||||
user = do_nick("", av[1], av[4], av[2], source, av[7], ts, av[6], av[3], "", av[5]);
|
||||
if (user)
|
||||
NickAlias *na = findnick(user->nick);
|
||||
Anope::string svidbuf;
|
||||
if (na && na->nc->GetExtRegular("authenticationtoken", svidbuf) && svidbuf == params[0])
|
||||
{
|
||||
user->SetCloakedHost(av[3]);
|
||||
|
||||
NickAlias *na = findnick(user->nick);
|
||||
Anope::string svidbuf;
|
||||
if (na && na->nc->GetExtRegular("authenticationtoken", svidbuf) && svidbuf == av[0])
|
||||
{
|
||||
user->Login(na->nc);
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
else
|
||||
validate_user(user);
|
||||
user->Login(na->nc);
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
else
|
||||
validate_user(user);
|
||||
}
|
||||
}
|
||||
else
|
||||
do_nick(source, av[0], "", "", "", "", 0, "", "", "", "");
|
||||
return MOD_CONT;
|
||||
else if (params.size() == 1)
|
||||
do_nick(source, params[0], "", "", "", "", 0, "", "", "", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
int anope_event_chghost(const Anope::string &source, int ac, const char **av)
|
||||
bool event_chghost(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (params.empty())
|
||||
return true;
|
||||
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(source);
|
||||
User *u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "FHOST for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetDisplayedHost(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetDisplayedHost(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT: SERVER */
|
||||
int anope_event_server(const Anope::string &source, int ac, const char **av)
|
||||
bool event_server(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_server(source, av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo<unsigned>(av[1]) : 0, av[2], "");
|
||||
return MOD_CONT;
|
||||
do_server(source, params[0], Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, params[2], "");
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_privmsg(const Anope::string &source, int ac, const char **av)
|
||||
bool event_privmsg(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
m_privmsg(source, av[0], av[1]);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 1)
|
||||
m_privmsg(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_part(const Anope::string &source, int ac, const char **av)
|
||||
bool event_part(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1 || ac > 2)
|
||||
return MOD_CONT;
|
||||
do_part(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
do_part(source, params[0], params.size() > 1 ? params[1] : "");
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_whois(const Anope::string &source, int ac, const char **av)
|
||||
bool event_whois(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!source.empty() && ac >= 1)
|
||||
m_whois(source, av[0]);
|
||||
return MOD_CONT;
|
||||
if (!source.empty() && !params.empty())
|
||||
m_whois(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
bool event_capab(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!strcasecmp(av[0], "START"))
|
||||
if (params[0].equals_cs("START"))
|
||||
{
|
||||
/* reset CAPAB */
|
||||
has_servicesmod = false;
|
||||
@@ -775,24 +739,24 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
has_chgidentmod = false;
|
||||
has_hidechansmod = false;
|
||||
}
|
||||
else if (!strcasecmp(av[0], "MODULES"))
|
||||
else if (params[0].equals_cs("MODULES"))
|
||||
{
|
||||
if (strstr(av[1], "m_globops.so"))
|
||||
if (params[1].find("m_globops.so") != Anope::string::npos)
|
||||
has_globopsmod = true;
|
||||
if (strstr(av[1], "m_services.so"))
|
||||
if (params[1].find("m_services.so") != Anope::string::npos)
|
||||
has_servicesmod = true;
|
||||
if (strstr(av[1], "m_svshold.so"))
|
||||
if (params[1].find("m_svshold.so") != Anope::string::npos)
|
||||
has_svsholdmod = true;
|
||||
if (strstr(av[1], "m_chghost.so"))
|
||||
if (params[1].find("m_chghost.so") != Anope::string::npos)
|
||||
has_chghostmod = true;
|
||||
if (strstr(av[1], "m_chgident.so"))
|
||||
if (params[1].find("m_chgident.so") != Anope::string::npos)
|
||||
has_chgidentmod = true;
|
||||
if (strstr(av[1], "m_hidechans.so"))
|
||||
if (params[1].find("m_hidechans.so") != Anope::string::npos)
|
||||
has_hidechansmod = true;
|
||||
}
|
||||
else if (!strcasecmp(av[0], "CAPABILITIES"))
|
||||
else if (params[0].equals_cs("CAPABILITIES"))
|
||||
{
|
||||
spacesepstream ssep(av[1]);
|
||||
spacesepstream ssep(params[1]);
|
||||
Anope::string capab;
|
||||
while (ssep.GetToken(capab))
|
||||
{
|
||||
@@ -950,14 +914,14 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (capab.find("MAXMODES=") != std::string::npos)
|
||||
else if (capab.find("MAXMODES=") != Anope::string::npos)
|
||||
{
|
||||
Anope::string maxmodes(capab.begin() + 9, capab.end());
|
||||
ircd->maxmodes = maxmodes.is_pos_number_only() ? convertTo<unsigned>(maxmodes) : 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcasecmp(av[0], "END"))
|
||||
else if (params[0].equals_cs("END"))
|
||||
{
|
||||
if (!has_globopsmod)
|
||||
{
|
||||
@@ -989,49 +953,49 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
ircd->svshold = has_svsholdmod;
|
||||
}
|
||||
|
||||
CapabParse(ac, av);
|
||||
return MOD_CONT;
|
||||
CapabParse(params);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_endburst(const Anope::string &source, int ac, const char **av)
|
||||
bool event_endburst(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Me->GetLinks().front()->Sync(true);
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
void moduleAddIRCDMsgs()
|
||||
{
|
||||
Anope::AddMessage("ENDBURST", anope_event_endburst);
|
||||
Anope::AddMessage("436", anope_event_436);
|
||||
Anope::AddMessage("AWAY", anope_event_away);
|
||||
Anope::AddMessage("JOIN", anope_event_join);
|
||||
Anope::AddMessage("KICK", anope_event_kick);
|
||||
Anope::AddMessage("KILL", anope_event_kill);
|
||||
Anope::AddMessage("MODE", anope_event_mode);
|
||||
Anope::AddMessage("MOTD", anope_event_motd);
|
||||
Anope::AddMessage("NICK", anope_event_nick);
|
||||
Anope::AddMessage("CAPAB", anope_event_capab);
|
||||
Anope::AddMessage("PART", anope_event_part);
|
||||
Anope::AddMessage("PING", anope_event_ping);
|
||||
Anope::AddMessage("PRIVMSG", anope_event_privmsg);
|
||||
Anope::AddMessage("QUIT", anope_event_quit);
|
||||
Anope::AddMessage("SERVER", anope_event_server);
|
||||
Anope::AddMessage("SQUIT", anope_event_squit);
|
||||
Anope::AddMessage("RSQUIT", anope_event_rsquit);
|
||||
Anope::AddMessage("TOPIC", anope_event_topic);
|
||||
Anope::AddMessage("WHOIS", anope_event_whois);
|
||||
Anope::AddMessage("SVSMODE", anope_event_mode);
|
||||
Anope::AddMessage("FHOST", anope_event_chghost);
|
||||
Anope::AddMessage("CHGIDENT", anope_event_chgident);
|
||||
Anope::AddMessage("FNAME", anope_event_chgname);
|
||||
Anope::AddMessage("SETHOST", anope_event_sethost);
|
||||
Anope::AddMessage("SETIDENT", anope_event_setident);
|
||||
Anope::AddMessage("SETNAME", anope_event_setname);
|
||||
Anope::AddMessage("FJOIN", anope_event_fjoin);
|
||||
Anope::AddMessage("FMODE", anope_event_fmode);
|
||||
Anope::AddMessage("FTOPIC", anope_event_ftopic);
|
||||
Anope::AddMessage("OPERTYPE", anope_event_opertype);
|
||||
Anope::AddMessage("IDLE", anope_event_idle);
|
||||
Anope::AddMessage("ENDBURST", event_endburst);
|
||||
Anope::AddMessage("436", event_436);
|
||||
Anope::AddMessage("AWAY", event_away);
|
||||
Anope::AddMessage("JOIN", event_join);
|
||||
Anope::AddMessage("KICK", event_kick);
|
||||
Anope::AddMessage("KILL", event_kill);
|
||||
Anope::AddMessage("MODE", event_mode);
|
||||
Anope::AddMessage("MOTD", event_motd);
|
||||
Anope::AddMessage("NICK", event_nick);
|
||||
Anope::AddMessage("CAPAB", event_capab);
|
||||
Anope::AddMessage("PART", event_part);
|
||||
Anope::AddMessage("PING", event_ping);
|
||||
Anope::AddMessage("PRIVMSG", event_privmsg);
|
||||
Anope::AddMessage("QUIT", event_quit);
|
||||
Anope::AddMessage("SERVER", event_server);
|
||||
Anope::AddMessage("SQUIT", event_squit);
|
||||
Anope::AddMessage("RSQUIT", event_rsquit);
|
||||
Anope::AddMessage("TOPIC", event_topic);
|
||||
Anope::AddMessage("WHOIS", event_whois);
|
||||
Anope::AddMessage("SVSMODE", event_mode);
|
||||
Anope::AddMessage("FHOST", event_chghost);
|
||||
Anope::AddMessage("CHGIDENT", event_chgident);
|
||||
Anope::AddMessage("FNAME", event_chgname);
|
||||
Anope::AddMessage("SETHOST", event_sethost);
|
||||
Anope::AddMessage("SETIDENT", event_setident);
|
||||
Anope::AddMessage("SETNAME", event_setname);
|
||||
Anope::AddMessage("FJOIN", event_fjoin);
|
||||
Anope::AddMessage("FMODE", event_fmode);
|
||||
Anope::AddMessage("FTOPIC", event_ftopic);
|
||||
Anope::AddMessage("OPERTYPE", event_opertype);
|
||||
Anope::AddMessage("IDLE", event_idle);
|
||||
}
|
||||
|
||||
bool ChannelModeFlood::IsValid(const Anope::string &value) const
|
||||
|
||||
+218
-222
@@ -68,12 +68,12 @@ void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost)
|
||||
send_cmd(HostServ ? HostServ->GetUID() : TS6SID, "CHGHOST %s %s", nick.c_str(), vhost.c_str());
|
||||
}
|
||||
|
||||
int anope_event_idle(const Anope::string &source, int ac, const char **av)
|
||||
bool event_idle(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
BotInfo *bi = findbot(av[0]);
|
||||
BotInfo *bi = findbot(params[0]);
|
||||
|
||||
send_cmd(bi ? bi->GetUID() : av[0], "IDLE %s %ld %ld", source.c_str(), static_cast<long>(start_time), bi ? (static_cast<long>(Anope::CurTime - bi->lastmsg)) : 0);
|
||||
return MOD_CONT;
|
||||
send_cmd(bi ? bi->GetUID() : params[0], "IDLE %s %ld %ld", source.c_str(), static_cast<long>(start_time), bi ? (static_cast<long>(Anope::CurTime - bi->lastmsg)) : 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
static Anope::string currentpass;
|
||||
@@ -306,28 +306,28 @@ class InspIRCdProto : public IRCDProto
|
||||
}
|
||||
} ircd_proto;
|
||||
|
||||
int anope_event_ftopic(const Anope::string &source, int ac, const char **av)
|
||||
bool event_ftopic(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
/* :source FTOPIC channel ts setby :topic */
|
||||
if (ac < 4)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 4)
|
||||
return true;
|
||||
|
||||
Channel *c = findchan(av[0]);
|
||||
Channel *c = findchan(params[0]);
|
||||
if (!c)
|
||||
{
|
||||
Log(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
|
||||
return MOD_CONT;
|
||||
Log(LOG_DEBUG) << "TOPIC " << params[3] << " for nonexistent channel " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
c->ChangeTopicInternal(av[2], av[3], Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : Anope::CurTime);
|
||||
c->ChangeTopicInternal(params[2], params[3], Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_mode(const Anope::string &source, int ac, const char **av)
|
||||
bool event_mode(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (*av[0] == '#' || *av[0] == '&')
|
||||
do_cmode(source, ac, av);
|
||||
if (params[0][0] == '#' || params[0][0] == '&')
|
||||
do_cmode(source, params[0], params[2], params[1]);
|
||||
else
|
||||
{
|
||||
/* InspIRCd lets opers change another
|
||||
@@ -335,7 +335,7 @@ int anope_event_mode(const Anope::string &source, int ac, const char **av)
|
||||
as it slightly breaks RFC1459
|
||||
*/
|
||||
User *u = finduser(source);
|
||||
User *u2 = finduser(av[0]);
|
||||
User *u2 = finduser(params[0]);
|
||||
|
||||
// This can happen with server-origin modes.
|
||||
if (!u)
|
||||
@@ -343,71 +343,68 @@ int anope_event_mode(const Anope::string &source, int ac, const char **av)
|
||||
|
||||
// if it's still null, drop it like fire.
|
||||
// most likely situation was that server introduced a nick which we subsequently akilled
|
||||
if (!u)
|
||||
return MOD_CONT;
|
||||
if (!u || !u2)
|
||||
return true;
|
||||
|
||||
av[0] = u2->nick.c_str();
|
||||
do_umode(u->nick, ac, av);
|
||||
do_umode(u->nick, u2->nick, params[1]);
|
||||
}
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_opertype(const Anope::string &source, int ac, const char **av)
|
||||
bool event_opertype(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
/* opertype is equivalent to mode +o because servers
|
||||
dont do this directly */
|
||||
User *u;
|
||||
u = finduser(source);
|
||||
User *u = finduser(source);
|
||||
if (u && !is_oper(u))
|
||||
{
|
||||
const char *newav[2];
|
||||
newav[0] = source.c_str();
|
||||
newav[1] = "+o";
|
||||
return anope_event_mode(source, 2, newav);
|
||||
std::vector<Anope::string> newparams;
|
||||
newparams.push_back(source);
|
||||
newparams.push_back(Anope::CurTime);
|
||||
newparams.push_back("+o");
|
||||
return event_mode(source, newparams);
|
||||
}
|
||||
else
|
||||
return MOD_CONT;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_fmode(const Anope::string &source, int ac, const char **av)
|
||||
bool event_fmode(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
const char *newav[128];
|
||||
int n, o;
|
||||
Channel *c;
|
||||
|
||||
/* :source FMODE #test 12345678 +nto foo */
|
||||
if (ac < 3)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 3)
|
||||
return true;
|
||||
|
||||
Channel *c = findchan(params[0]);
|
||||
/* Checking the TS for validity to avoid desyncs */
|
||||
if ((c = findchan(av[0])))
|
||||
if ((c = findchan(params[0])))
|
||||
{
|
||||
time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0;
|
||||
time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0;
|
||||
if (c->creation_time > ts)
|
||||
{
|
||||
/* Our TS is bigger, we should lower it */
|
||||
c->creation_time = ts;
|
||||
c->Reset();
|
||||
}
|
||||
else if (c->creation_time < ts)
|
||||
/* The TS we got is bigger, we should ignore this message. */
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
/* Got FMODE for a non-existing channel */
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
|
||||
/* TS's are equal now, so we can proceed with parsing */
|
||||
n = o = 0;
|
||||
while (n < ac)
|
||||
std::vector<Anope::string> newparams;
|
||||
for (unsigned n = 0; n < params.size(); ++n)
|
||||
{
|
||||
if (n != 1)
|
||||
{
|
||||
newav[o] = av[n];
|
||||
++o;
|
||||
Log(LOG_DEBUG) << "Param: " << newav[o - 1];
|
||||
newparams.push_back(params[n]);
|
||||
Log(LOG_DEBUG) << "Param: " << params[n];
|
||||
}
|
||||
++n;
|
||||
}
|
||||
|
||||
return anope_event_mode(source, ac - 1, newav);
|
||||
return event_mode(source, newparams);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -418,15 +415,15 @@ int anope_event_fmode(const Anope::string &source, int ac, const char **av)
|
||||
* 2: channel modes + params (NOTE: this may definitely be more than one param!)
|
||||
* last: users
|
||||
*/
|
||||
int anope_event_fjoin(const Anope::string &source, int ac, const char **av)
|
||||
bool event_fjoin(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Channel *c = findchan(av[0]);
|
||||
time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0;
|
||||
Channel *c = findchan(params[0]);
|
||||
time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0;
|
||||
bool keep_their_modes = true;
|
||||
|
||||
if (!c)
|
||||
{
|
||||
c = new Channel(av[0], ts);
|
||||
c = new Channel(params[0], ts);
|
||||
c->SetFlag(CH_SYNCING);
|
||||
}
|
||||
/* Our creation time is newer than what the server gave us */
|
||||
@@ -443,13 +440,18 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av)
|
||||
keep_their_modes = false;
|
||||
|
||||
/* If we need to keep their modes, and this FJOIN string contains modes */
|
||||
if (keep_their_modes && ac >= 4)
|
||||
if (keep_their_modes && params.size() >= 3)
|
||||
{
|
||||
Anope::string modes;
|
||||
for (unsigned i = 2; i < params.size() - 1; ++i)
|
||||
modes += " " + params[i];
|
||||
if (!modes.empty())
|
||||
modes.erase(modes.begin());
|
||||
/* Set the modes internally */
|
||||
ChanSetInternalModes(c, ac - 3, av + 2);
|
||||
c->SetModesInternal(NULL, modes);
|
||||
}
|
||||
|
||||
spacesepstream sep(av[ac - 1]);
|
||||
spacesepstream sep(params[params.size() - 1]);
|
||||
Anope::string buf;
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
@@ -512,190 +514,185 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av)
|
||||
c->Sync();
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Events */
|
||||
int anope_event_ping(const Anope::string &source, int ac, const char **av)
|
||||
bool event_ping(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac == 1)
|
||||
ircdproto->SendPong("", av[0]);
|
||||
if (params.size() == 1)
|
||||
ircdproto->SendPong("", params[0]);
|
||||
else if (params.size() == 2)
|
||||
ircdproto->SendPong(params[1], params[0]);
|
||||
|
||||
if (ac == 2)
|
||||
ircdproto->SendPong(av[1], av[0]);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_time(const Anope::string &source, int ac, const char **av)
|
||||
bool event_time(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac !=2)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 2)
|
||||
return true;
|
||||
|
||||
send_cmd(TS6SID, "TIME %s %s %ld", source.c_str(), av[1], static_cast<long>(Anope::CurTime));
|
||||
send_cmd(TS6SID, "TIME %s %s %ld", source.c_str(), params[1].c_str(), static_cast<long>(Anope::CurTime));
|
||||
|
||||
/* We handled it, don't pass it on to the core..
|
||||
* The core doesn't understand our syntax anyways.. ~ Viper */
|
||||
return MOD_STOP;
|
||||
}
|
||||
|
||||
int anope_event_436(const Anope::string &source, int ac, const char **av)
|
||||
bool event_436(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
m_nickcoll(av[0]);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
m_nickcoll(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_away(const Anope::string &source, int ac, const char **av)
|
||||
bool event_away(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
m_away(source, ac ? av[0] : "");
|
||||
return MOD_CONT;
|
||||
m_away(source, !params.empty() ? params[0] : "");
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Taken from hybrid.c, topic syntax is identical */
|
||||
int anope_event_topic(const Anope::string &source, int ac, const char **av)
|
||||
bool event_topic(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Channel *c = findchan(av[0]);
|
||||
Channel *c = findchan(params[0]);
|
||||
|
||||
if (!c)
|
||||
{
|
||||
Log() << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
|
||||
return MOD_CONT;
|
||||
Log() << "TOPIC " << params[1] << " for nonexistent channel " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
c->ChangeTopicInternal(source, (ac > 1 && *av[1] ? av[1] : ""), Anope::CurTime);
|
||||
c->ChangeTopicInternal(source, (params.size() > 1 ? params[1] : ""), Anope::CurTime);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_squit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_squit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_squit(source, ac, av);
|
||||
return MOD_CONT;
|
||||
do_squit(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_rsquit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_rsquit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
/* On InspIRCd we must send a SQUIT when we recieve RSQUIT for a server we have juped */
|
||||
Server *s = Server::Find(av[0]);
|
||||
Server *s = Server::Find(params[0]);
|
||||
if (s && s->HasFlag(SERVER_JUPED))
|
||||
send_cmd(TS6SID, "SQUIT %s :%s", s->GetSID().c_str(), ac > 1 ? av[1] : "");
|
||||
send_cmd(TS6SID, "SQUIT %s :%s", s->GetSID().c_str(), params.size() > 1 ? params[1].c_str() : "");
|
||||
|
||||
do_squit(source, ac, av);
|
||||
do_squit(source, params[0]);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_quit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_quit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_quit(source, ac, av);
|
||||
return MOD_CONT;
|
||||
do_quit(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_kill(const Anope::string &source, int ac, const char **av)
|
||||
bool event_kill(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = finduser(av[0]);
|
||||
BotInfo *bi = findbot(av[0]);
|
||||
m_kill(u ? u->nick : (bi ? bi->nick : av[0]), av[1]);
|
||||
return MOD_CONT;
|
||||
User *u = finduser(params[0]);
|
||||
BotInfo *bi = findbot(params[0]);
|
||||
m_kill(u ? u->nick : (bi ? bi->nick : params[0]), params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_kick(const Anope::string &source, int ac, const char **av)
|
||||
bool event_kick(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_kick(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 2)
|
||||
do_kick(source, params[0], params[1], params[2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_join(const Anope::string &source, int ac, const char **av)
|
||||
bool event_join(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_join(source, ac, av);
|
||||
return MOD_CONT;
|
||||
do_join(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_motd(const Anope::string &source, int ac, const char **av)
|
||||
bool event_motd(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
m_motd(source);
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_setname(const Anope::string &source, int ac, const char **av)
|
||||
bool event_setname(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
|
||||
u = finduser(source);
|
||||
User *u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "SETNAME for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetRealname(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetRealname(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_chgname(const Anope::string &source, int ac, const char **av)
|
||||
bool event_chgname(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
User *u = finduser(source);
|
||||
|
||||
u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "FNAME for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetRealname(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetRealname(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_setident(const Anope::string &source, int ac, const char **av)
|
||||
bool event_setident(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
User *u = finduser(source);
|
||||
|
||||
u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "SETIDENT for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetIdent(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetIdent(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_chgident(const Anope::string &source, int ac, const char **av)
|
||||
bool event_chgident(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
User *u = finduser(params[0]);
|
||||
|
||||
u = finduser(av[0]);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "CHGIDENT for nonexistent user " << av[0];
|
||||
return MOD_CONT;
|
||||
Log(LOG_DEBUG) << "CHGIDENT for nonexistent user " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetIdent(av[1]);
|
||||
return MOD_CONT;
|
||||
u->SetIdent(params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_sethost(const Anope::string &source, int ac, const char **av)
|
||||
bool event_sethost(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
User *u = finduser(source);
|
||||
|
||||
u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "SETHOST for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetDisplayedHost(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetDisplayedHost(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_nick(const Anope::string &source, int ac, const char **av)
|
||||
bool event_nick(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_nick(source, av[0], "", "", "", "", 0, "", "", "", "");
|
||||
return MOD_CONT;
|
||||
do_nick(source, params[0], "", "", "", "", 0, "", "", "", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -712,11 +709,11 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
|
||||
* last: realname
|
||||
*/
|
||||
|
||||
int anope_event_uid(const Anope::string &source, int ac, const char **av)
|
||||
bool event_uid(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *user;
|
||||
Server *s = Server::Find(source);
|
||||
int ts = strtoul(av[1], NULL, 10);
|
||||
time_t ts = convertTo<time_t>(params[1]);
|
||||
|
||||
/* Check if the previously introduced user was Id'd for the nickgroup of the nick he s currently using.
|
||||
* If not, validate the user. ~ Viper*/
|
||||
@@ -737,10 +734,10 @@ int anope_event_uid(const Anope::string &source, int ac, const char **av)
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
|
||||
Anope::string modes = av[8];
|
||||
for (int i = 9; i < ac - 1; ++i)
|
||||
modes += Anope::string(" ") + av[i];
|
||||
user = do_nick("", av[2], av[5], av[3], s->GetName(), av[ac - 1], ts, av[6], av[4], av[0], modes);
|
||||
Anope::string modes = params[8];
|
||||
for (unsigned i = 9; i < params.size() - 1; ++i)
|
||||
modes += " " + params[i];
|
||||
user = do_nick("", params[2], params[5], params[3], s->GetName(), params[params.size() - 1], ts, params[6], params[4], params[0], modes);
|
||||
if (user)
|
||||
{
|
||||
if (!user->server->IsSynced())
|
||||
@@ -749,22 +746,21 @@ int anope_event_uid(const Anope::string &source, int ac, const char **av)
|
||||
validate_user(user);
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_chghost(const Anope::string &source, int ac, const char **av)
|
||||
bool event_chghost(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
User *u = finduser(source);
|
||||
|
||||
u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "FHOST for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetDisplayedHost(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetDisplayedHost(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -775,53 +771,53 @@ int anope_event_chghost(const Anope::string &source, int ac, const char **av)
|
||||
* 3: numeric
|
||||
* 4: desc
|
||||
*/
|
||||
int anope_event_server(const Anope::string &source, int ac, const char **av)
|
||||
bool event_server(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_server(source, av[0], Anope::string(av[2]).is_pos_number_only() ? convertTo<unsigned>(av[2]) : 0, av[4], av[3]);
|
||||
return MOD_CONT;
|
||||
do_server(source, params[0], Anope::string(params[2]).is_pos_number_only() ? convertTo<unsigned>(params[2]) : 0, params[4], params[3]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_privmsg(const Anope::string &source, int ac, const char **av)
|
||||
bool event_privmsg(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!finduser(source))
|
||||
return MOD_CONT; // likely a message from a server, which can happen.
|
||||
return true; // likely a message from a server, which can happen.
|
||||
|
||||
m_privmsg(source, av[0], av[1]);
|
||||
return MOD_CONT;
|
||||
m_privmsg(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_part(const Anope::string &source, int ac, const char **av)
|
||||
bool event_part(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_part(source, ac, av);
|
||||
return MOD_CONT;
|
||||
do_part(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_whois(const Anope::string &source, int ac, const char **av)
|
||||
bool event_whois(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
m_whois(source, av[0]);
|
||||
return MOD_CONT;
|
||||
m_whois(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_metadata(const Anope::string &source, int ac, const char **av)
|
||||
bool event_metadata(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 3)
|
||||
return MOD_CONT;
|
||||
else if (!strcmp(av[1], "accountname"))
|
||||
if (params.size() < 3)
|
||||
return true;
|
||||
if (params[1].equals_cs("accountname"))
|
||||
{
|
||||
User *u = finduser(av[0]);
|
||||
NickCore *nc = findcore(av[2]);
|
||||
User *u = finduser(params[0]);
|
||||
NickCore *nc = findcore(params[2]);
|
||||
if (u && nc)
|
||||
{
|
||||
u->Login(nc);
|
||||
}
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
bool event_capab(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!strcasecmp(av[0], "START"))
|
||||
if (params[0].equals_cs("START"))
|
||||
{
|
||||
/* reset CAPAB */
|
||||
has_servicesmod = false;
|
||||
@@ -831,26 +827,26 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
has_chgidentmod = false;
|
||||
has_hidechansmod = false;
|
||||
}
|
||||
else if (!strcasecmp(av[0], "MODULES"))
|
||||
else if (params[0].equals_cs("MODULES"))
|
||||
{
|
||||
if (strstr(av[1], "m_globops.so"))
|
||||
if (params[1].find("m_globops.so") != Anope::string::npos)
|
||||
has_globopsmod = true;
|
||||
if (strstr(av[1], "m_services_account.so"))
|
||||
if (params[1].find("m_services_account.so") != Anope::string::npos)
|
||||
has_servicesmod = true;
|
||||
if (strstr(av[1], "m_svshold.so"))
|
||||
if (params[1].find("m_svshold.so") != Anope::string::npos)
|
||||
has_svsholdmod = true;
|
||||
if (strstr(av[1], "m_chghost.so"))
|
||||
if (params[1].find("m_chghost.so") != Anope::string::npos)
|
||||
has_chghostmod = true;
|
||||
if (strstr(av[1], "m_chgident.so"))
|
||||
if (params[1].find("m_chgident.so") != Anope::string::npos)
|
||||
has_chgidentmod = true;
|
||||
if (strstr(av[1], "m_hidechans.so"))
|
||||
if (params[1].find("m_hidechans.so") != Anope::string::npos)
|
||||
has_hidechansmod = true;
|
||||
if (strstr(av[1], "m_servprotect.so"))
|
||||
if (params[1].find("m_servprotect.so") != Anope::string::npos)
|
||||
ircd->pseudoclient_mode = "+Ik";
|
||||
}
|
||||
else if (!strcasecmp(av[0], "CAPABILITIES"))
|
||||
else if (params[0].equals_cs("CAPABILITIES"))
|
||||
{
|
||||
spacesepstream ssep(av[1]);
|
||||
spacesepstream ssep(params[1]);
|
||||
Anope::string capab;
|
||||
while (ssep.GetToken(capab))
|
||||
{
|
||||
@@ -1116,7 +1112,7 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcasecmp(av[0], "END"))
|
||||
else if (params[0].equals_cs("END"))
|
||||
{
|
||||
if (!has_globopsmod)
|
||||
{
|
||||
@@ -1148,12 +1144,12 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
ircd->svshold = has_svsholdmod;
|
||||
}
|
||||
|
||||
CapabParse(ac, av);
|
||||
CapabParse(params);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_endburst(const Anope::string &source, int ac, const char **av)
|
||||
bool event_endburst(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = prev_u_intro;
|
||||
Server *s = Server::Find(source);
|
||||
@@ -1182,45 +1178,45 @@ int anope_event_endburst(const Anope::string &source, int ac, const char **av)
|
||||
Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName();
|
||||
|
||||
s->Sync(true);
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
void moduleAddIRCDMsgs()
|
||||
{
|
||||
Anope::AddMessage("ENDBURST", anope_event_endburst);
|
||||
Anope::AddMessage("436", anope_event_436);
|
||||
Anope::AddMessage("AWAY", anope_event_away);
|
||||
Anope::AddMessage("JOIN", anope_event_join);
|
||||
Anope::AddMessage("KICK", anope_event_kick);
|
||||
Anope::AddMessage("KILL", anope_event_kill);
|
||||
Anope::AddMessage("MODE", anope_event_mode);
|
||||
Anope::AddMessage("MOTD", anope_event_motd);
|
||||
Anope::AddMessage("NICK", anope_event_nick);
|
||||
Anope::AddMessage("UID", anope_event_uid);
|
||||
Anope::AddMessage("CAPAB", anope_event_capab);
|
||||
Anope::AddMessage("PART", anope_event_part);
|
||||
Anope::AddMessage("PING", anope_event_ping);
|
||||
Anope::AddMessage("TIME", anope_event_time);
|
||||
Anope::AddMessage("PRIVMSG", anope_event_privmsg);
|
||||
Anope::AddMessage("QUIT", anope_event_quit);
|
||||
Anope::AddMessage("SERVER", anope_event_server);
|
||||
Anope::AddMessage("SQUIT", anope_event_squit);
|
||||
Anope::AddMessage("RSQUIT", anope_event_rsquit);
|
||||
Anope::AddMessage("TOPIC", anope_event_topic);
|
||||
Anope::AddMessage("WHOIS", anope_event_whois);
|
||||
Anope::AddMessage("SVSMODE", anope_event_mode);
|
||||
Anope::AddMessage("FHOST", anope_event_chghost);
|
||||
Anope::AddMessage("CHGIDENT", anope_event_chgident);
|
||||
Anope::AddMessage("FNAME", anope_event_chgname);
|
||||
Anope::AddMessage("SETHOST", anope_event_sethost);
|
||||
Anope::AddMessage("SETIDENT", anope_event_setident);
|
||||
Anope::AddMessage("SETNAME", anope_event_setname);
|
||||
Anope::AddMessage("FJOIN", anope_event_fjoin);
|
||||
Anope::AddMessage("FMODE", anope_event_fmode);
|
||||
Anope::AddMessage("FTOPIC", anope_event_ftopic);
|
||||
Anope::AddMessage("OPERTYPE", anope_event_opertype);
|
||||
Anope::AddMessage("IDLE", anope_event_idle);
|
||||
Anope::AddMessage("METADATA", anope_event_metadata);
|
||||
Anope::AddMessage("ENDBURST", event_endburst);
|
||||
Anope::AddMessage("436", event_436);
|
||||
Anope::AddMessage("AWAY", event_away);
|
||||
Anope::AddMessage("JOIN", event_join);
|
||||
Anope::AddMessage("KICK", event_kick);
|
||||
Anope::AddMessage("KILL", event_kill);
|
||||
Anope::AddMessage("MODE", event_mode);
|
||||
Anope::AddMessage("MOTD", event_motd);
|
||||
Anope::AddMessage("NICK", event_nick);
|
||||
Anope::AddMessage("UID", event_uid);
|
||||
Anope::AddMessage("CAPAB", event_capab);
|
||||
Anope::AddMessage("PART", event_part);
|
||||
Anope::AddMessage("PING", event_ping);
|
||||
Anope::AddMessage("TIME", event_time);
|
||||
Anope::AddMessage("PRIVMSG", event_privmsg);
|
||||
Anope::AddMessage("QUIT", event_quit);
|
||||
Anope::AddMessage("SERVER", event_server);
|
||||
Anope::AddMessage("SQUIT", event_squit);
|
||||
Anope::AddMessage("RSQUIT", event_rsquit);
|
||||
Anope::AddMessage("TOPIC", event_topic);
|
||||
Anope::AddMessage("WHOIS", event_whois);
|
||||
Anope::AddMessage("SVSMODE", event_mode);
|
||||
Anope::AddMessage("FHOST", event_chghost);
|
||||
Anope::AddMessage("CHGIDENT", event_chgident);
|
||||
Anope::AddMessage("FNAME", event_chgname);
|
||||
Anope::AddMessage("SETHOST", event_sethost);
|
||||
Anope::AddMessage("SETIDENT", event_setident);
|
||||
Anope::AddMessage("SETNAME", event_setname);
|
||||
Anope::AddMessage("FJOIN", event_fjoin);
|
||||
Anope::AddMessage("FMODE", event_fmode);
|
||||
Anope::AddMessage("FTOPIC", event_ftopic);
|
||||
Anope::AddMessage("OPERTYPE", event_opertype);
|
||||
Anope::AddMessage("IDLE", event_idle);
|
||||
Anope::AddMessage("METADATA", event_metadata);
|
||||
}
|
||||
|
||||
bool ChannelModeFlood::IsValid(const Anope::string &value) const
|
||||
|
||||
+218
-222
@@ -66,12 +66,12 @@ void inspircd_cmd_chghost(const Anope::string &nick, const Anope::string &vhost)
|
||||
send_cmd(HostServ ? HostServ->GetUID() : TS6SID, "CHGHOST %s %s", nick.c_str(), vhost.c_str());
|
||||
}
|
||||
|
||||
int anope_event_idle(const Anope::string &source, int ac, const char **av)
|
||||
bool event_idle(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
BotInfo *bi = findbot(av[0]);
|
||||
BotInfo *bi = findbot(params[0]);
|
||||
|
||||
send_cmd(bi ? bi->GetUID() : av[0], "IDLE %s %ld %ld", source.c_str(), static_cast<long>(start_time), bi ? (static_cast<long>(Anope::CurTime - bi->lastmsg)) : 0);
|
||||
return MOD_CONT;
|
||||
send_cmd(bi ? bi->GetUID() : params[0], "IDLE %s %ld %ld", source.c_str(), static_cast<long>(start_time), bi ? (static_cast<long>(Anope::CurTime - bi->lastmsg)) : 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
static Anope::string currentpass;
|
||||
@@ -304,28 +304,28 @@ class InspIRCdProto : public IRCDProto
|
||||
}
|
||||
} ircd_proto;
|
||||
|
||||
int anope_event_ftopic(const Anope::string &source, int ac, const char **av)
|
||||
bool event_ftopic(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
/* :source FTOPIC channel ts setby :topic */
|
||||
if (ac < 4)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 4)
|
||||
return true;
|
||||
|
||||
Channel *c = findchan(av[0]);
|
||||
Channel *c = findchan(params[0]);
|
||||
if (!c)
|
||||
{
|
||||
Log(LOG_DEBUG) << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
|
||||
return MOD_CONT;
|
||||
Log(LOG_DEBUG) << "TOPIC " << params[3] << " for nonexistent channel " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
c->ChangeTopicInternal(av[2], av[3], Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : Anope::CurTime);
|
||||
c->ChangeTopicInternal(params[2], params[3], Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_mode(const Anope::string &source, int ac, const char **av)
|
||||
bool event_mode(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (*av[0] == '#' || *av[0] == '&')
|
||||
do_cmode(source, ac, av);
|
||||
if (params[0][0] == '#' || params[0][0] == '&')
|
||||
do_cmode(source, params[0], params[2], params[1]);
|
||||
else
|
||||
{
|
||||
/* InspIRCd lets opers change another
|
||||
@@ -333,7 +333,7 @@ int anope_event_mode(const Anope::string &source, int ac, const char **av)
|
||||
as it slightly breaks RFC1459
|
||||
*/
|
||||
User *u = finduser(source);
|
||||
User *u2 = finduser(av[0]);
|
||||
User *u2 = finduser(params[0]);
|
||||
|
||||
// This can happen with server-origin modes.
|
||||
if (!u)
|
||||
@@ -341,16 +341,15 @@ int anope_event_mode(const Anope::string &source, int ac, const char **av)
|
||||
|
||||
// if it's still null, drop it like fire.
|
||||
// most likely situation was that server introduced a nick which we subsequently akilled
|
||||
if (!u)
|
||||
return MOD_CONT;
|
||||
if (!u || !u2)
|
||||
return true;
|
||||
|
||||
av[0] = u2->nick.c_str();
|
||||
do_umode(u->nick, ac, av);
|
||||
do_umode(u->nick, u2->nick, params[1]);
|
||||
}
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_opertype(const Anope::string &source, int ac, const char **av)
|
||||
bool event_opertype(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
/* opertype is equivalent to mode +o because servers
|
||||
dont do this directly */
|
||||
@@ -358,54 +357,48 @@ int anope_event_opertype(const Anope::string &source, int ac, const char **av)
|
||||
u = finduser(source);
|
||||
if (u && !is_oper(u))
|
||||
{
|
||||
const char *newav[2];
|
||||
newav[0] = source.c_str();
|
||||
newav[1] = "+o";
|
||||
return anope_event_mode(source, 2, newav);
|
||||
std::vector<Anope::string> newparams;
|
||||
newparams.push_back(source);
|
||||
newparams.push_back(Anope::CurTime);
|
||||
newparams.push_back("+o");
|
||||
return event_mode(source, newparams);
|
||||
}
|
||||
else
|
||||
return MOD_CONT;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_fmode(const Anope::string &source, int ac, const char **av)
|
||||
bool event_fmode(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
const char *newav[128];
|
||||
int n, o;
|
||||
Channel *c;
|
||||
|
||||
/* :source FMODE #test 12345678 +nto foo */
|
||||
if (ac < 3)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 3)
|
||||
return true;
|
||||
|
||||
Channel *c = findchan(params[0]);
|
||||
if (!c)
|
||||
return true;
|
||||
|
||||
/* Checking the TS for validity to avoid desyncs */
|
||||
if ((c = findchan(av[0])))
|
||||
time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0;
|
||||
if (c->creation_time > ts)
|
||||
{
|
||||
time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0;
|
||||
if (c->creation_time > ts)
|
||||
/* Our TS is bigger, we should lower it */
|
||||
c->creation_time = ts;
|
||||
else if (c->creation_time < ts)
|
||||
/* The TS we got is bigger, we should ignore this message. */
|
||||
return MOD_CONT;
|
||||
/* Our TS is bigger, we should lower it */
|
||||
c->creation_time = ts;
|
||||
c->Reset();
|
||||
}
|
||||
else
|
||||
/* Got FMODE for a non-existing channel */
|
||||
return MOD_CONT;
|
||||
else if (c->creation_time < ts)
|
||||
/* The TS we got is bigger, we should ignore this message. */
|
||||
return true;
|
||||
|
||||
/* TS's are equal now, so we can proceed with parsing */
|
||||
n = o = 0;
|
||||
while (n < ac)
|
||||
{
|
||||
if (n != 1)
|
||||
{
|
||||
newav[o] = av[n];
|
||||
++o;
|
||||
Log(LOG_DEBUG) << "Param: " << newav[o - 1];
|
||||
}
|
||||
++n;
|
||||
}
|
||||
std::vector<Anope::string> newparams;
|
||||
newparams.push_back(params[0]);
|
||||
newparams.push_back(params[1]);
|
||||
Anope::string modes = params[2];
|
||||
for (unsigned n = 3; n < params.size(); ++n)
|
||||
modes += " " + params[n];
|
||||
newparams.push_back(modes);
|
||||
|
||||
return anope_event_mode(source, ac - 1, newav);
|
||||
return event_mode(source, newparams);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -416,15 +409,15 @@ int anope_event_fmode(const Anope::string &source, int ac, const char **av)
|
||||
* 2: channel modes + params (NOTE: this may definitely be more than one param!)
|
||||
* last: users
|
||||
*/
|
||||
int anope_event_fjoin(const Anope::string &source, int ac, const char **av)
|
||||
bool event_fjoin(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Channel *c = findchan(av[0]);
|
||||
time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0;
|
||||
Channel *c = findchan(params[0]);
|
||||
time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0;
|
||||
bool keep_their_modes = true;
|
||||
|
||||
if (!c)
|
||||
{
|
||||
c = new Channel(av[0], ts);
|
||||
c = new Channel(params[0], ts);
|
||||
c->SetFlag(CH_SYNCING);
|
||||
}
|
||||
/* Our creation time is newer than what the server gave us */
|
||||
@@ -441,13 +434,18 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av)
|
||||
keep_their_modes = false;
|
||||
|
||||
/* If we need to keep their modes, and this FJOIN string contains modes */
|
||||
if (keep_their_modes && ac >= 4)
|
||||
if (keep_their_modes && params.size() >= 3)
|
||||
{
|
||||
Anope::string modes;
|
||||
for (unsigned i = 2; i < params.size() - 1; ++i)
|
||||
modes += " " + params[i];
|
||||
if (!modes.empty())
|
||||
modes.erase(modes.begin());
|
||||
/* Set the modes internally */
|
||||
ChanSetInternalModes(c, ac - 3, av + 2);
|
||||
c->SetModesInternal(NULL, modes);
|
||||
}
|
||||
|
||||
spacesepstream sep(av[ac - 1]);
|
||||
spacesepstream sep(params[params.size() - 1]);
|
||||
Anope::string buf;
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
@@ -510,112 +508,111 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av)
|
||||
c->Sync();
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Events */
|
||||
int anope_event_ping(const Anope::string &source, int ac, const char **av)
|
||||
bool event_ping(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac == 1)
|
||||
ircdproto->SendPong("", av[0]);
|
||||
if (params.size() == 1)
|
||||
ircdproto->SendPong("", params[0]);
|
||||
else if (params.size() == 2)
|
||||
ircdproto->SendPong(params[1], params[0]);
|
||||
|
||||
if (ac == 2)
|
||||
ircdproto->SendPong(av[1], av[0]);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_time(const Anope::string &source, int ac, const char **av)
|
||||
bool event_time(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac !=2)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 2)
|
||||
return true;
|
||||
|
||||
send_cmd(TS6SID, "TIME %s %s %ld", source.c_str(), av[1], static_cast<long>(Anope::CurTime));
|
||||
send_cmd(TS6SID, "TIME %s %s %ld", source.c_str(), params[1].c_str(), static_cast<long>(Anope::CurTime));
|
||||
|
||||
/* We handled it, don't pass it on to the core..
|
||||
* The core doesn't understand our syntax anyways.. ~ Viper */
|
||||
return MOD_STOP;
|
||||
}
|
||||
|
||||
int anope_event_436(const Anope::string &source, int ac, const char **av)
|
||||
bool event_436(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
m_nickcoll(av[0]);
|
||||
return MOD_CONT;
|
||||
m_nickcoll(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_away(const Anope::string &source, int ac, const char **av)
|
||||
bool event_away(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
m_away(source, ac ? av[0] : "");
|
||||
return MOD_CONT;
|
||||
m_away(source, !params.empty() ? params[0] : "");
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Taken from hybrid.c, topic syntax is identical */
|
||||
int anope_event_topic(const Anope::string &source, int ac, const char **av)
|
||||
bool event_topic(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Channel *c = findchan(av[0]);
|
||||
Channel *c = findchan(params[0]);
|
||||
|
||||
if (!c)
|
||||
{
|
||||
Log() << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
|
||||
return MOD_CONT;
|
||||
Log() << "TOPIC " << (params.size() > 1 ? params[1] : "") << " for nonexistent channel " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
c->ChangeTopicInternal(source, (ac > 1 && *av[1] ? av[1] : ""), Anope::CurTime);
|
||||
c->ChangeTopicInternal(source, (params.size() > 1 ? params[1] : ""), Anope::CurTime);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_squit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_squit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_squit(source, ac, av);
|
||||
return MOD_CONT;
|
||||
do_squit(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_rsquit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_rsquit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
/* On InspIRCd we must send a SQUIT when we recieve RSQUIT for a server we have juped */
|
||||
Server *s = Server::Find(av[0]);
|
||||
Server *s = Server::Find(params[0]);
|
||||
if (s && s->HasFlag(SERVER_JUPED))
|
||||
send_cmd(TS6SID, "SQUIT %s :%s", s->GetSID().c_str(), ac > 1 ? av[1] : "");
|
||||
send_cmd(TS6SID, "SQUIT %s :%s", s->GetSID().c_str(), params.size() > 1 ? params[1].c_str() : "");
|
||||
|
||||
do_squit(source, ac, av);
|
||||
do_squit(source, params[0]);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_quit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_quit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_quit(source, ac, av);
|
||||
return MOD_CONT;
|
||||
do_quit(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_kill(const Anope::string &source, int ac, const char **av)
|
||||
bool event_kill(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = finduser(av[0]);
|
||||
BotInfo *bi = findbot(av[0]);
|
||||
m_kill(u ? u->nick : (bi ? bi->nick : av[0]), av[1]);
|
||||
return MOD_CONT;
|
||||
User *u = finduser(params[0]);
|
||||
BotInfo *bi = findbot(params[0]);
|
||||
m_kill(u ? u->nick : (bi ? bi->nick : params[0]), params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_kick(const Anope::string &source, int ac, const char **av)
|
||||
bool event_kick(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_kick(source, ac, av);
|
||||
return MOD_CONT;
|
||||
do_kick(source, params[0], params[1], params[2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_join(const Anope::string &source, int ac, const char **av)
|
||||
bool event_join(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_join(source, ac, av);
|
||||
return MOD_CONT;
|
||||
do_join(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_motd(const Anope::string &source, int ac, const char **av)
|
||||
bool event_motd(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
m_motd(source);
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_setname(const Anope::string &source, int ac, const char **av)
|
||||
bool event_setname(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
|
||||
@@ -623,14 +620,14 @@ int anope_event_setname(const Anope::string &source, int ac, const char **av)
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "SETNAME for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetRealname(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetRealname(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_chgname(const Anope::string &source, int ac, const char **av)
|
||||
bool event_chgname(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
|
||||
@@ -638,14 +635,14 @@ int anope_event_chgname(const Anope::string &source, int ac, const char **av)
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "FNAME for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetRealname(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetRealname(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_setident(const Anope::string &source, int ac, const char **av)
|
||||
bool event_setident(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
|
||||
@@ -653,28 +650,28 @@ int anope_event_setident(const Anope::string &source, int ac, const char **av)
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "SETIDENT for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetIdent(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetIdent(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_chgident(const Anope::string &source, int ac, const char **av)
|
||||
bool event_chgident(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = finduser(source);
|
||||
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "FIDENT for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetIdent(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetIdent(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_sethost(const Anope::string &source, int ac, const char **av)
|
||||
bool event_sethost(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
|
||||
@@ -682,17 +679,17 @@ int anope_event_sethost(const Anope::string &source, int ac, const char **av)
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "SETHOST for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetDisplayedHost(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetDisplayedHost(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_nick(const Anope::string &source, int ac, const char **av)
|
||||
bool event_nick(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_nick(source, av[0], "", "", "", "", 0, "", "", "", "");
|
||||
return MOD_CONT;
|
||||
do_nick(source, params[0], "", "", "", "", 0, "", "", "", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -709,11 +706,11 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
|
||||
* last: realname
|
||||
*/
|
||||
|
||||
int anope_event_uid(const Anope::string &source, int ac, const char **av)
|
||||
bool event_uid(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *user;
|
||||
Server *s = Server::Find(source);
|
||||
time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0;
|
||||
time_t ts = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0;
|
||||
|
||||
/* Check if the previously introduced user was Id'd for the nickgroup of the nick he s currently using.
|
||||
* If not, validate the user. ~ Viper*/
|
||||
@@ -734,10 +731,10 @@ int anope_event_uid(const Anope::string &source, int ac, const char **av)
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
|
||||
Anope::string modes = av[8];
|
||||
for (int i = 9; i < ac - 1; ++i)
|
||||
modes += Anope::string(" ") + av[i];
|
||||
user = do_nick("", av[2], av[5], av[3], s->GetName(), av[ac - 1], ts, av[6], av[4], av[0], modes);
|
||||
Anope::string modes = params[8];
|
||||
for (unsigned i = 9; i < params.size() - 1; ++i)
|
||||
modes += Anope::string(" ") + params[i];
|
||||
user = do_nick("", params[2], params[5], params[3], s->GetName(), params[params.size() - 1], ts, params[6], params[4], params[0], modes);
|
||||
if (user)
|
||||
{
|
||||
if (!user->server->IsSynced())
|
||||
@@ -746,22 +743,20 @@ int anope_event_uid(const Anope::string &source, int ac, const char **av)
|
||||
validate_user(user);
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_chghost(const Anope::string &source, int ac, const char **av)
|
||||
bool event_chghost(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
|
||||
u = finduser(source);
|
||||
User *u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "FHOST for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetDisplayedHost(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetDisplayedHost(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -772,55 +767,56 @@ int anope_event_chghost(const Anope::string &source, int ac, const char **av)
|
||||
* 3: numeric
|
||||
* 4: desc
|
||||
*/
|
||||
int anope_event_server(const Anope::string &source, int ac, const char **av)
|
||||
bool event_server(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_server(source, av[0], Anope::string(av[2]).is_pos_number_only() ? convertTo<unsigned>(av[2]) : 0, av[4], av[3]);
|
||||
return MOD_CONT;
|
||||
do_server(source, params[0], Anope::string(params[2]).is_pos_number_only() ? convertTo<unsigned>(params[2]) : 0, params[4], params[3]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_privmsg(const Anope::string &source, int ac, const char **av)
|
||||
bool event_privmsg(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!finduser(source))
|
||||
return MOD_CONT; // likely a message from a server, which can happen.
|
||||
return true; // likely a message from a server, which can happen.
|
||||
|
||||
m_privmsg(source, av[0], av[1]);
|
||||
return MOD_CONT;
|
||||
m_privmsg(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_part(const Anope::string &source, int ac, const char **av)
|
||||
bool event_part(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
do_part(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
do_part(source, params[0], params.size() > 1 ? params[1] : "");
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_whois(const Anope::string &source, int ac, const char **av)
|
||||
bool event_whois(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
m_whois(source, av[0]);
|
||||
return MOD_CONT;
|
||||
m_whois(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_metadata(const Anope::string &source, int ac, const char **av)
|
||||
bool event_metadata(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 3)
|
||||
return MOD_CONT;
|
||||
else if (!strcmp(av[1], "accountname"))
|
||||
if (params.size() < 3)
|
||||
return true;
|
||||
else if (params[1].equals_cs("accountname"))
|
||||
{
|
||||
User *u = finduser(av[0]);
|
||||
NickCore *nc = findcore(av[2]);
|
||||
User *u = finduser(params[0]);
|
||||
NickCore *nc = findcore(params[2]);
|
||||
if (u && nc)
|
||||
{
|
||||
u->Login(nc);
|
||||
}
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
bool event_capab(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!strcasecmp(av[0], "START"))
|
||||
if (params[0].equals_cs("START"))
|
||||
{
|
||||
if (ac < 2 || (Anope::string(av[1]).is_pos_number_only() ? convertTo<unsigned>(av[1]): 0) < 1202)
|
||||
if (params.size() < 2 || (Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]): 0) < 1202)
|
||||
{
|
||||
send_cmd("", "ERROR :Protocol mismatch, no or invalid protocol version given in CAPAB START");
|
||||
quitmsg = "Protocol mismatch, no or invalid protocol version given in CAPAB START";
|
||||
@@ -834,9 +830,9 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
has_chghostmod = false;
|
||||
has_chgidentmod = false;
|
||||
}
|
||||
else if (!strcasecmp(av[0], "CHANMODES"))
|
||||
else if (params[0].equals_cs("CHANMODES"))
|
||||
{
|
||||
spacesepstream ssep(av[1]);
|
||||
spacesepstream ssep(params[1]);
|
||||
Anope::string capab;
|
||||
|
||||
while (ssep.GetToken(capab))
|
||||
@@ -945,9 +941,9 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
Log() << "Unrecognized mode string in CAPAB CHANMODES: " << capab;
|
||||
}
|
||||
}
|
||||
else if (!strcasecmp(av[0], "USERMODES"))
|
||||
if (params[0].equals_cs("USERMODES"))
|
||||
{
|
||||
spacesepstream ssep(av[1]);
|
||||
spacesepstream ssep(params[1]);
|
||||
Anope::string capab;
|
||||
|
||||
while (ssep.GetToken(capab))
|
||||
@@ -1001,18 +997,18 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
Log() << "Unrecognized mode string in CAPAB USERMODES: " << capab;
|
||||
}
|
||||
}
|
||||
else if (!strcasecmp(av[0], "MODULES"))
|
||||
else if (params[0].equals_cs("MODULES"))
|
||||
{
|
||||
spacesepstream ssep(av[1]);
|
||||
spacesepstream ssep(params[1]);
|
||||
Anope::string module;
|
||||
|
||||
while (ssep.GetToken(module))
|
||||
if (module.equals_cs("m_svshold.so"))
|
||||
has_svsholdmod = true;
|
||||
}
|
||||
else if (!strcasecmp(av[0], "MODSUPPORT"))
|
||||
else if (params[0].equals_cs("MODSUPPORT"))
|
||||
{
|
||||
spacesepstream ssep(av[1]);
|
||||
spacesepstream ssep(params[1]);
|
||||
Anope::string module;
|
||||
|
||||
while (ssep.GetToken(module))
|
||||
@@ -1027,9 +1023,9 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
ircd->pseudoclient_mode = "+Ik";
|
||||
}
|
||||
}
|
||||
else if (!strcasecmp(av[0], "CAPABILITIES"))
|
||||
else if (params[0].equals_cs("CAPABILITIES"))
|
||||
{
|
||||
spacesepstream ssep(av[1]);
|
||||
spacesepstream ssep(params[1]);
|
||||
Anope::string capab;
|
||||
while (ssep.GetToken(capab))
|
||||
{
|
||||
@@ -1096,7 +1092,7 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcasecmp(av[0], "END"))
|
||||
else if (params[0].equals_cs("END"))
|
||||
{
|
||||
if (!has_servicesmod)
|
||||
{
|
||||
@@ -1121,12 +1117,12 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
ircd->svshold = has_svsholdmod;
|
||||
}
|
||||
|
||||
CapabParse(ac, av);
|
||||
CapabParse(params);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_endburst(const Anope::string &source, int ac, const char **av)
|
||||
bool event_endburst(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = prev_u_intro;
|
||||
Server *s = Server::Find(source);
|
||||
@@ -1155,45 +1151,45 @@ int anope_event_endburst(const Anope::string &source, int ac, const char **av)
|
||||
Log(LOG_DEBUG) << "Processed ENDBURST for " << s->GetName();
|
||||
|
||||
s->Sync(true);
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
void moduleAddIRCDMsgs()
|
||||
{
|
||||
Anope::AddMessage("ENDBURST", anope_event_endburst);
|
||||
Anope::AddMessage("436", anope_event_436);
|
||||
Anope::AddMessage("AWAY", anope_event_away);
|
||||
Anope::AddMessage("JOIN", anope_event_join);
|
||||
Anope::AddMessage("KICK", anope_event_kick);
|
||||
Anope::AddMessage("KILL", anope_event_kill);
|
||||
Anope::AddMessage("MODE", anope_event_mode);
|
||||
Anope::AddMessage("MOTD", anope_event_motd);
|
||||
Anope::AddMessage("NICK", anope_event_nick);
|
||||
Anope::AddMessage("UID", anope_event_uid);
|
||||
Anope::AddMessage("CAPAB", anope_event_capab);
|
||||
Anope::AddMessage("PART", anope_event_part);
|
||||
Anope::AddMessage("PING", anope_event_ping);
|
||||
Anope::AddMessage("TIME", anope_event_time);
|
||||
Anope::AddMessage("PRIVMSG", anope_event_privmsg);
|
||||
Anope::AddMessage("QUIT", anope_event_quit);
|
||||
Anope::AddMessage("SERVER", anope_event_server);
|
||||
Anope::AddMessage("SQUIT", anope_event_squit);
|
||||
Anope::AddMessage("RSQUIT", anope_event_rsquit);
|
||||
Anope::AddMessage("TOPIC", anope_event_topic);
|
||||
Anope::AddMessage("WHOIS", anope_event_whois);
|
||||
Anope::AddMessage("SVSMODE", anope_event_mode);
|
||||
Anope::AddMessage("FHOST", anope_event_chghost);
|
||||
Anope::AddMessage("FIDENT", anope_event_chgident);
|
||||
Anope::AddMessage("FNAME", anope_event_chgname);
|
||||
Anope::AddMessage("SETHOST", anope_event_sethost);
|
||||
Anope::AddMessage("SETIDENT", anope_event_setident);
|
||||
Anope::AddMessage("SETNAME", anope_event_setname);
|
||||
Anope::AddMessage("FJOIN", anope_event_fjoin);
|
||||
Anope::AddMessage("FMODE", anope_event_fmode);
|
||||
Anope::AddMessage("FTOPIC", anope_event_ftopic);
|
||||
Anope::AddMessage("OPERTYPE", anope_event_opertype);
|
||||
Anope::AddMessage("IDLE", anope_event_idle);
|
||||
Anope::AddMessage("METADATA", anope_event_metadata);
|
||||
Anope::AddMessage("ENDBURST", event_endburst);
|
||||
Anope::AddMessage("436", event_436);
|
||||
Anope::AddMessage("AWAY", event_away);
|
||||
Anope::AddMessage("JOIN", event_join);
|
||||
Anope::AddMessage("KICK", event_kick);
|
||||
Anope::AddMessage("KILL", event_kill);
|
||||
Anope::AddMessage("MODE", event_mode);
|
||||
Anope::AddMessage("MOTD", event_motd);
|
||||
Anope::AddMessage("NICK", event_nick);
|
||||
Anope::AddMessage("UID", event_uid);
|
||||
Anope::AddMessage("CAPAB", event_capab);
|
||||
Anope::AddMessage("PART", event_part);
|
||||
Anope::AddMessage("PING", event_ping);
|
||||
Anope::AddMessage("TIME", event_time);
|
||||
Anope::AddMessage("PRIVMSG", event_privmsg);
|
||||
Anope::AddMessage("QUIT", event_quit);
|
||||
Anope::AddMessage("SERVER", event_server);
|
||||
Anope::AddMessage("SQUIT", event_squit);
|
||||
Anope::AddMessage("RSQUIT", event_rsquit);
|
||||
Anope::AddMessage("TOPIC", event_topic);
|
||||
Anope::AddMessage("WHOIS", event_whois);
|
||||
Anope::AddMessage("SVSMODE", event_mode);
|
||||
Anope::AddMessage("FHOST", event_chghost);
|
||||
Anope::AddMessage("FIDENT", event_chgident);
|
||||
Anope::AddMessage("FNAME", event_chgname);
|
||||
Anope::AddMessage("SETHOST", event_sethost);
|
||||
Anope::AddMessage("SETIDENT", event_setident);
|
||||
Anope::AddMessage("SETNAME", event_setname);
|
||||
Anope::AddMessage("FJOIN", event_fjoin);
|
||||
Anope::AddMessage("FMODE", event_fmode);
|
||||
Anope::AddMessage("FTOPIC", event_ftopic);
|
||||
Anope::AddMessage("OPERTYPE", event_opertype);
|
||||
Anope::AddMessage("IDLE", event_idle);
|
||||
Anope::AddMessage("METADATA", event_metadata);
|
||||
}
|
||||
|
||||
bool ChannelModeFlood::IsValid(const Anope::string &value) const
|
||||
|
||||
+176
-200
@@ -276,15 +276,15 @@ class RatboxProto : public IRCDProto
|
||||
}
|
||||
} ircd_proto;
|
||||
|
||||
int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
|
||||
bool event_sjoin(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Channel *c = findchan(av[1]);
|
||||
time_t ts = Anope::string(av[0]).is_pos_number_only() ? convertTo<time_t>(av[0]) : 0;
|
||||
Channel *c = findchan(params[1]);
|
||||
time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0;
|
||||
bool keep_their_modes = true;
|
||||
|
||||
if (!c)
|
||||
{
|
||||
c = new Channel(av[1], ts);
|
||||
c = new Channel(params[1], ts);
|
||||
c->SetFlag(CH_SYNCING);
|
||||
}
|
||||
/* Our creation time is newer than what the server gave us */
|
||||
@@ -301,13 +301,18 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
|
||||
keep_their_modes = false;
|
||||
|
||||
/* If we need to keep their modes, and this SJOIN string contains modes */
|
||||
if (keep_their_modes && ac >= 4)
|
||||
if (keep_their_modes && params.size() >= 3)
|
||||
{
|
||||
Anope::string modes;
|
||||
for (unsigned i = 2; i < params.size() - 1; ++i)
|
||||
modes += " " + params[i];
|
||||
if (!modes.empty())
|
||||
modes.erase(modes.begin());
|
||||
/* Set the modes internally */
|
||||
ChanSetInternalModes(c, ac - 3, av + 2);
|
||||
c->SetModesInternal(NULL, modes);
|
||||
}
|
||||
|
||||
spacesepstream sep(av[ac - 1]);
|
||||
spacesepstream sep(params[params.size() - 1]);
|
||||
Anope::string buf;
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
@@ -369,47 +374,45 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
|
||||
c->Sync();
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
Non TS6
|
||||
|
||||
av[0] = nick
|
||||
av[1] = hop
|
||||
av[2] = ts
|
||||
av[3] = modes
|
||||
av[4] = user
|
||||
av[5] = host
|
||||
av[6] = server
|
||||
av[7] = info
|
||||
params[0] = nick
|
||||
params[1] = hop
|
||||
params[2] = ts
|
||||
params[3] = modes
|
||||
params[4] = user
|
||||
params[5] = host
|
||||
params[6] = server
|
||||
params[7] = info
|
||||
|
||||
TS6
|
||||
av[0] = nick
|
||||
av[1] = hop
|
||||
av[2] = ts
|
||||
av[3] = modes
|
||||
av[4] = user
|
||||
av[5] = host
|
||||
av[6] = IP
|
||||
av[7] = UID
|
||||
av[8] = info
|
||||
params[0] = nick
|
||||
params[1] = hop
|
||||
params[2] = ts
|
||||
params[3] = modes
|
||||
params[4] = user
|
||||
params[5] = host
|
||||
params[6] = IP
|
||||
params[7] = UID
|
||||
params[8] = info
|
||||
|
||||
*/
|
||||
int anope_event_nick(const Anope::string &source, int ac, const char **av)
|
||||
bool event_nick(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *user;
|
||||
|
||||
if (ac == 9)
|
||||
if (params.size() == 9)
|
||||
{
|
||||
Server *s = Server::Find(source);
|
||||
/* Source is always the server */
|
||||
user = do_nick("", av[0], av[4], av[5], s->GetName(), av[8], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, av[6], "*", av[7], av[3]);
|
||||
User *user = do_nick("", params[0], params[4], params[5], s->GetName(), params[8], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, params[6], "*", params[7], params[3]);
|
||||
if (user)
|
||||
{
|
||||
NickAlias *na = findnick(user->nick);
|
||||
Anope::string svidbuf;
|
||||
if (na && na->nc->GetExtRegular("authenticationtoken", svidbuf) && svidbuf == av[2])
|
||||
if (na && na->nc->GetExtRegular("authenticationtoken", svidbuf) && svidbuf == params[2])
|
||||
{
|
||||
user->Login(na->nc);
|
||||
}
|
||||
@@ -417,298 +420,271 @@ int anope_event_nick(const Anope::string &source, int ac, const char **av)
|
||||
validate_user(user);
|
||||
}
|
||||
}
|
||||
else if (ac == 2)
|
||||
do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0, "", "", "", "");
|
||||
return MOD_CONT;
|
||||
else if (params.size() == 2)
|
||||
do_nick(source, params[0], "", "", "", "", Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0, "", "", "", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_topic(const Anope::string &source, int ac, const char **av)
|
||||
bool event_topic(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Channel *c = findchan(av[0]);
|
||||
Channel *c = findchan(params[0]);
|
||||
if (!c)
|
||||
{
|
||||
Log() << "TOPIC for nonexistant channel " << av[0];
|
||||
return MOD_CONT;
|
||||
Log() << "TOPIC for nonexistant channel " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ac == 4)
|
||||
if (params.size() == 4)
|
||||
{
|
||||
c->ChangeTopicInternal(av[1], av[3], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : Anope::CurTime);
|
||||
c->ChangeTopicInternal(params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
c->ChangeTopicInternal(source, (ac > 1 && *av[1] ? av[1] : ""));
|
||||
c->ChangeTopicInternal(source, (params.size() > 1 ? params[1] : ""));
|
||||
}
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_tburst(const Anope::string &source, int ac, const char **av)
|
||||
bool event_tburst(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 4)
|
||||
return MOD_CONT;
|
||||
if (params.size() != 4)
|
||||
return true;
|
||||
|
||||
Anope::string setter = myStrGetToken(av[2], '!', 0);
|
||||
time_t topic_time = Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : Anope::CurTime;
|
||||
Channel *c = findchan(av[0]);
|
||||
Anope::string setter = myStrGetToken(params[2], '!', 0);
|
||||
time_t topic_time = Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : Anope::CurTime;
|
||||
Channel *c = findchan(params[0]);
|
||||
|
||||
if (!c)
|
||||
{
|
||||
Log() << "TOPIC " << merge_args(ac - 1, av + 1) << " for nonexistent channel " << av[0];
|
||||
return MOD_CONT;
|
||||
Log() << "TOPIC " << params[3] << " for nonexistent channel " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
c->ChangeTopicInternal(setter, ac > 3 && *av[3] ? av[3] : "", topic_time);
|
||||
c->ChangeTopicInternal(setter, params.size() > 3 ? params[3] : "", topic_time);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_436(const Anope::string &source, int ac, const char **av)
|
||||
bool event_436(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 1)
|
||||
return true;
|
||||
|
||||
m_nickcoll(av[0]);
|
||||
return MOD_CONT;
|
||||
m_nickcoll(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_ping(const Anope::string &source, int ac, const char **av)
|
||||
bool event_ping(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
ircdproto->SendPong(ac > 1 ? av[1] : Config->ServerName, av[0]);
|
||||
return MOD_CONT;
|
||||
if (params.size() < 1)
|
||||
return true;
|
||||
ircdproto->SendPong(params.size() > 1 ? params[1] : Config->ServerName, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_away(const Anope::string &source, int ac, const char **av)
|
||||
bool event_away(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u = NULL;
|
||||
|
||||
u = finduser(source);
|
||||
m_away(u ? u->nick : source, ac ? av[0] : "");
|
||||
return MOD_CONT;
|
||||
User *u = finduser(source);
|
||||
m_away(u ? u->nick : source, !params.empty() ? params[0] : "");
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_kill(const Anope::string &source, int ac, const char **av)
|
||||
bool event_kill(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
|
||||
m_kill(av[0], av[1]);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 1)
|
||||
m_kill(params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_kick(const Anope::string &source, int ac, const char **av)
|
||||
bool event_kick(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 3)
|
||||
return MOD_CONT;
|
||||
do_kick(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 2)
|
||||
do_kick(source, params[0], params[1], params[2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_join(const Anope::string &source, int ac, const char **av)
|
||||
bool event_join(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 1)
|
||||
{
|
||||
anope_event_sjoin(source, ac, av);
|
||||
return MOD_CONT;
|
||||
}
|
||||
if (params.size() != 1)
|
||||
event_sjoin(source, params);
|
||||
else
|
||||
do_join(source, ac, av);
|
||||
return MOD_CONT;
|
||||
do_join(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_motd(const Anope::string &source, int ac, const char **av)
|
||||
bool event_motd(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (source.empty())
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
|
||||
m_motd(source);
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_privmsg(const Anope::string &source, int ac, const char **av)
|
||||
bool event_privmsg(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
|
||||
// XXX: this is really the same as charybdis
|
||||
m_privmsg(source, av[0], av[1]);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 1)
|
||||
m_privmsg(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_part(const Anope::string &source, int ac, const char **av)
|
||||
bool event_part(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (!params.empty())
|
||||
do_part(source, params[0], params.size() > 1 ? params[1] : "");
|
||||
|
||||
if (ac < 1 || ac > 2)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(source);
|
||||
do_part(u ? u->nick : source, ac, av);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_whois(const Anope::string &source, int ac, const char **av)
|
||||
bool event_whois(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!source.empty() && ac >= 1)
|
||||
if (!source.empty() && !params.empty())
|
||||
{
|
||||
BotInfo *bi = findbot(av[0]);
|
||||
m_whois(source, bi->GetUID());
|
||||
m_whois(source, params[0]);
|
||||
}
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT: SERVER */
|
||||
int anope_event_server(const Anope::string &source, int ac, const char **av)
|
||||
bool event_server(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!stricmp(av[1], "1"))
|
||||
do_server(source, av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo<unsigned>(av[1]) : 0, av[2], TS6UPLINK);
|
||||
if (params[1].equals_cs("1"))
|
||||
do_server(source, params[0], Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, params[2], TS6UPLINK);
|
||||
else
|
||||
do_server(source, av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo<unsigned>(av[1]) : 0, av[2], "");
|
||||
return MOD_CONT;
|
||||
do_server(source, params[0], Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, params[2], "");
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_sid(const Anope::string &source, int ac, const char **av)
|
||||
bool event_sid(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
/* :42X SID trystan.nomadirc.net 2 43X :ircd-ratbox test server */
|
||||
Server *s = Server::Find(source);
|
||||
|
||||
do_server(s->GetName(), av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo<unsigned>(av[1]) : 0, av[3], av[2]);
|
||||
return MOD_CONT;
|
||||
do_server(s->GetName(), params[0], Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, params[3], params[2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_squit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_squit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
|
||||
do_squit(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
do_squit(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_quit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_quit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
User *u = finduser(source);
|
||||
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(source);
|
||||
|
||||
do_quit(u ? u->nick : source, ac, av);
|
||||
return MOD_CONT;
|
||||
do_quit(u ? u->nick : source, !params.empty() ? params[0] : "");
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_mode(const Anope::string &source, int ac, const char **av)
|
||||
bool event_mode(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u, *u2;
|
||||
if (params.size() < 2)
|
||||
return true;
|
||||
|
||||
if (ac < 2)
|
||||
return MOD_CONT;
|
||||
|
||||
if (*av[0] == '#' || *av[0] == '&')
|
||||
do_cmode(source, ac, av);
|
||||
if (params[0][0] == '#' || params[0][0] == '&')
|
||||
do_cmode(source, params[0], params[2], params[1]);
|
||||
else
|
||||
{
|
||||
u = finduser(source);
|
||||
u2 = finduser(av[0]);
|
||||
av[0] = u2->nick.c_str();
|
||||
do_umode(u->nick, ac, av);
|
||||
User *u = finduser(source);
|
||||
User *u2 = finduser(params[0]);
|
||||
if (!u || !u2)
|
||||
return true;
|
||||
do_umode(u->nick, u2->nick, params[1]);
|
||||
}
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_tmode(const Anope::string &source, int ac, const char **av)
|
||||
bool event_tmode(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (*av[1] == '#' || *av[1] == '&')
|
||||
do_cmode(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (params[1][0] == '#' || params[1][0] == '&')
|
||||
do_cmode(source, params[0], params[1], params[2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Event: PROTOCTL */
|
||||
int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
bool event_capab(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
CapabParse(ac, av);
|
||||
return MOD_CONT;
|
||||
CapabParse(params);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_pass(const Anope::string &source, int ac, const char **av)
|
||||
bool event_pass(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
TS6UPLINK = av[3];
|
||||
return MOD_CONT;
|
||||
TS6UPLINK = params[3];
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_bmask(const Anope::string &source, int ac, const char **av)
|
||||
bool event_bmask(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Channel *c;
|
||||
ChannelModeList *cms;
|
||||
|
||||
/* :42X BMASK 1106409026 #ircops b :*!*@*.aol.com */
|
||||
/* 0 1 2 3 */
|
||||
c = findchan(av[1]);
|
||||
Channel *c = findchan(params[1]);
|
||||
|
||||
if (c)
|
||||
{
|
||||
Anope::string bans = av[3];
|
||||
Anope::string bans = params[3];
|
||||
int count = myNumToken(bans, ' '), i;
|
||||
for (i = 0; i <= count - 1; ++i)
|
||||
{
|
||||
Anope::string b = myStrGetToken(bans, ' ', i);
|
||||
if (!stricmp(av[2], "b"))
|
||||
if (params[2].equals_cs("b"))
|
||||
{
|
||||
cms = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('b'));
|
||||
cms->AddMask(c, b);
|
||||
ChannelModeList *cml = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('b'));
|
||||
cml->AddMask(c, b);
|
||||
}
|
||||
if (!stricmp(av[2], "e"))
|
||||
else if (params[2].equals_cs("e"))
|
||||
{
|
||||
cms = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('e'));
|
||||
cms->AddMask(c, b);
|
||||
ChannelModeList *cml = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('e'));
|
||||
cml->AddMask(c, b);
|
||||
}
|
||||
if (!stricmp(av[2], "I"))
|
||||
if (params[2].equals_cs("I"))
|
||||
{
|
||||
cms = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('I'));
|
||||
cms->AddMask(c, b);
|
||||
ChannelModeList *cml = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('I'));
|
||||
cml->AddMask(c, b);
|
||||
}
|
||||
}
|
||||
}
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_error(const Anope::string &source, int ac, const char **av)
|
||||
bool event_error(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac >= 1)
|
||||
Log(LOG_DEBUG) << av[0];
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
Log(LOG_DEBUG) << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
void moduleAddIRCDMsgs()
|
||||
{
|
||||
Anope::AddMessage("436", anope_event_436);
|
||||
Anope::AddMessage("AWAY", anope_event_away);
|
||||
Anope::AddMessage("JOIN", anope_event_join);
|
||||
Anope::AddMessage("KICK", anope_event_kick);
|
||||
Anope::AddMessage("KILL", anope_event_kill);
|
||||
Anope::AddMessage("MODE", anope_event_mode);
|
||||
Anope::AddMessage("TMODE", anope_event_tmode);
|
||||
Anope::AddMessage("MOTD", anope_event_motd);
|
||||
Anope::AddMessage("NICK", anope_event_nick);
|
||||
Anope::AddMessage("BMASK", anope_event_bmask);
|
||||
Anope::AddMessage("UID", anope_event_nick);
|
||||
Anope::AddMessage("PART", anope_event_part);
|
||||
Anope::AddMessage("PASS", anope_event_pass);
|
||||
Anope::AddMessage("PING", anope_event_ping);
|
||||
Anope::AddMessage("PRIVMSG", anope_event_privmsg);
|
||||
Anope::AddMessage("QUIT", anope_event_quit);
|
||||
Anope::AddMessage("SERVER", anope_event_server);
|
||||
Anope::AddMessage("SQUIT", anope_event_squit);
|
||||
Anope::AddMessage("TOPIC", anope_event_topic);
|
||||
Anope::AddMessage("TB", anope_event_tburst);
|
||||
Anope::AddMessage("WHOIS", anope_event_whois);
|
||||
Anope::AddMessage("CAPAB", anope_event_capab);
|
||||
Anope::AddMessage("SJOIN", anope_event_sjoin);
|
||||
Anope::AddMessage("ERROR", anope_event_error);
|
||||
Anope::AddMessage("SID", anope_event_sid);
|
||||
Anope::AddMessage("436", event_436);
|
||||
Anope::AddMessage("AWAY", event_away);
|
||||
Anope::AddMessage("JOIN", event_join);
|
||||
Anope::AddMessage("KICK", event_kick);
|
||||
Anope::AddMessage("KILL", event_kill);
|
||||
Anope::AddMessage("MODE", event_mode);
|
||||
Anope::AddMessage("TMODE", event_tmode);
|
||||
Anope::AddMessage("MOTD", event_motd);
|
||||
Anope::AddMessage("NICK", event_nick);
|
||||
Anope::AddMessage("BMASK", event_bmask);
|
||||
Anope::AddMessage("UID", event_nick);
|
||||
Anope::AddMessage("PART", event_part);
|
||||
Anope::AddMessage("PASS", event_pass);
|
||||
Anope::AddMessage("PING", event_ping);
|
||||
Anope::AddMessage("PRIVMSG", event_privmsg);
|
||||
Anope::AddMessage("QUIT", event_quit);
|
||||
Anope::AddMessage("SERVER", event_server);
|
||||
Anope::AddMessage("SQUIT", event_squit);
|
||||
Anope::AddMessage("TOPIC", event_topic);
|
||||
Anope::AddMessage("TB", event_tburst);
|
||||
Anope::AddMessage("WHOIS", event_whois);
|
||||
Anope::AddMessage("CAPAB", event_capab);
|
||||
Anope::AddMessage("SJOIN", event_sjoin);
|
||||
Anope::AddMessage("ERROR", event_error);
|
||||
Anope::AddMessage("SID", event_sid);
|
||||
}
|
||||
|
||||
static void AddModes()
|
||||
|
||||
+273
-303
@@ -45,11 +45,6 @@ IRCDVar myIrcd[] = {
|
||||
{NULL}
|
||||
};
|
||||
|
||||
void unreal_cmd_netinfo(int ac, const char **av)
|
||||
{
|
||||
send_cmd("", "AO %ld %ld %d %s 0 0 0 :%s", static_cast<long>(maxusercnt), static_cast<long>(Anope::CurTime), Anope::string(av[2]).is_number_only() ? convertTo<int>(av[2]) : 0, av[3], av[7]);
|
||||
}
|
||||
|
||||
/* PROTOCTL */
|
||||
/*
|
||||
NICKv2 = Nick Version 2
|
||||
@@ -393,11 +388,11 @@ class UnrealIRCdProto : public IRCDProto
|
||||
} ircd_proto;
|
||||
|
||||
/* Event: PROTOCTL */
|
||||
int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
bool event_capab(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
for (int i = 0; i < ac; ++i)
|
||||
for (unsigned i = 0; i < params.size(); ++i)
|
||||
{
|
||||
Anope::string capab = av[i];
|
||||
Anope::string capab = params[i];
|
||||
|
||||
if (capab.find("CHANMODES") != Anope::string::npos)
|
||||
{
|
||||
@@ -537,35 +532,34 @@ int anope_event_capab(const Anope::string &source, int ac, const char **av)
|
||||
}
|
||||
}
|
||||
|
||||
CapabParse(ac, av);
|
||||
CapabParse(params);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Events */
|
||||
int anope_event_ping(const Anope::string &source, int ac, const char **av)
|
||||
bool event_ping(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
ircdproto->SendPong(ac > 1 ? av[1] : Config->ServerName, av[0]);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
ircdproto->SendPong(params.size() > 1 ? params[1] : Config->ServerName, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/** This is here because:
|
||||
*
|
||||
* If we had servers three servers, A, B & C linked like so: A<->B<->C
|
||||
* If Anope is (linked to) A and B splits from A and then reconnects
|
||||
* If Anope is linked to A and B splits from A and then reconnects
|
||||
* B introduces itself, introduces C, sends EOS for C, introduces Bs clients
|
||||
* introduces Cs clients, sends EOS for B. This causes all of Cs clients to be introduced
|
||||
* with their server "not syncing". We now send a PING immediatly when receiving a new server
|
||||
* and then finish sync once we get a pong back from that server
|
||||
*/
|
||||
int anope_event_pong(const Anope::string &source, int ac, const char **av)
|
||||
bool event_pong(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Server *s = Server::Find(source);
|
||||
if (s && !s->IsSynced())
|
||||
s->Sync(false);
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* netinfo
|
||||
@@ -578,19 +572,17 @@ int anope_event_pong(const Anope::string &source, int ac, const char **av)
|
||||
* argv[6] = free(**)
|
||||
* argv[7] = ircnet
|
||||
*/
|
||||
int anope_event_netinfo(const Anope::string &source, int ac, const char **av)
|
||||
bool event_netinfo(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
unreal_cmd_netinfo(ac, av);
|
||||
return MOD_CONT;
|
||||
send_cmd("", "AO %ld %ld %d %s 0 0 0 :%s", static_cast<long>(maxusercnt), static_cast<long>(Anope::CurTime), Anope::string(params[2]).is_number_only() ? convertTo<int>(params[2]) : 0, params[3].c_str(), params[7].c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_436(const Anope::string &source, int ac, const char **av)
|
||||
bool event_436(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
|
||||
m_nickcoll(av[0]);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
m_nickcoll(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -598,12 +590,12 @@ int anope_event_436(const Anope::string &source, int ac, const char **av)
|
||||
** parv[0] = sender prefix
|
||||
** parv[1] = away message
|
||||
*/
|
||||
int anope_event_away(const Anope::string &source, int ac, const char **av)
|
||||
bool event_away(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (source.empty())
|
||||
return MOD_CONT;
|
||||
m_away(source, ac ? av[0] : "");
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
m_away(source, !params.empty() ? params[0] : "");
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -614,57 +606,52 @@ int anope_event_away(const Anope::string &source, int ac, const char **av)
|
||||
** parv[2] = topic time
|
||||
** parv[3] = topic text
|
||||
*/
|
||||
int anope_event_topic(const Anope::string &source, int ac, const char **av)
|
||||
bool event_topic(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 4)
|
||||
return MOD_CONT;
|
||||
if (params.size() != 4)
|
||||
return true;
|
||||
|
||||
Channel *c = findchan(av[0]);
|
||||
Channel *c = findchan(params[0]);
|
||||
if (!c)
|
||||
{
|
||||
Log() << "TOPIC for nonexistant channel " << av[0];
|
||||
return MOD_CONT;
|
||||
Log() << "TOPIC for nonexistant channel " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
c->ChangeTopicInternal(av[1], av[3], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : Anope::CurTime);
|
||||
c->ChangeTopicInternal(params[1], params[3], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_squit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_squit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
do_squit(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (params.size() != 2)
|
||||
do_squit(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_quit(const Anope::string &source, int ac, const char **av)
|
||||
bool event_quit(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
do_quit(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
do_quit(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_mode(const Anope::string &source, int ac, const char **av)
|
||||
bool event_mode(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 2)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 2)
|
||||
return true;
|
||||
|
||||
bool server_source = Server::Find(source) != NULL;
|
||||
Anope::string modes = params[1];
|
||||
for (unsigned i = 2; i < params.size() - (server_source ? 1 : 0); ++i)
|
||||
modes += " " + params[i];
|
||||
|
||||
if (*av[0] == '#' || *av[0] == '&')
|
||||
do_cmode(source, ac, av);
|
||||
if (params[0][0] == '#' || params[0][0] == '&')
|
||||
do_cmode(source, params[0], modes, server_source ? params[params.size() - 1] : "");
|
||||
else
|
||||
do_umode(source, ac, av);
|
||||
return MOD_CONT;
|
||||
}
|
||||
|
||||
/* This is used to strip the TS from the end of the mode stirng */
|
||||
int anope_event_gmode(const Anope::string &source, int ac, const char **av)
|
||||
{
|
||||
if (Server::Find(source))
|
||||
--ac;
|
||||
return anope_event_mode(source, ac, av);
|
||||
do_umode(source, params[0], modes);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Unreal sends USER modes with this */
|
||||
@@ -673,145 +660,129 @@ int anope_event_gmode(const Anope::string &source, int ac, const char **av)
|
||||
parv[0] - sender
|
||||
parv[1] - modes to change
|
||||
*/
|
||||
int anope_event_umode2(const Anope::string &source, int ac, const char **av)
|
||||
bool event_umode2(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 1)
|
||||
return true;
|
||||
|
||||
const char *newav[2];
|
||||
newav[0] = source.c_str();
|
||||
newav[1] = av[0];
|
||||
do_umode(source, 2, newav);
|
||||
return MOD_CONT;
|
||||
do_umode(source, source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_kill(const Anope::string &source, int ac, const char **av)
|
||||
bool event_kill(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
if (params.size() != 2)
|
||||
return true;
|
||||
|
||||
m_kill(av[0], av[1]);
|
||||
return MOD_CONT;
|
||||
m_kill(params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_kick(const Anope::string &source, int ac, const char **av)
|
||||
bool event_kick(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 3)
|
||||
return MOD_CONT;
|
||||
do_kick(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (params.size() != 3)
|
||||
return true;
|
||||
do_kick(source, params[0], params[1], params[2]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_join(const Anope::string &source, int ac, const char **av)
|
||||
bool event_join(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
do_join(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (!params.empty())
|
||||
do_join(source, params[0], "");
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_motd(const Anope::string &source, int ac, const char **av)
|
||||
bool event_motd(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (source.empty())
|
||||
return MOD_CONT;
|
||||
|
||||
m_motd(source);
|
||||
return MOD_CONT;
|
||||
if (!source.empty())
|
||||
m_motd(source);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_setname(const Anope::string &source, int ac, const char **av)
|
||||
bool event_setname(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (params.size() != 1)
|
||||
return true;
|
||||
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(source);
|
||||
User *u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "SETNAME for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetRealname(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetRealname(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_chgname(const Anope::string &source, int ac, const char **av)
|
||||
bool event_chgname(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (params.size() != 2)
|
||||
return true;
|
||||
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(av[0]);
|
||||
User *u = finduser(params[0]);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "CHGNAME for nonexistent user " << av[0];
|
||||
return MOD_CONT;
|
||||
Log(LOG_DEBUG) << "CHGNAME for nonexistent user " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetRealname(av[1]);
|
||||
return MOD_CONT;
|
||||
u->SetRealname(params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_setident(const Anope::string &source, int ac, const char **av)
|
||||
bool event_setident(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (params.size() != 1)
|
||||
return true;
|
||||
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(source);
|
||||
User *u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "SETIDENT for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetVIdent(av[0]);
|
||||
return MOD_CONT;
|
||||
u->SetVIdent(params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_chgident(const Anope::string &source, int ac, const char **av)
|
||||
bool event_chgident(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (params.size() != 2)
|
||||
return true;
|
||||
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(av[0]);
|
||||
User *u = finduser(params[0]);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "CHGIDENT for nonexistent user " << av[0];
|
||||
return MOD_CONT;
|
||||
Log(LOG_DEBUG) << "CHGIDENT for nonexistent user " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetVIdent(av[1]);
|
||||
return MOD_CONT;
|
||||
u->SetVIdent(params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_sethost(const Anope::string &source, int ac, const char **av)
|
||||
bool event_sethost(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (params.size() != 1)
|
||||
return true;
|
||||
|
||||
if (ac != 1)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(source);
|
||||
User *u = finduser(source);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "SETHOST for nonexistent user " << source;
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* When a user sets +x we recieve the new host and then the mode change */
|
||||
if (u->HasMode(UMODE_CLOAK))
|
||||
u->SetDisplayedHost(av[0]);
|
||||
u->SetDisplayedHost(params[0]);
|
||||
else
|
||||
u->SetCloakedHost(av[0]);
|
||||
u->SetCloakedHost(params[0]);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -840,161 +811,155 @@ int anope_event_sethost(const Anope::string &source, int ac, const char **av)
|
||||
** parv[0] = new nickname
|
||||
** parv[1] = hopcount
|
||||
*/
|
||||
int anope_event_nick(const Anope::string &source, int ac, const char **av)
|
||||
bool event_nick(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *user;
|
||||
|
||||
if (ac != 2)
|
||||
if (params.size() == 7)
|
||||
{
|
||||
if (ac == 7)
|
||||
{
|
||||
/*
|
||||
<codemastr> that was a bug that is now fixed in 3.2.1
|
||||
<codemastr> in some instances it would use the non-nickv2 format
|
||||
<codemastr> it's sent when a nick collision occurs
|
||||
- so we have to leave it around for now -TSL
|
||||
*/
|
||||
do_nick(source, av[0], av[3], av[4], av[5], av[6], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, "", "*", "", "");
|
||||
}
|
||||
else if (ac == 11)
|
||||
{
|
||||
Anope::string decoded_ip;
|
||||
b64_decode(av[9], decoded_ip);
|
||||
/*
|
||||
<codemastr> that was a bug that is now fixed in 3.2.1
|
||||
<codemastr> in some instances it would use the non-nickv2 format
|
||||
<codemastr> it's sent when a nick collision occurs
|
||||
- so we have to leave it around for now -TSL
|
||||
*/
|
||||
do_nick(source, params[0], params[3], params[4], params[5], params[6], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, "", "*", "", "");
|
||||
}
|
||||
else if (params.size() == 11)
|
||||
{
|
||||
Anope::string decoded_ip;
|
||||
b64_decode(params[9], decoded_ip);
|
||||
|
||||
sockaddrs ip;
|
||||
ip.ntop(strlen(av[9]) == 8 ? AF_INET : AF_INET6, decoded_ip.c_str());
|
||||
sockaddrs ip;
|
||||
ip.ntop(params[9].length() == 8 ? AF_INET : AF_INET6, decoded_ip.c_str());
|
||||
|
||||
if (av[8] && !strcmp(av[8], "*"))
|
||||
av[8] = "";
|
||||
Anope::string vhost = params[8];
|
||||
if (vhost.equals_cs("*"))
|
||||
vhost.clear();
|
||||
|
||||
user = do_nick(source, av[0], av[3], av[4], av[5], av[10], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, ip.addr(), av[8], "", av[7]);
|
||||
if (user)
|
||||
{
|
||||
NickAlias *na = findnick(user->nick);
|
||||
|
||||
if (na && user->timestamp == convertTo<time_t>(av[6]))
|
||||
{
|
||||
user->Login(na->nc);
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
else
|
||||
validate_user(user);
|
||||
}
|
||||
}
|
||||
else
|
||||
User *user = do_nick(source, params[0], params[3], params[4], params[5], params[10], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, ip.addr(), vhost, "", params[7]);
|
||||
if (user)
|
||||
{
|
||||
if (av[8] && !strcmp(av[8], "*"))
|
||||
av[8] = "";
|
||||
NickAlias *na = findnick(user->nick);
|
||||
|
||||
/* NON NICKIP */
|
||||
user = do_nick(source, av[0], av[3], av[4], av[5], av[9], Anope::string(av[2]).is_pos_number_only() ? convertTo<time_t>(av[2]) : 0, "", av[8], "", av[7]);
|
||||
if (user)
|
||||
if (na && user->timestamp == convertTo<time_t>(params[6]))
|
||||
{
|
||||
NickAlias *na = findnick(user->nick);
|
||||
|
||||
if (na && user->timestamp == convertTo<time_t>(av[6]))
|
||||
{
|
||||
user->Login(na->nc);
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
else
|
||||
validate_user(user);
|
||||
user->Login(na->nc);
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
else
|
||||
validate_user(user);
|
||||
}
|
||||
}
|
||||
else if (params.size() != 2)
|
||||
{
|
||||
Anope::string vhost = params[8];
|
||||
if (vhost.equals_cs("*"))
|
||||
vhost.clear();
|
||||
|
||||
/* NON NICKIP */
|
||||
User *user = do_nick(source, params[0], params[3], params[4], params[5], params[9], Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : 0, "", vhost, "", params[7]);
|
||||
if (user)
|
||||
{
|
||||
NickAlias *na = findnick(user->nick);
|
||||
|
||||
if (na && user->timestamp == convertTo<time_t>(params[6]))
|
||||
{
|
||||
user->Login(na->nc);
|
||||
user->SetMode(NickServ, UMODE_REGISTERED);
|
||||
}
|
||||
else
|
||||
validate_user(user);
|
||||
}
|
||||
}
|
||||
else
|
||||
do_nick(source, av[0], "", "", "", "", Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0, "", "", "", "");
|
||||
return MOD_CONT;
|
||||
do_nick(source, params[0], "", "", "", "", Anope::string(params[1]).is_pos_number_only() ? convertTo<time_t>(params[1]) : 0, "", "", "", "");
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_chghost(const Anope::string &source, int ac, const char **av)
|
||||
bool event_chghost(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
User *u;
|
||||
if (params.size() != 2)
|
||||
return true;
|
||||
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
|
||||
u = finduser(av[0]);
|
||||
User *u = finduser(params[0]);
|
||||
if (!u)
|
||||
{
|
||||
Log(LOG_DEBUG) << "debug: CHGHOST for nonexistent user " << av[0];
|
||||
return MOD_CONT;
|
||||
Log(LOG_DEBUG) << "debug: CHGHOST for nonexistent user " << params[0];
|
||||
return true;
|
||||
}
|
||||
|
||||
u->SetDisplayedHost(av[1]);
|
||||
return MOD_CONT;
|
||||
u->SetDisplayedHost(params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/* EVENT: SERVER */
|
||||
int anope_event_server(const Anope::string &source, int ac, const char **av)
|
||||
bool event_server(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!stricmp(av[1], "1"))
|
||||
if (params[1].equals_cs("1"))
|
||||
{
|
||||
Anope::string vl = myStrGetToken(av[2], ' ', 0);
|
||||
Anope::string vl = myStrGetToken(params[2], ' ', 0);
|
||||
Anope::string upnumeric = myStrGetToken(vl, '-', 2);
|
||||
Anope::string desc = myStrGetTokenRemainder(av[2], ' ', 1);
|
||||
do_server(source, av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo<unsigned>(av[1]) : 0, desc, upnumeric);
|
||||
Anope::string desc = myStrGetTokenRemainder(params[2], ' ', 1);
|
||||
do_server(source, params[0], Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, desc, upnumeric);
|
||||
}
|
||||
else
|
||||
do_server(source, av[0], Anope::string(av[1]).is_pos_number_only() ? convertTo<unsigned>(av[1]) : 0, av[2], "");
|
||||
ircdproto->SendPing(Config->ServerName, av[0]);
|
||||
do_server(source, params[0], Anope::string(params[1]).is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0, params[2], "");
|
||||
ircdproto->SendPing(Config->ServerName, params[0]);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_privmsg(const Anope::string &source, int ac, const char **av)
|
||||
bool event_privmsg(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac != 2)
|
||||
return MOD_CONT;
|
||||
m_privmsg(source, av[0], av[1]);
|
||||
return MOD_CONT;
|
||||
if (params.size() > 1)
|
||||
m_privmsg(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_part(const Anope::string &source, int ac, const char **av)
|
||||
bool event_part(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1 || ac > 2)
|
||||
return MOD_CONT;
|
||||
do_part(source, ac, av);
|
||||
return MOD_CONT;
|
||||
if (params.size() < 1 || params.size() > 2)
|
||||
return true;
|
||||
do_part(source, params[0], params[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_whois(const Anope::string &source, int ac, const char **av)
|
||||
bool event_whois(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (!source.empty() && ac >= 1)
|
||||
m_whois(source, av[0]);
|
||||
return MOD_CONT;
|
||||
if (!source.empty() && !params.empty())
|
||||
m_whois(source, params[0]);
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_error(const Anope::string &source, int ac, const char **av)
|
||||
bool event_error(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (av[0])
|
||||
if (!params.empty())
|
||||
{
|
||||
Log(LOG_DEBUG) << av[0];
|
||||
if (strstr(av[0], "No matching link configuration"))
|
||||
Log(LOG_DEBUG) << params[0];
|
||||
if (params[0].find("No matching link configuration") != Anope::string::npos)
|
||||
Log() << "Error: Your IRCD's link block may not be setup correctly, please check unrealircd.conf";
|
||||
}
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_sdesc(const Anope::string &source, int ac, const char **av)
|
||||
bool event_sdesc(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Server *s = Server::Find(source);
|
||||
|
||||
if (s)
|
||||
s->SetDescription(av[0]);
|
||||
s->SetDescription(params[0]);
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
|
||||
bool event_sjoin(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
Channel *c = findchan(av[1]);
|
||||
time_t ts = Anope::string(av[0]).is_pos_number_only() ? convertTo<time_t>(av[0]) : 0;
|
||||
Channel *c = findchan(params[1]);
|
||||
time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0;
|
||||
bool keep_their_modes = true;
|
||||
|
||||
if (!c)
|
||||
{
|
||||
c = new Channel(av[1], ts);
|
||||
c = new Channel(params[1], ts);
|
||||
c->SetFlag(CH_SYNCING);
|
||||
}
|
||||
/* Our creation time is newer than what the server gave us */
|
||||
@@ -1011,13 +976,18 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
|
||||
keep_their_modes = false;
|
||||
|
||||
/* If we need to keep their modes, and this SJOIN string contains modes */
|
||||
if (keep_their_modes && ac >= 4)
|
||||
if (keep_their_modes && params.size() >= 4)
|
||||
{
|
||||
Anope::string modes;
|
||||
for (unsigned i = 2; i < params.size() - 1; ++i)
|
||||
modes += " " + params[i];
|
||||
if (!modes.empty())
|
||||
modes.erase(modes.begin());
|
||||
/* Set the modes internally */
|
||||
ChanSetInternalModes(c, ac - 3, av + 2);
|
||||
c->SetModesInternal(NULL, modes);
|
||||
}
|
||||
|
||||
spacesepstream sep(av[ac - 1]);
|
||||
spacesepstream sep(params[params.size() - 1]);
|
||||
Anope::string buf;
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
@@ -1109,72 +1079,72 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
|
||||
c->Sync();
|
||||
}
|
||||
|
||||
return MOD_CONT;
|
||||
return true;
|
||||
}
|
||||
|
||||
void moduleAddIRCDMsgs()
|
||||
{
|
||||
Anope::AddMessage("436", anope_event_436);
|
||||
Anope::AddMessage("AWAY", anope_event_away);
|
||||
Anope::AddMessage("6", anope_event_away);
|
||||
Anope::AddMessage("JOIN", anope_event_join);
|
||||
Anope::AddMessage("C", anope_event_join);
|
||||
Anope::AddMessage("KICK", anope_event_kick);
|
||||
Anope::AddMessage("H", anope_event_kick);
|
||||
Anope::AddMessage("KILL", anope_event_kill);
|
||||
Anope::AddMessage(".", anope_event_kill);
|
||||
Anope::AddMessage("MODE", anope_event_mode);
|
||||
Anope::AddMessage("G", anope_event_gmode);
|
||||
Anope::AddMessage("MOTD", anope_event_motd);
|
||||
Anope::AddMessage("F", anope_event_motd);
|
||||
Anope::AddMessage("NICK", anope_event_nick);
|
||||
Anope::AddMessage("&", anope_event_nick);
|
||||
Anope::AddMessage("PART", anope_event_part);
|
||||
Anope::AddMessage("D", anope_event_part);
|
||||
Anope::AddMessage("PING", anope_event_ping);
|
||||
Anope::AddMessage("8", anope_event_ping);
|
||||
Anope::AddMessage("PONG", anope_event_pong);
|
||||
Anope::AddMessage("9", anope_event_pong);
|
||||
Anope::AddMessage("PRIVMSG", anope_event_privmsg);
|
||||
Anope::AddMessage("!", anope_event_privmsg);
|
||||
Anope::AddMessage("QUIT", anope_event_quit);
|
||||
Anope::AddMessage(",", anope_event_quit);
|
||||
Anope::AddMessage("SERVER", anope_event_server);
|
||||
Anope::AddMessage("'", anope_event_server);
|
||||
Anope::AddMessage("SQUIT", anope_event_squit);
|
||||
Anope::AddMessage("-", anope_event_squit);
|
||||
Anope::AddMessage("TOPIC", anope_event_topic);
|
||||
Anope::AddMessage(")", anope_event_topic);
|
||||
Anope::AddMessage("SVSMODE", anope_event_mode);
|
||||
Anope::AddMessage("n", anope_event_mode);
|
||||
Anope::AddMessage("SVS2MODE", anope_event_mode);
|
||||
Anope::AddMessage("v", anope_event_mode);
|
||||
Anope::AddMessage("WHOIS", anope_event_whois);
|
||||
Anope::AddMessage("#", anope_event_whois);
|
||||
Anope::AddMessage("PROTOCTL", anope_event_capab);
|
||||
Anope::AddMessage("_", anope_event_capab);
|
||||
Anope::AddMessage("CHGHOST", anope_event_chghost);
|
||||
Anope::AddMessage("AL", anope_event_chghost);
|
||||
Anope::AddMessage("CHGIDENT", anope_event_chgident);
|
||||
Anope::AddMessage("AZ", anope_event_chgident);
|
||||
Anope::AddMessage("CHGNAME", anope_event_chgname);
|
||||
Anope::AddMessage("BK", anope_event_chgname);
|
||||
Anope::AddMessage("NETINFO", anope_event_netinfo);
|
||||
Anope::AddMessage("AO", anope_event_netinfo);
|
||||
Anope::AddMessage("SETHOST", anope_event_sethost);
|
||||
Anope::AddMessage("AA", anope_event_sethost);
|
||||
Anope::AddMessage("SETIDENT", anope_event_setident);
|
||||
Anope::AddMessage("AD", anope_event_setident);
|
||||
Anope::AddMessage("SETNAME", anope_event_setname);
|
||||
Anope::AddMessage("AE", anope_event_setname);
|
||||
Anope::AddMessage("ERROR", anope_event_error);
|
||||
Anope::AddMessage("5", anope_event_error);
|
||||
Anope::AddMessage("UMODE2", anope_event_umode2);
|
||||
Anope::AddMessage("|", anope_event_umode2);
|
||||
Anope::AddMessage("SJOIN", anope_event_sjoin);
|
||||
Anope::AddMessage("~", anope_event_sjoin);
|
||||
Anope::AddMessage("SDESC", anope_event_sdesc);
|
||||
Anope::AddMessage("AG", anope_event_sdesc);
|
||||
Anope::AddMessage("436", event_436);
|
||||
Anope::AddMessage("AWAY", event_away);
|
||||
Anope::AddMessage("6", event_away);
|
||||
Anope::AddMessage("JOIN", event_join);
|
||||
Anope::AddMessage("C", event_join);
|
||||
Anope::AddMessage("KICK", event_kick);
|
||||
Anope::AddMessage("H", event_kick);
|
||||
Anope::AddMessage("KILL", event_kill);
|
||||
Anope::AddMessage(".", event_kill);
|
||||
Anope::AddMessage("MODE", event_mode);
|
||||
Anope::AddMessage("G", event_mode);
|
||||
Anope::AddMessage("MOTD", event_motd);
|
||||
Anope::AddMessage("F", event_motd);
|
||||
Anope::AddMessage("NICK", event_nick);
|
||||
Anope::AddMessage("&", event_nick);
|
||||
Anope::AddMessage("PART", event_part);
|
||||
Anope::AddMessage("D", event_part);
|
||||
Anope::AddMessage("PING", event_ping);
|
||||
Anope::AddMessage("8", event_ping);
|
||||
Anope::AddMessage("PONG", event_pong);
|
||||
Anope::AddMessage("9", event_pong);
|
||||
Anope::AddMessage("PRIVMSG", event_privmsg);
|
||||
Anope::AddMessage("!", event_privmsg);
|
||||
Anope::AddMessage("QUIT", event_quit);
|
||||
Anope::AddMessage(",", event_quit);
|
||||
Anope::AddMessage("SERVER", event_server);
|
||||
Anope::AddMessage("'", event_server);
|
||||
Anope::AddMessage("SQUIT", event_squit);
|
||||
Anope::AddMessage("-", event_squit);
|
||||
Anope::AddMessage("TOPIC", event_topic);
|
||||
Anope::AddMessage(")", event_topic);
|
||||
Anope::AddMessage("SVSMODE", event_mode);
|
||||
Anope::AddMessage("n", event_mode);
|
||||
Anope::AddMessage("SVS2MODE", event_mode);
|
||||
Anope::AddMessage("v", event_mode);
|
||||
Anope::AddMessage("WHOIS", event_whois);
|
||||
Anope::AddMessage("#", event_whois);
|
||||
Anope::AddMessage("PROTOCTL", event_capab);
|
||||
Anope::AddMessage("_", event_capab);
|
||||
Anope::AddMessage("CHGHOST", event_chghost);
|
||||
Anope::AddMessage("AL", event_chghost);
|
||||
Anope::AddMessage("CHGIDENT", event_chgident);
|
||||
Anope::AddMessage("AZ", event_chgident);
|
||||
Anope::AddMessage("CHGNAME", event_chgname);
|
||||
Anope::AddMessage("BK", event_chgname);
|
||||
Anope::AddMessage("NETINFO", event_netinfo);
|
||||
Anope::AddMessage("AO", event_netinfo);
|
||||
Anope::AddMessage("SETHOST", event_sethost);
|
||||
Anope::AddMessage("AA", event_sethost);
|
||||
Anope::AddMessage("SETIDENT", event_setident);
|
||||
Anope::AddMessage("AD", event_setident);
|
||||
Anope::AddMessage("SETNAME", event_setname);
|
||||
Anope::AddMessage("AE", event_setname);
|
||||
Anope::AddMessage("ERROR", event_error);
|
||||
Anope::AddMessage("5", event_error);
|
||||
Anope::AddMessage("UMODE2", event_umode2);
|
||||
Anope::AddMessage("|", event_umode2);
|
||||
Anope::AddMessage("SJOIN", event_sjoin);
|
||||
Anope::AddMessage("~", event_sjoin);
|
||||
Anope::AddMessage("SDESC", event_sdesc);
|
||||
Anope::AddMessage("AG", event_sdesc);
|
||||
|
||||
/* The non token version of these is in messages.c */
|
||||
Anope::AddMessage("2", m_stats);
|
||||
|
||||
+62
-102
@@ -826,26 +826,26 @@ void Channel::SetModes(BotInfo *bi, bool EnforceMLock, const char *cmodes, ...)
|
||||
}
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/** Set modes internally on the channel
|
||||
* @param c The channel
|
||||
* @param ac Number of args
|
||||
* @param av args
|
||||
/** Set a string of modes internally on a channel
|
||||
* @param setter The setter, if it is a user
|
||||
* @param mode the modes
|
||||
* @param EnforceMLock true to enforce mlock
|
||||
*/
|
||||
void ChanSetInternalModes(Channel *c, int ac, const char **av, User *setter)
|
||||
void Channel::SetModesInternal(User *setter, const Anope::string &modes, bool EnforceMLock)
|
||||
{
|
||||
if (!ac)
|
||||
return;
|
||||
spacesepstream sep_modes(modes);
|
||||
Anope::string m;
|
||||
|
||||
sep_modes.GetToken(m);
|
||||
|
||||
Anope::string modestring;
|
||||
Anope::string paramstring;
|
||||
int k = 0, j = 0, add = -1;
|
||||
for (unsigned int i = 0, end = strlen(av[0]); i < end; ++i)
|
||||
int add = -1;
|
||||
for (unsigned int i = 0, end = m.length(); i < end; ++i)
|
||||
{
|
||||
ChannelMode *cm;
|
||||
|
||||
switch (av[0][i])
|
||||
switch (m[i])
|
||||
{
|
||||
case '+':
|
||||
modestring += '+';
|
||||
@@ -858,7 +858,7 @@ void ChanSetInternalModes(Channel *c, int ac, const char **av, User *setter)
|
||||
default:
|
||||
if (add == -1)
|
||||
continue;
|
||||
cm = ModeManager::FindChannelModeByChar(av[0][i]);
|
||||
cm = ModeManager::FindChannelModeByChar(m[i]);
|
||||
if (!cm)
|
||||
continue;
|
||||
modestring += cm->ModeChar;
|
||||
@@ -867,9 +867,9 @@ void ChanSetInternalModes(Channel *c, int ac, const char **av, User *setter)
|
||||
if (cm->Type == MODE_REGULAR)
|
||||
{
|
||||
if (add)
|
||||
c->SetModeInternal(cm);
|
||||
this->SetModeInternal(cm, "", EnforceMLock);
|
||||
else
|
||||
c->RemoveModeInternal(cm);
|
||||
this->RemoveModeInternal(cm, "", EnforceMLock);
|
||||
continue;
|
||||
}
|
||||
else if (cm->Type == MODE_PARAM)
|
||||
@@ -878,32 +878,32 @@ void ChanSetInternalModes(Channel *c, int ac, const char **av, User *setter)
|
||||
|
||||
if (!add && cmp->MinusNoArg)
|
||||
{
|
||||
c->RemoveModeInternal(cm);
|
||||
++k;
|
||||
this->RemoveModeInternal(cm, "", EnforceMLock);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (++j < ac)
|
||||
Anope::string token;
|
||||
if (sep_modes.GetToken(token))
|
||||
{
|
||||
User *u = NULL;
|
||||
if (cm->Type == MODE_STATUS && (u = finduser(av[j])))
|
||||
if (cm->Type == MODE_STATUS && (u = finduser(token)))
|
||||
paramstring += " " + u->nick;
|
||||
else
|
||||
paramstring += " " + Anope::string(av[j]);
|
||||
paramstring += " " + token;
|
||||
|
||||
if (add)
|
||||
c->SetModeInternal(cm, av[j]);
|
||||
this->SetModeInternal(cm, token, EnforceMLock);
|
||||
else
|
||||
c->RemoveModeInternal(cm, av[j]);
|
||||
this->RemoveModeInternal(cm, token, EnforceMLock);
|
||||
}
|
||||
else
|
||||
Log() << "warning: ChanSetInternalModes() recieved more modes requiring params than params, modes: " << merge_args(ac, av) << ", ac: " << ac << ", j: " << j;
|
||||
Log() << "warning: Channel::SetModesInternal() recieved more modes requiring params than params, modes: " << modes;
|
||||
}
|
||||
|
||||
if (setter)
|
||||
Log(setter, c, "mode") << modestring << paramstring;
|
||||
|
||||
if (j + k + 1 < ac)
|
||||
Log() << "warning: ChanSetInternalModes() recieved more params than modes requiring them, modes: " << merge_args(ac, av) << ", ac: " << ac << ", j: " << j << " k: " << k;
|
||||
Log(setter, this, "mode") << modestring << paramstring;
|
||||
else
|
||||
Log(LOG_DEBUG) << "Setting " << this->name << " to " << modestring << paramstring;
|
||||
}
|
||||
|
||||
/** Kick a user from a channel internally
|
||||
@@ -1127,22 +1127,21 @@ User *nc_on_chan(Channel *c, const NickCore *nc)
|
||||
/*************************** Message Handling ****************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/* Handle a JOIN command.
|
||||
* av[0] = channels to join
|
||||
/** Handle a JOIN command
|
||||
* @param source user joining
|
||||
* @param channels being joined
|
||||
* @param ts TS for the join
|
||||
*/
|
||||
|
||||
void do_join(const Anope::string &source, int ac, const char **av)
|
||||
void do_join(const Anope::string &source, const Anope::string &channels, const Anope::string &ts)
|
||||
{
|
||||
User *user;
|
||||
|
||||
user = finduser(source);
|
||||
User *user = finduser(source);
|
||||
if (!user)
|
||||
{
|
||||
Log() << "JOIN from nonexistent user " << source << ": " << merge_args(ac, av);
|
||||
Log() << "JOIN from nonexistent user " << source << ": " << channels;
|
||||
return;
|
||||
}
|
||||
|
||||
commasepstream sep(av[0]);
|
||||
commasepstream sep(channels);
|
||||
Anope::string buf;
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
@@ -1165,18 +1164,18 @@ void do_join(const Anope::string &source, int ac, const char **av)
|
||||
|
||||
/* Channel doesn't exist, create it */
|
||||
if (!chan)
|
||||
chan = new Channel(av[0], Anope::CurTime);
|
||||
chan = new Channel(buf, Anope::CurTime);
|
||||
|
||||
/* Join came with a TS */
|
||||
if (ac == 2)
|
||||
if (!ts.empty())
|
||||
{
|
||||
time_t ts = Anope::string(av[1]).is_pos_number_only() ? convertTo<time_t>(av[1]) : 0;
|
||||
time_t t = Anope::string(ts).is_pos_number_only() ? convertTo<time_t>(ts) : 0;
|
||||
|
||||
/* Their time is older, we lose */
|
||||
if (chan->creation_time > ts)
|
||||
if (t && chan->creation_time > t)
|
||||
{
|
||||
Log(LOG_DEBUG) << "Recieved an older TS " << chan->name << " in JOIN, changing from " << chan->creation_time << " to " << ts;
|
||||
chan->creation_time = ts;
|
||||
chan->creation_time = t;
|
||||
|
||||
chan->Reset();
|
||||
}
|
||||
@@ -1205,41 +1204,36 @@ void do_join(const Anope::string &source, int ac, const char **av)
|
||||
|
||||
/** Handle a KICK command.
|
||||
* @param source The source of the kick
|
||||
* @param ac number of args
|
||||
* @param av The channel, nick(s) being kicked, and reason
|
||||
* @param users the user(s) being kicked
|
||||
* @param reason The reason for the kick
|
||||
*/
|
||||
void do_kick(const Anope::string &source, int ac, const char **av)
|
||||
void do_kick(const Anope::string &source, const Anope::string &channel, const Anope::string &users, const Anope::string &reason)
|
||||
{
|
||||
Channel *c = findchan(av[0]);
|
||||
Channel *c = findchan(channel);
|
||||
if (!c)
|
||||
{
|
||||
Log() << "Recieved kick for nonexistant channel " << av[0];
|
||||
Log() << "Recieved kick for nonexistant channel " << channel;
|
||||
return;
|
||||
}
|
||||
|
||||
Anope::string buf;
|
||||
commasepstream sep(av[1]);
|
||||
commasepstream sep(users);
|
||||
while (sep.GetToken(buf))
|
||||
c->KickInternal(source, buf, av[2]);
|
||||
c->KickInternal(source, buf, reason);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Handle a PART command.
|
||||
* av[0] = channels to leave
|
||||
* av[1] = reason (optional)
|
||||
*/
|
||||
|
||||
void do_part(const Anope::string &source, int ac, const char **av)
|
||||
void do_part(const Anope::string &source, const Anope::string &channels, const Anope::string &reason)
|
||||
{
|
||||
User *user = finduser(source);
|
||||
if (!user)
|
||||
{
|
||||
Log() << "PART from nonexistent user " << source << ": " << merge_args(ac, av);
|
||||
Log() << "PART from nonexistent user " << source << ": " << reason;
|
||||
return;
|
||||
}
|
||||
|
||||
commasepstream sep(av[0]);
|
||||
commasepstream sep(channels);
|
||||
Anope::string buf;
|
||||
while (sep.GetToken(buf))
|
||||
{
|
||||
@@ -1249,11 +1243,11 @@ void do_part(const Anope::string &source, int ac, const char **av)
|
||||
Log() << "Recieved PART from " << user->nick << " for nonexistant channel " << buf;
|
||||
else if (user->FindChannel(c))
|
||||
{
|
||||
Log(user, c, "part") << "Reason: " << (av[1] ? av[1] : "No reason");
|
||||
Log(user, c, "part") << "Reason: " << (!reason.empty() ? reason : "No reason");
|
||||
FOREACH_MOD(I_OnPrePartChannel, OnPrePartChannel(user, c));
|
||||
Anope::string ChannelName = c->name;
|
||||
c->DeleteUser(user);
|
||||
FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(ChannelName), ChannelName, av[1] ? av[1] : ""));
|
||||
FOREACH_MOD(I_OnPartChannel, OnPartChannel(user, findchan(ChannelName), ChannelName, !reason.empty() ? reason : ""));
|
||||
}
|
||||
else
|
||||
Log() << "Recieved PART from " << user->nick << " for " << c->name << ", but " << user->nick << " isn't in " << c->name << "?";
|
||||
@@ -1265,53 +1259,22 @@ void do_part(const Anope::string &source, int ac, const char **av)
|
||||
/** Process a MODE command from the server, and set the modes on the user/channel
|
||||
* it was sent for
|
||||
* @param source The source of the command
|
||||
* @param ac Number of args in array..
|
||||
* @param av Array of args
|
||||
* @param channel the channel to change modes on
|
||||
* @param modes the mode changes
|
||||
* @param ts the timestamp for the modes
|
||||
*/
|
||||
void do_cmode(const Anope::string &source, int ac, const char **av)
|
||||
void do_cmode(const Anope::string &source, const Anope::string &channel, const Anope::string &modes, const Anope::string &ts)
|
||||
{
|
||||
Channel *c;
|
||||
ChannelInfo *ci;
|
||||
unsigned i, end;
|
||||
const char *t;
|
||||
|
||||
if (Capab.HasFlag(CAPAB_TSMODE))
|
||||
{
|
||||
for (i = 0, end = strlen(av[1]); i < end; ++i)
|
||||
if (!isdigit(av[1][i]))
|
||||
break;
|
||||
if (!av[1][i])
|
||||
{
|
||||
t = av[0];
|
||||
av[0] = av[1];
|
||||
av[1] = t;
|
||||
--ac;
|
||||
++av;
|
||||
}
|
||||
else
|
||||
Log() << "TSMODE enabled but MODE has no valid TS";
|
||||
}
|
||||
|
||||
/* :42XAAAAAO TMODE 1106409026 #ircops +b *!*@*.aol.com */
|
||||
if (ircd->ts6 && isdigit(av[0][0]))
|
||||
{
|
||||
--ac;
|
||||
++av;
|
||||
}
|
||||
|
||||
c = findchan(av[0]);
|
||||
Channel *c = findchan(channel);
|
||||
if (!c)
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
ci = cs_findchan(av[0]);
|
||||
if (!ci || ci->HasFlag(CI_FORBIDDEN))
|
||||
Log(LOG_DEBUG) << "MODE " << merge_args(ac - 1, av + 1) << " for nonexistant channel " << av[0];
|
||||
}
|
||||
Log(LOG_DEBUG) << "MODE " << modes << " for nonexistant channel " << channel;
|
||||
return;
|
||||
}
|
||||
|
||||
if (source.find('.') != Anope::string::npos && Anope::string(av[1]).find_first_of("bovahq") == Anope::string::npos) // XXX
|
||||
Log(LOG_DEBUG) << "MODE " << channel << " " << modes << " ts: " << ts;
|
||||
|
||||
if (source.find('.') != Anope::string::npos)
|
||||
{
|
||||
if (Anope::CurTime != c->server_modetime)
|
||||
{
|
||||
@@ -1321,10 +1284,7 @@ void do_cmode(const Anope::string &source, int ac, const char **av)
|
||||
++c->server_modecount;
|
||||
}
|
||||
|
||||
--ac;
|
||||
++av;
|
||||
|
||||
ChanSetInternalModes(c, ac, av);
|
||||
c->SetModesInternal(finduser(source), modes);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
/* Memory management routines.
|
||||
*
|
||||
* (C) 2003-2010 Anope Team
|
||||
* Contact us at team@anope.org
|
||||
*
|
||||
* Please read COPYING and README for further details.
|
||||
*
|
||||
* Based on the original code of Epona by Lara.
|
||||
* Based on the original code of Services by Andy Church.
|
||||
*/
|
||||
|
||||
#include "services.h"
|
||||
|
||||
/* smalloc, scalloc, srealloc, sstrdup:
|
||||
* Versions of the memory allocation functions which will cause the
|
||||
* program to terminate with an "Out of memory" error if the memory
|
||||
* cannot be allocated. (Hence, the return value from these functions
|
||||
* is never NULL.)
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* calloc, replacement so we can trap for "out of memory"
|
||||
* @param elsize to allocate
|
||||
* @param els size of members
|
||||
* @return void
|
||||
*/
|
||||
void *scalloc(long elsize, long els)
|
||||
{
|
||||
void *buf;
|
||||
|
||||
if (!elsize || !els)
|
||||
elsize = els = 1;
|
||||
buf = calloc(elsize, els);
|
||||
if (!buf)
|
||||
abort();
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* realloc, replacement so we can trap for "out of memory"
|
||||
* @param oldptr Old Pointer
|
||||
* @param newsize Size of new pointer
|
||||
* @return void
|
||||
*/
|
||||
void *srealloc(void *oldptr, long newsize)
|
||||
{
|
||||
void *buf;
|
||||
|
||||
if (!newsize)
|
||||
newsize = 1;
|
||||
buf = realloc(oldptr, newsize);
|
||||
if (!buf)
|
||||
abort();
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/*************************************************************************/
|
||||
|
||||
/* In the future: malloc() replacements that tell us if we're leaking and
|
||||
* maybe do sanity checks too... */
|
||||
|
||||
/*************************************************************************/
|
||||
+16
-17
@@ -51,14 +51,14 @@ int m_kill(const Anope::string &nick, const Anope::string &msg)
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
int m_time(const Anope::string &source, int ac, const char **av)
|
||||
bool m_time(const Anope::string &source, const std::vector<Anope::string> &)
|
||||
{
|
||||
if (source.empty())
|
||||
return MOD_CONT;
|
||||
|
||||
time_t *t;
|
||||
time(t);
|
||||
struct tm *tm = localtime(t);
|
||||
time_t t;
|
||||
time(&t);
|
||||
struct tm *tm = localtime(&t);
|
||||
char buf[64];
|
||||
strftime(buf, sizeof(buf), "%a %b %d %H:%M:%S %Y %Z", tm);
|
||||
ircdproto->SendNumeric(Config->ServerName, 391, source, "%s :%s", Config->ServerName.c_str(), buf);
|
||||
@@ -212,14 +212,14 @@ int m_privmsg(const Anope::string &source, const Anope::string &receiver, const
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
int m_stats(const Anope::string &source, int ac, const char **av)
|
||||
bool m_stats(const Anope::string &source, const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
if (ac < 1)
|
||||
return MOD_CONT;
|
||||
if (params.size() < 1)
|
||||
return true;
|
||||
|
||||
User *u = finduser(source);
|
||||
|
||||
switch (*av[0])
|
||||
switch (params[0][0])
|
||||
{
|
||||
case 'l':
|
||||
if (u && is_oper(u))
|
||||
@@ -228,13 +228,13 @@ int m_stats(const Anope::string &source, int ac, const char **av)
|
||||
ircdproto->SendNumeric(Config->ServerName, 211, source, "%s %d %d %d %d %d %d %ld", uplink_server->host.c_str(), UplinkSock->WriteBufferLen(), TotalWritten, -1, UplinkSock->ReadBufferLen(), TotalRead, -1, Anope::CurTime - start_time);
|
||||
}
|
||||
|
||||
ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*');
|
||||
ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", params[0][0]);
|
||||
break;
|
||||
case 'o':
|
||||
case 'O':
|
||||
/* Check whether the user is an operator */
|
||||
if (u && !is_oper(u) && Config->HideStatsO)
|
||||
ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*');
|
||||
ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", params[0][0]);
|
||||
else
|
||||
{
|
||||
std::list<std::pair<Anope::string, Anope::string> >::iterator it, it_end;
|
||||
@@ -248,7 +248,7 @@ int m_stats(const Anope::string &source, int ac, const char **av)
|
||||
ircdproto->SendNumeric(Config->ServerName, 243, source, "O * * %s %s 0", nick.c_str(), type.c_str());
|
||||
}
|
||||
|
||||
ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*');
|
||||
ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", params[0][0]);
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -258,19 +258,18 @@ int m_stats(const Anope::string &source, int ac, const char **av)
|
||||
time_t uptime = Anope::CurTime - start_time;
|
||||
ircdproto->SendNumeric(Config->ServerName, 242, source, ":Services up %d day%s, %02d:%02d:%02d", uptime / 86400, uptime / 86400 == 1 ? "" : "s", (uptime / 3600) % 24, (uptime / 60) % 60, uptime % 60);
|
||||
ircdproto->SendNumeric(Config->ServerName, 250, source, ":Current users: %d (%d ops); maximum %d", usercnt, opcnt, maxusercnt);
|
||||
ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*');
|
||||
ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", params[0][0]);
|
||||
break;
|
||||
} /* case 'u' */
|
||||
|
||||
default:
|
||||
ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", *av[0] ? *av[0] : '*');
|
||||
ircdproto->SendNumeric(Config->ServerName, 219, source, "%c :End of /STATS report.", params[0][0]);
|
||||
}
|
||||
return MOD_CONT;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
int m_version(const Anope::string &source, int ac, const char **av)
|
||||
bool m_version(const Anope::string &source, const std::vector<Anope::string> &)
|
||||
{
|
||||
if (!source.empty())
|
||||
ircdproto->SendNumeric(Config->ServerName, 351, source, "Anope-%s %s :%s -(%s) -- %s", Anope::Version().c_str(), Config->ServerName.c_str(), ircd->name, Config->EncModuleList.begin()->c_str(), Anope::Build().c_str());
|
||||
|
||||
@@ -556,42 +556,6 @@ Anope::string myStrGetTokenRemainder(const Anope::string &str, const char dilim,
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Clean up the buffer for extra spaces
|
||||
* @param str to clean up
|
||||
* @return void
|
||||
*/
|
||||
void doCleanBuffer(char *str)
|
||||
{
|
||||
char *in, *out;
|
||||
char ch;
|
||||
|
||||
if (!str)
|
||||
return;
|
||||
|
||||
in = str;
|
||||
out = str;
|
||||
|
||||
while (issp(ch = *in++));
|
||||
if (ch)
|
||||
for (;;)
|
||||
{
|
||||
*out++ = ch;
|
||||
ch = *in++;
|
||||
if (!ch)
|
||||
break;
|
||||
if (!issp(ch))
|
||||
continue;
|
||||
while (issp(ch = *in++));
|
||||
if (!ch)
|
||||
break;
|
||||
*out++ = ' ';
|
||||
}
|
||||
*out = ch; /* == '\0' */
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* Kill the user to enforce the sqline
|
||||
* @param nick to kill
|
||||
|
||||
+1
-1
@@ -92,7 +92,7 @@ Module *FindModule(const Anope::string &name)
|
||||
* @param func A callback function that will be called when this message is received
|
||||
* @return The new message object
|
||||
*/
|
||||
Message *Anope::AddMessage(const Anope::string &name, int (*func)(const Anope::string &source, int ac, const char **av))
|
||||
Message *Anope::AddMessage(const Anope::string &name, bool (*func)(const Anope::string &source, const std::vector<Anope::string> ¶ms))
|
||||
{
|
||||
Message *m = new Message();
|
||||
|
||||
|
||||
+49
-105
@@ -214,138 +214,82 @@ int clear_ignores()
|
||||
return deleted;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
/* split_buf: Split a buffer into arguments and store the arguments in an
|
||||
* argument vector pointed to by argv (which will be malloc'd
|
||||
* as necessary); return the argument count. If colon_special
|
||||
* is non-zero, then treat a parameter with a leading ':' as
|
||||
* the last parameter of the line, per the IRC RFC. Destroys
|
||||
* the buffer by side effect.
|
||||
/** Main process routine
|
||||
* @param buffer A raw line from the uplink to do things with
|
||||
*/
|
||||
int split_buf(char *buf, const char ***argv, int colon_special)
|
||||
{
|
||||
int argvsize = 8;
|
||||
int argc;
|
||||
char *s;
|
||||
|
||||
*argv = static_cast<const char **>(scalloc(sizeof(const char *) * argvsize, 1));
|
||||
argc = 0;
|
||||
while (*buf)
|
||||
{
|
||||
if (argc == argvsize)
|
||||
{
|
||||
argvsize += 8;
|
||||
*argv = static_cast<const char **>(srealloc(*argv, sizeof(const char *) * argvsize));
|
||||
}
|
||||
if (*buf == ':')
|
||||
{
|
||||
(*argv)[argc++] = buf + 1;
|
||||
buf = const_cast<char *>(""); // XXX: unsafe cast.
|
||||
}
|
||||
else
|
||||
{
|
||||
s = strpbrk(buf, " ");
|
||||
if (s)
|
||||
{
|
||||
*s++ = 0;
|
||||
while (*s == ' ')
|
||||
++s;
|
||||
}
|
||||
else
|
||||
s = buf + strlen(buf);
|
||||
(*argv)[argc++] = buf;
|
||||
buf = s;
|
||||
}
|
||||
}
|
||||
return argc;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* process: Main processing routine. Takes the string in inbuf (global
|
||||
* variable) and does something appropriate with it. */
|
||||
|
||||
void process(const Anope::string &buffer)
|
||||
{
|
||||
int retVal = 0;
|
||||
char source[64] = "";
|
||||
char cmd[64] = "";
|
||||
char buf[1024] = ""; // XXX InspIRCd 2.0 can send messages longer than 512 characters to servers... how disappointing.
|
||||
char *s;
|
||||
int ac; /* Parameters for the command */
|
||||
const char **av;
|
||||
|
||||
/* If debugging, log the buffer */
|
||||
Log(LOG_RAWIO) << "Received: " << buffer;
|
||||
|
||||
/* First make a copy of the buffer so we have the original in case we
|
||||
* crash - in that case, we want to know what we crashed on. */
|
||||
strscpy(buf, buffer.c_str(), sizeof(buf));
|
||||
/* Strip all extra spaces */
|
||||
Anope::string buf = buffer;
|
||||
buf = buf.replace_all_cs(" ", " ");
|
||||
|
||||
doCleanBuffer(buf);
|
||||
|
||||
/* Split the buffer into pieces. */
|
||||
if (*buf == ':')
|
||||
{
|
||||
s = strpbrk(buf, " ");
|
||||
if (!s)
|
||||
return;
|
||||
*s = 0;
|
||||
while (isspace(*++s));
|
||||
strscpy(source, buf + 1, sizeof(source));
|
||||
memmove(buf, s, strlen(s) + 1);
|
||||
}
|
||||
else
|
||||
*source = 0;
|
||||
if (!*buf)
|
||||
if (buf.empty())
|
||||
return;
|
||||
s = strpbrk(buf, " ");
|
||||
if (s)
|
||||
|
||||
Anope::string source;
|
||||
if (buf[0] == ':')
|
||||
{
|
||||
*s = 0;
|
||||
while (isspace(*++s));
|
||||
size_t space = buf.find_first_of(" ");
|
||||
if (space == Anope::string::npos)
|
||||
return;
|
||||
source = buf.substr(1, space - 1);
|
||||
buf = buf.substr(space + 1);
|
||||
if (source.empty() || buf.empty())
|
||||
return;
|
||||
}
|
||||
|
||||
spacesepstream buf_sep(buf);
|
||||
Anope::string buf_token;
|
||||
|
||||
Anope::string command = buf;
|
||||
if (buf_sep.GetToken(buf_token))
|
||||
command = buf_token;
|
||||
|
||||
std::vector<Anope::string> params;
|
||||
while (buf_sep.GetToken(buf_token))
|
||||
{
|
||||
if (buf_token[0] == ':')
|
||||
{
|
||||
if (!buf_sep.StreamEnd())
|
||||
params.push_back(buf_token.substr(1) + " " + buf_sep.GetRemaining());
|
||||
else
|
||||
params.push_back(buf_token.substr(1));
|
||||
break;
|
||||
}
|
||||
else
|
||||
params.push_back(buf_token);
|
||||
}
|
||||
else
|
||||
s = buf + strlen(buf);
|
||||
strscpy(cmd, buf, sizeof(cmd));
|
||||
ac = split_buf(s, &av, 1);
|
||||
|
||||
if (protocoldebug)
|
||||
{
|
||||
if (*source)
|
||||
Log() << "Source " << source;
|
||||
if (*cmd)
|
||||
Log() << "Token " << cmd;
|
||||
if (ac)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < ac; ++i)
|
||||
Log() << "av[" << i << "] = " << av[i];
|
||||
}
|
||||
Log() << "Source : " << (source.empty() ? "No source" : source);
|
||||
Log() << "Command: " << command;
|
||||
|
||||
if (params.empty())
|
||||
Log() << "No params";
|
||||
else
|
||||
Log() << "av[0] = NULL";
|
||||
for (unsigned i = 0; i < params.size(); ++i)
|
||||
Log() << "params " << i << ": " << params[i];
|
||||
}
|
||||
|
||||
/* Do something with the message. */
|
||||
std::vector<Message *> messages = Anope::FindMessage(cmd);
|
||||
std::vector<Message *> messages = Anope::FindMessage(command);
|
||||
|
||||
if (!messages.empty())
|
||||
{
|
||||
retVal = MOD_CONT;
|
||||
bool retVal = true;
|
||||
|
||||
for (std::vector<Message *>::iterator it = messages.begin(), it_end = messages.end(); retVal == MOD_CONT && it != it_end; ++it)
|
||||
for (std::vector<Message *>::iterator it = messages.begin(), it_end = messages.end(); retVal == true && it != it_end; ++it)
|
||||
{
|
||||
Message *m = *it;
|
||||
|
||||
if (m->func)
|
||||
retVal = m->func(source, ac, av);
|
||||
retVal = m->func(source, params);
|
||||
}
|
||||
}
|
||||
else
|
||||
Log(LOG_DEBUG) << "unknown message from server (" << buffer << ")";
|
||||
|
||||
/* Free argument list we created */
|
||||
free(av);
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
+8
-11
@@ -353,18 +353,17 @@ void do_server(const Anope::string &source, const Anope::string &servername, uns
|
||||
|
||||
/**
|
||||
* Handle removing the server from the Server struct
|
||||
* @param source Name of the server leaving
|
||||
* @param ac Number of arguments in av
|
||||
* @param av Agruments as part of the SQUIT
|
||||
* @param source Name of the server sending the squit
|
||||
* @param server Name of the server leaving
|
||||
* @return void
|
||||
*/
|
||||
void do_squit(const Anope::string &source, int ac, const char **av)
|
||||
void do_squit(const Anope::string &source, const Anope::string &server)
|
||||
{
|
||||
Server *s = Server::Find(av[0]);
|
||||
Server *s = Server::Find(server);
|
||||
|
||||
if (!s)
|
||||
{
|
||||
Log() << "SQUIT for nonexistent server (" << av[0] << ")!!";
|
||||
Log() << "SQUIT for nonexistent server " << server;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -395,16 +394,14 @@ void do_squit(const Anope::string &source, int ac, const char **av)
|
||||
/*************************************************************************/
|
||||
|
||||
/** Handle parsing the CAPAB/PROTOCTL messages
|
||||
* @param ac Number of args
|
||||
* @param av Args
|
||||
*/
|
||||
void CapabParse(int ac, const char **av)
|
||||
void CapabParse(const std::vector<Anope::string> ¶ms)
|
||||
{
|
||||
for (int i = 0; i < ac; ++i)
|
||||
for (unsigned i = 0; i < params.size(); ++i)
|
||||
{
|
||||
for (unsigned j = 0; !Capab_Info[j].Token.empty(); ++j)
|
||||
{
|
||||
if (Capab_Info[j].Token.equals_ci(av[i]))
|
||||
if (Capab_Info[j].Token.equals_ci(params[i]))
|
||||
{
|
||||
Capab.SetFlag(Capab_Info[j].Flag);
|
||||
break;
|
||||
|
||||
+14
-22
@@ -855,52 +855,44 @@ User *do_nick(const Anope::string &source, const Anope::string &nick, const Anop
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Handle a MODE command for a user.
|
||||
* av[0] = nick to change mode for
|
||||
* av[1] = modes
|
||||
*/
|
||||
|
||||
void do_umode(const Anope::string &source, int ac, const char **av)
|
||||
void do_umode(const Anope::string &, const Anope::string &user, const Anope::string &modes)
|
||||
{
|
||||
User *user = finduser(av[0]);
|
||||
if (!user)
|
||||
User *u = finduser(user);
|
||||
if (!u)
|
||||
{
|
||||
Log() << "user: MODE "<< av[1] << " for nonexistent nick "<< av[0] << ":" << merge_args(ac, av);
|
||||
Log() << "user: MODE "<< modes << " for nonexistent nick "<< user;
|
||||
return;
|
||||
}
|
||||
|
||||
Log(user, "mode") << "changes modes to " << merge_args(ac - 1, av + 1);
|
||||
Log(u, "mode") << "changes modes to " << modes;
|
||||
|
||||
Anope::string modes = av[1];
|
||||
for (int i = 2; i < ac; ++i)
|
||||
modes += Anope::string(" ") + av[i];
|
||||
user->SetModesInternal(modes.c_str());
|
||||
u->SetModesInternal(modes.c_str());
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/* Handle a QUIT command.
|
||||
* av[0] = reason
|
||||
/** Handle a QUIT command.
|
||||
* @param source User quitting
|
||||
* @param reason Quit reason
|
||||
*/
|
||||
|
||||
void do_quit(const Anope::string &source, int ac, const char **av)
|
||||
void do_quit(const Anope::string &source, const Anope::string &reason)
|
||||
{
|
||||
User *user = finduser(source);
|
||||
if (!user)
|
||||
{
|
||||
Log() << "user: QUIT from nonexistent user " << source << ":" << merge_args(ac, av);
|
||||
Log() << "user: QUIT from nonexistent user " << source << " (" << reason << ")";
|
||||
return;
|
||||
}
|
||||
|
||||
Log(user, "quit") << "quit (Reason: " << (*av[0] ? av[0] : "no reason") << ")";
|
||||
Log(user, "quit") << "quit (Reason: " << (!reason.empty() ? reason : "no reason") << ")";
|
||||
|
||||
NickAlias *na = findnick(user->nick);
|
||||
if (na && !na->HasFlag(NS_FORBIDDEN) && !na->nc->HasFlag(NI_SUSPENDED) && (user->IsRecognized() || user->IsIdentified(true)))
|
||||
{
|
||||
na->last_seen = Anope::CurTime;
|
||||
na->last_quit = *av[0] ? av[0] : "";
|
||||
na->last_quit = reason;
|
||||
}
|
||||
FOREACH_MOD(I_OnUserQuit, OnUserQuit(user, *av[0] ? av[0] : ""));
|
||||
FOREACH_MOD(I_OnUserQuit, OnUserQuit(user, reason));
|
||||
delete user;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user