ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/anope-protocol-module/hybrid.cpp
Revision: 1557
Committed: Sat Oct 13 20:31:14 2012 UTC (14 years ago) by michael
Content type: text/x-c++src
File size: 20743 byte(s)
Log Message:
- svn propset svn:keywords "Id"

File Contents

# User Rev Content
1 michael 1556 /* ircd-hybrid-8 protocol module
2     *
3     * (C) 2003-2012 Anope Team
4     * (C) 2012 by the Hybrid Development Team
5     *
6     * Please read COPYING and README for further details.
7     *
8     * Based on the original code of Epona by Lara.
9     * Based on the original code of Services by Andy Church.
10     *
11 michael 1557 * $Id$
12 michael 1556 */
13    
14     #include "module.h"
15    
16     static Anope::string UplinkSID;
17    
18     class HybridProto : public IRCDProto
19     {
20     public:
21     HybridProto() : IRCDProto("Hybrid 8.0.0")
22     {
23     DefaultPseudoclientModes = "+oi";
24     CanSNLine = true;
25     CanSQLine = true;
26     CanSZLine = false; /* hybrid currently does support remote d-lines, but we disable it for now */
27     RequiresID = true;
28     MaxModes = 4;
29     }
30    
31     void SendGlobalNotice(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
32     {
33     UplinkSocket::Message(bi) << "NOTICE $$" << dest->GetName() << " :" << msg;
34     }
35    
36     void SendGlobalPrivmsg(const BotInfo *bi, const Server *dest, const Anope::string &msg) anope_override
37     {
38     UplinkSocket::Message(bi) << "PRIVMSG $$" << dest->GetName() << " :" << msg;
39     }
40    
41     void SendGlobopsInternal(const BotInfo *source, const Anope::string &buf) anope_override
42     {
43     UplinkSocket::Message(source) << "GLOBOPS :" << buf;
44     }
45    
46     void SendSQLine(User *, const XLine *x) anope_override
47     {
48     UplinkSocket::Message(Me) << "RESV * " << x->Mask << " :" << x->GetReason();
49     }
50    
51     void SendSGLineDel(const XLine *x) anope_override
52     {
53     const BotInfo *bi = findbot(Config->OperServ);
54    
55     UplinkSocket::Message(bi) << "UNXLINE * " << x->Mask;
56     }
57    
58     void SendSGLine(User *, const XLine *x) anope_override
59     {
60     const BotInfo *bi = findbot(Config->OperServ);
61    
62     UplinkSocket::Message(bi) << "XLINE * " << x->Mask << " 0 :" << x->GetReason();
63     }
64    
65     void SendAkillDel(const XLine *x) anope_override
66     {
67     if (x->IsRegex() || x->HasNickOrReal())
68     return;
69    
70     const BotInfo *bi = findbot(Config->OperServ);
71    
72     UplinkSocket::Message(bi) << "UNKLINE * " << x->GetUser() << " " << x->GetHost();
73     }
74    
75     void SendSQLineDel(const XLine *x) anope_override
76     {
77     UplinkSocket::Message(Me) << "UNRESV * " << x->Mask;
78     }
79    
80     void SendJoin(const User *user, Channel *c, const ChannelStatus *status) anope_override
81     {
82     /*
83     * Note that we must send our modes with the SJOIN and
84     * can not add them to the mode stacker because ircd-hybrid
85     * does not allow *any* client to op itself
86     */
87     UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " +"
88     << c->GetModes(true, true) << " :"
89     << (status != NULL ? status->BuildModePrefixList() : "") << user->GetUID();
90    
91     /* And update our internal status for this user since this is not going through our mode handling system */
92     if (status != NULL)
93     {
94     UserContainer *uc = c->FindUser(user);
95    
96     if (uc != NULL)
97     *uc->Status = *status;
98     }
99     }
100    
101     void SendAkill(User *u, XLine *x) anope_override
102     {
103     const BotInfo *bi = findbot(Config->OperServ);
104    
105     if (x->IsRegex() || x->HasNickOrReal())
106     {
107     if (!u)
108     {
109     /*
110     * No user (this akill was just added), and contains nick and/or realname.
111     * Find users that match and ban them.
112     */
113     for (Anope::insensitive_map<User *>::const_iterator it = UserListByNick.begin(); it != UserListByNick.end(); ++it)
114     if (x->manager->Check(it->second, x))
115     this->SendAkill(it->second, x);
116    
117     return;
118     }
119    
120     const XLine *old = x;
121    
122     if (old->manager->HasEntry("*@" + u->host))
123     return;
124    
125     /* We can't akill x as it has a nick and/or realname included, so create a new akill for *@host */
126     XLine *xline = new XLine("*@" + u->host, old->By, old->Expires, old->Reason, old->UID);
127    
128     old->manager->AddXLine(xline);
129     x = xline;
130    
131     Log(bi, "akill") << "AKILL: Added an akill for " << x->Mask << " because " << u->GetMask() << "#"
132     << u->realname << " matches " << old->Mask;
133     }
134    
135     /* Calculate the time left before this would expire, capping it at 2 days */
136     time_t timeleft = x->Expires - Anope::CurTime;
137    
138     if (timeleft > 172800 || !x->Expires)
139     timeleft = 172800;
140    
141     UplinkSocket::Message(bi) << "KLINE * " << timeleft << " " << x->GetUser() << " " << x->GetHost() << " :" << x->GetReason();
142     }
143    
144     void SendServer(const Server *server) anope_override
145     {
146     UplinkSocket::Message() << "SERVER " << server->GetName() << " " << server->GetHops() << " :" << server->GetDescription();
147     }
148    
149     void SendConnect() anope_override
150     {
151     UplinkSocket::Message() << "PASS " << Config->Uplinks[CurrentUplink]->password << " TS 6 :" << Me->GetSID();
152    
153     /*
154     * As of October 13, 2012, ircd-hybrid-8 does support the following capabilities
155     * which are required to work with IRC-services:
156     *
157     * QS - Can handle quit storm removal
158     * EX - Can do channel +e exemptions
159     * CHW - Can do channel wall @#
160     * IE - Can do invite exceptions
161     * KNOCK - Supports KNOCK
162     * TBURST - Supports topic burst
163     * ENCAP - Supports ENCAP
164     * HOPS - Supports HalfOps
165     * SVS - Supports services
166     * EOB - Supports End Of Burst message
167     * TS6 - Capable of TS6 support
168     */
169     UplinkSocket::Message() << "CAPAB :QS EX CHW IE ENCAP TBURST SVS HOPS EOB TS6";
170    
171     SendServer(Me);
172    
173     UplinkSocket::Message() << "SVINFO 6 5 0 :" << Anope::CurTime;
174     }
175    
176     void SendClientIntroduction(const User *u) anope_override
177     {
178     Anope::string modes = "+" + u->GetModes();
179    
180     UplinkSocket::Message(Me) << "UID " << u->nick << " 1 " << u->timestamp << " " << modes << " "
181     << u->GetIdent() << " " << u->host << " 0 " << u->GetUID() << " 0 :" << u->realname;
182     }
183    
184     void SendEOB() anope_override
185     {
186     UplinkSocket::Message(Me) << "EOB";
187     }
188    
189     void SendModeInternal(const BotInfo *bi, const User *u, const Anope::string &buf) anope_override
190     {
191     if (bi)
192     UplinkSocket::Message(bi) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf;
193     else
194     UplinkSocket::Message(Me) << "SVSMODE " << u->nick << " " << u->timestamp << " " << buf;
195     }
196    
197     void SendLogin(User *u) anope_override
198     {
199     const BotInfo *ns = findbot(Config->NickServ);
200    
201     ircdproto->SendMode(ns, u, "+d %d", u->timestamp);
202     }
203    
204     void SendLogout(User *u) anope_override
205     {
206     const BotInfo *ns = findbot(Config->NickServ);
207    
208     ircdproto->SendMode(ns, u, "+d 1");
209     }
210    
211     void SendChannel(Channel *c) anope_override
212     {
213     Anope::string modes = c->GetModes(true, true);
214    
215     if (modes.empty())
216     modes = "+";
217    
218     UplinkSocket::Message() << "SJOIN " << c->creation_time << " " << c->name << " " << modes << " :";
219     }
220    
221     void SendTopic(BotInfo *bi, Channel *c) anope_override
222     {
223     bool needjoin = c->FindUser(bi) == NULL;
224    
225     if (needjoin)
226     {
227     ChannelStatus status;
228    
229     status.SetFlag(CMODE_OP);
230     bi->Join(c, &status);
231     }
232    
233     IRCDProto::SendTopic(bi, c);
234    
235     if (needjoin)
236     bi->Part(c);
237     }
238     };
239    
240     struct IRCDMessageBMask : IRCDMessage
241     {
242     IRCDMessageBMask() : IRCDMessage("BMASK", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
243    
244     /* 0 1 2 3 */
245     /* :0MC BMASK 1350157102 #channel b :*!*@*.test.com */
246     bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
247     {
248     Channel *c = findchan(params[1]);
249    
250     if (c)
251     {
252     ChannelMode *ban = ModeManager::FindChannelModeByName(CMODE_BAN),
253     *except = ModeManager::FindChannelModeByName(CMODE_EXCEPT),
254     *invex = ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE);
255    
256     Anope::string bans = params[3];
257    
258     int count = myNumToken(bans, ' '), i;
259    
260     for (i = 0; i < count; ++i)
261     {
262     Anope::string b = myStrGetToken(bans, ' ', i);
263    
264     if (ban && params[2].equals_cs("b"))
265     c->SetModeInternal(source, ban, b);
266     else if (except && params[2].equals_cs("e"))
267     c->SetModeInternal(source, except, b);
268     else if (invex && params[2].equals_cs("I"))
269     c->SetModeInternal(source, invex, b);
270     }
271     }
272    
273     return true;
274     }
275     };
276    
277     struct IRCDMessageJoin : CoreIRCDMessageJoin
278     {
279     IRCDMessageJoin() : CoreIRCDMessageJoin("JOIN") { }
280    
281     bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
282     {
283     if (params.size() < 2)
284     return true;
285    
286     std::vector<Anope::string> p = params;
287     p.erase(p.begin());
288    
289     return CoreIRCDMessageJoin::Run(source, p);
290     }
291     };
292    
293     struct IRCDMessageMode : IRCDMessage
294     {
295     IRCDMessageMode(const Anope::string &n) : IRCDMessage(n, 2) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
296    
297     bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
298     {
299     if (params.size() > 2 && ircdproto->IsChannelValid(params[0]))
300     {
301     Channel *c = findchan(params[0]);
302     time_t ts = Anope::CurTime;
303    
304     try
305     {
306     ts = convertTo<time_t>(params[1]);
307     }
308     catch (const ConvertException &) { }
309    
310     if (c)
311     c->SetModesInternal(source, params[2], ts);
312     }
313     else
314     {
315     User *u = finduser(params[0]);
316    
317     if (u)
318     u->SetModesInternal("%s", params[1].c_str());
319     }
320    
321     return true;
322     }
323     };
324    
325     struct IRCDMessageNick : IRCDMessage
326     {
327     IRCDMessageNick() : IRCDMessage("NICK", 2) { SetFlag(IRCDMESSAGE_REQUIRE_USER); }
328    
329     /* 0 1 */
330     /* :0MCAAAAAB NICK newnick 1350157102 */
331     bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
332     {
333     source.GetUser()->ChangeNick(params[0]);
334     return true;
335     }
336     };
337    
338     struct IRCDMessagePass : IRCDMessage
339     {
340     IRCDMessagePass() : IRCDMessage("PASS", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
341    
342     bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
343     {
344     UplinkSID = params[3];
345     return true;
346     }
347     };
348    
349     struct IRCDMessagePong : IRCDMessage
350     {
351     IRCDMessagePong() : IRCDMessage("PONG", 0) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
352    
353     bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
354     {
355     source.GetServer()->Sync(false);
356     return true;
357     }
358     };
359    
360     struct IRCDMessageServer : IRCDMessage
361     {
362     IRCDMessageServer() : IRCDMessage("SERVER", 3) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
363    
364     /* 0 1 2 */
365     /* SERVER hades.arpa 1 :ircd-hybrid test server */
366     bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
367     {
368     /* Servers other than our immediate uplink are introduced via SID */
369     if (params[1] != "1")
370     return true;
371    
372     new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], 1, params[2], UplinkSID);
373    
374     ircdproto->SendPing(Config->ServerName, params[0]);
375     return true;
376     }
377     };
378    
379     struct IRCDMessageSID : IRCDMessage
380     {
381     IRCDMessageSID() : IRCDMessage("SID", 4) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
382    
383     /* 0 1 2 3 */
384     /* :0MC SID hades.arpa 2 4XY :ircd-hybrid test server */
385     bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
386     {
387     unsigned int hops = params[1].is_pos_number_only() ? convertTo<unsigned>(params[1]) : 0;
388     new Server(source.GetServer() == NULL ? Me : source.GetServer(), params[0], hops, params[3], params[2]);
389    
390     ircdproto->SendPing(Config->ServerName, params[0]);
391     return true;
392     }
393     };
394    
395     struct IRCDMessageSjoin : IRCDMessage
396     {
397     IRCDMessageSjoin() : IRCDMessage("SJOIN", 2) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
398    
399     bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
400     {
401     Channel *c = findchan(params[1]);
402     time_t ts = Anope::string(params[0]).is_pos_number_only() ? convertTo<time_t>(params[0]) : 0;
403     bool keep_their_modes = true;
404    
405     if (!c)
406     {
407     c = new Channel(params[1], ts);
408     c->SetFlag(CH_SYNCING);
409     }
410     /* Our creation time is newer than what the server gave us */
411     else if (c->creation_time > ts)
412     {
413     c->creation_time = ts;
414     c->Reset();
415     }
416     /* Their TS is newer than ours, our modes > theirs, unset their modes if need be */
417     else if (ts > c->creation_time)
418     keep_their_modes = false;
419    
420     /* If we need to keep their modes, and this SJOIN string contains modes */
421     if (keep_their_modes && params.size() >= 3)
422     {
423     Anope::string modes;
424    
425     for (unsigned i = 2; i < params.size() - 1; ++i)
426     modes += " " + params[i];
427    
428     if (!modes.empty())
429     modes.erase(modes.begin());
430    
431     /* Set the modes internally */
432     c->SetModesInternal(source, modes);
433     }
434    
435     spacesepstream sep(params[params.size() - 1]);
436     Anope::string buf;
437    
438     while (sep.GetToken(buf))
439     {
440     std::list<ChannelMode *> Status;
441     char ch;
442    
443     /* Get prefixes from the nick */
444     while ((ch = ModeManager::GetStatusChar(buf[0])))
445     {
446     buf.erase(buf.begin());
447    
448     ChannelMode *cm = ModeManager::FindChannelModeByChar(ch);
449    
450     if (!cm)
451     {
452     Log() << "Received unknown mode prefix " << ch << " in SJOIN string";
453     continue;
454     }
455    
456     if (keep_their_modes)
457     Status.push_back(cm);
458     }
459    
460     User *u = finduser(buf);
461    
462     if (!u)
463     {
464     Log(LOG_DEBUG) << "SJOIN for nonexistant user " << buf << " on " << c->name;
465     continue;
466     }
467    
468     EventReturn MOD_RESULT;
469     FOREACH_RESULT(I_OnPreJoinChannel, OnPreJoinChannel(u, c));
470    
471     /* Add the user to the channel */
472     c->JoinUser(u);
473    
474     /*
475     * Update their status internally on the channel
476     * This will enforce secureops etc on the user
477     */
478     for (std::list<ChannelMode *>::iterator it = Status.begin(), it_end = Status.end(); it != it_end; ++it)
479     c->SetModeInternal(source, *it, buf);
480    
481     /* Now set whatever modes this user is allowed to have on the channel */
482     chan_set_correct_modes(u, c, 1, true);
483    
484     /*
485     * Check to see if modules want the user to join, if they do
486     * check to see if they are allowed to join (CheckKick will kick/ban them)
487     * Don't trigger OnJoinChannel event then as the user will be destroyed
488     */
489     if (MOD_RESULT != EVENT_STOP && c->ci && c->ci->CheckKick(u))
490     continue;
491    
492     FOREACH_MOD(I_OnJoinChannel, OnJoinChannel(u, c));
493     }
494    
495     /* Channel is done syncing */
496     if (c->HasFlag(CH_SYNCING))
497     {
498     /* Unset the syncing flag */
499     c->UnsetFlag(CH_SYNCING);
500     c->Sync();
501     }
502    
503     return true;
504     }
505     };
506    
507     struct IRCDMessageTBurst : IRCDMessage
508     {
509     IRCDMessageTBurst() : IRCDMessage("TBURST", 5) { }
510    
511     bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
512     {
513     Anope::string setter = myStrGetToken(params[3], '!', 0);
514     time_t topic_time = Anope::string(params[2]).is_pos_number_only() ? convertTo<time_t>(params[2]) : Anope::CurTime;
515     Channel *c = findchan(params[1]);
516    
517     if (c)
518     c->ChangeTopicInternal(setter, params[4], topic_time);
519    
520     return true;
521     }
522     };
523    
524     struct IRCDMessageTMode : IRCDMessage
525     {
526     IRCDMessageTMode() : IRCDMessage("TMODE", 3) { SetFlag(IRCDMESSAGE_SOFT_LIMIT); }
527    
528     bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
529     {
530     time_t ts = Anope::CurTime;
531    
532     try
533     {
534     ts = convertTo<time_t>(params[0]);
535     }
536     catch (const ConvertException &) { }
537    
538     Channel *c = findchan(params[1]);
539     Anope::string modes = params[2];
540    
541     for (unsigned i = 3; i < params.size(); ++i)
542     modes += " " + params[i];
543    
544     if (c)
545     c->SetModesInternal(source, modes, ts);
546    
547     return true;
548     }
549     };
550    
551     struct IRCDMessageUID : IRCDMessage
552     {
553     IRCDMessageUID() : IRCDMessage("UID", 10) { SetFlag(IRCDMESSAGE_REQUIRE_SERVER); }
554    
555     /* 0 1 2 3 4 5 6 7 8 9 */
556     /* :0MC UID Steve 1 1350157102 +oi ~steve resolved.host 10.0.0.1 0MCAAAAAB 1350157108 :Mining all the time */
557     bool Run(MessageSource &source, const std::vector<Anope::string> &params) anope_override
558     {
559     /* Source is always the server */
560     User *user = new User(params[0], params[4], params[5], "",
561     params[6], source.GetServer(),
562     params[9], params[2].is_pos_number_only() ? convertTo<time_t>(params[2]) : 0,
563     params[3], params[7]);
564    
565     if (user && nickserv)
566     {
567     const NickAlias *na;
568    
569     if (user->timestamp == convertTo<time_t>(params[8]) && (na = findnick(user->nick)))
570     {
571     NickCore *nc = na->nc;
572    
573     user->Login(nc);
574    
575     if (!Config->NoNicknameOwnership && na->nc->HasFlag(NI_UNCONFIRMED) == false)
576     user->SetMode(findbot(Config->NickServ), UMODE_REGISTERED);
577     }
578     else
579     nickserv->Validate(user);
580     }
581    
582     return true;
583     }
584     };
585    
586     class ProtoHybrid : public Module
587     {
588     HybridProto ircd_proto;
589    
590     /* Core message handlers */
591     CoreIRCDMessageAway core_message_away;
592     CoreIRCDMessageCapab core_message_capab;
593     CoreIRCDMessageError core_message_error;
594     CoreIRCDMessageKick core_message_kick;
595     CoreIRCDMessageKill core_message_kill;
596     CoreIRCDMessageMOTD core_message_motd;
597     CoreIRCDMessagePart core_message_part;
598     CoreIRCDMessagePing core_message_ping;
599     CoreIRCDMessagePrivmsg core_message_privmsg;
600     CoreIRCDMessageQuit core_message_quit;
601     CoreIRCDMessageSQuit core_message_squit;
602     CoreIRCDMessageStats core_message_stats;
603     CoreIRCDMessageTime core_message_time;
604     CoreIRCDMessageTopic core_message_topic;
605     CoreIRCDMessageVersion core_message_version;
606    
607     /* Our message handlers */
608     IRCDMessageBMask message_bmask;
609     IRCDMessageJoin message_join;
610     IRCDMessageMode message_mode, message_svsmode;
611     IRCDMessageNick message_nick;
612     IRCDMessagePass message_pass;
613     IRCDMessagePong message_pong;
614     IRCDMessageServer message_server;
615     IRCDMessageSID message_sid;
616     IRCDMessageSjoin message_sjoin;
617     IRCDMessageTBurst message_tburst;
618     IRCDMessageTMode message_tmode;
619     IRCDMessageUID message_uid;
620    
621     void AddModes()
622     {
623     /* Add user modes */
624     ModeManager::AddUserMode(new UserMode(UMODE_ADMIN, 'a'));
625     ModeManager::AddUserMode(new UserMode(UMODE_INVIS, 'i'));
626     ModeManager::AddUserMode(new UserMode(UMODE_OPER, 'o'));
627     ModeManager::AddUserMode(new UserMode(UMODE_REGISTERED, 'r'));
628     ModeManager::AddUserMode(new UserMode(UMODE_SNOMASK, 's'));
629     ModeManager::AddUserMode(new UserMode(UMODE_WALLOPS, 'w'));
630     ModeManager::AddUserMode(new UserMode(UMODE_HIDEOPER, 'H'));
631     ModeManager::AddUserMode(new UserMode(UMODE_REGPRIV, 'R'));
632    
633     /* b/e/I */
634     ModeManager::AddChannelMode(new ChannelModeList(CMODE_BAN, 'b'));
635     ModeManager::AddChannelMode(new ChannelModeList(CMODE_EXCEPT, 'e'));
636     ModeManager::AddChannelMode(new ChannelModeList(CMODE_INVITEOVERRIDE, 'I'));
637    
638     /* v/h/o/a/q */
639     ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_VOICE, 'v', '+', 0));
640     ModeManager::AddChannelMode(new ChannelModeStatus(CMODE_OP, 'o', '@', 1));
641    
642     /* Add channel modes */
643     ModeManager::AddChannelMode(new ChannelMode(CMODE_INVITE, 'i'));
644     ModeManager::AddChannelMode(new ChannelModeKey('k'));
645     ModeManager::AddChannelMode(new ChannelModeParam(CMODE_LIMIT, 'l'));
646     ModeManager::AddChannelMode(new ChannelMode(CMODE_MODERATED, 'm'));
647     ModeManager::AddChannelMode(new ChannelMode(CMODE_NOEXTERNAL, 'n'));
648     ModeManager::AddChannelMode(new ChannelMode(CMODE_PRIVATE, 'p'));
649     ModeManager::AddChannelMode(new ChannelModeRegistered('r'));
650     ModeManager::AddChannelMode(new ChannelMode(CMODE_SECRET, 's'));
651     ModeManager::AddChannelMode(new ChannelMode(CMODE_TOPIC, 't'));
652     ModeManager::AddChannelMode(new ChannelModeOper('O'));
653     ModeManager::AddChannelMode(new ChannelMode(CMODE_REGISTEREDONLY, 'R'));
654     ModeManager::AddChannelMode(new ChannelMode(CMODE_SSL, 'S'));
655     }
656    
657     public:
658     ProtoHybrid(const Anope::string &modname, const Anope::string &creator) :
659     Module(modname, creator, PROTOCOL), message_mode("MODE"), message_svsmode("SVSMODE")
660     {
661     this->SetAuthor("Anope");
662     this->AddModes();
663    
664     ModuleManager::Attach(I_OnUserNickChange, this);
665    
666     if (Config->Numeric.empty())
667     {
668     Anope::string numeric = ts6_sid_retrieve();
669     Me->SetSID(numeric);
670     Config->Numeric = numeric;
671     }
672    
673     for (botinfo_map::iterator it = BotListByNick->begin(), it_end = BotListByNick->end(); it != it_end; ++it)
674     it->second->GenerateUID();
675     }
676    
677     void OnUserNickChange(User *u, const Anope::string &) anope_override
678     {
679     u->RemoveModeInternal(ModeManager::FindUserModeByName(UMODE_REGISTERED));
680     ircdproto->SendLogout(u);
681     }
682     };
683    
684     MODULE_INIT(ProtoHybrid)

Properties

Name Value
svn:keywords Id