ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/anope-protocol-module/hybrid.cpp
Revision: 1560
Committed: Sun Oct 14 11:21:18 2012 UTC (14 years ago) by michael
Content type: text/x-c++src
File size: 21405 byte(s)
Log Message:
- Update to use service account names instead of timestamps

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

Properties

Name Value
svn:keywords Id