forked from anope/anope
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodules.h
1226 lines (1050 loc) · 44.8 KB
/
modules.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* Modular support
*
* (C) 2003-2016 Anope Team
* Contact us at [email protected]
*
* 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 "serialize.h"
#ifndef MODULES_H
#define MODULES_H
#include "base.h"
#include "modes.h"
#include "timers.h"
#include "logger.h"
#include "extensible.h"
#include "version.h"
/** This definition is used as shorthand for the various classes
* and functions needed to make a module loadable by the OS.
* It defines the class factory and external AnopeInit and AnopeFini functions.
*/
#ifdef _WIN32
# define MODULE_INIT(x) \
extern "C" DllExport Module *AnopeInit(const Anope::string &, const Anope::string &); \
extern "C" Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
{ \
return new x(modname, creator); \
} \
BOOLEAN WINAPI DllMain(HINSTANCE, DWORD, LPVOID) \
{ \
return TRUE; \
} \
extern "C" DllExport void AnopeFini(x *); \
extern "C" void AnopeFini(x *m) \
{ \
delete m; \
} \
extern "C" DllExport ModuleVersionC AnopeVersion() \
{ \
ModuleVersionC ver; \
ver.version_major = VERSION_MAJOR; \
ver.version_minor = VERSION_MINOR; \
ver.version_patch = VERSION_PATCH; \
return ver; \
}
#else
# define MODULE_INIT(x) \
extern "C" DllExport Module *AnopeInit(const Anope::string &modname, const Anope::string &creator) \
{ \
return new x(modname, creator); \
} \
extern "C" DllExport void AnopeFini(x *m) \
{ \
delete m; \
} \
extern "C" DllExport ModuleVersionC AnopeVersion() \
{ \
ModuleVersionC ver; \
ver.version_major = VERSION_MAJOR; \
ver.version_minor = VERSION_MINOR; \
ver.version_patch = VERSION_PATCH; \
return ver; \
}
#endif
/**
* This #define allows us to call a method in all
* loaded modules in a readable simple way, e.g.:
*
* FOREACH_MOD(OnUserConnect, (user, exempt));
*/
#define FOREACH_MOD(ename, args) \
if (true) \
{ \
std::vector<Module *> &_modules = ModuleManager::EventHandlers[I_ ## ename]; \
for (std::vector<Module *>::iterator _i = _modules.begin(); _i != _modules.end();) \
{ \
try \
{ \
(*_i)->ename args; \
} \
catch (const ModuleException &modexcept) \
{ \
Log() << "Exception caught: " << modexcept.GetReason(); \
} \
catch (const NotImplementedException &) \
{ \
_i = _modules.erase(_i); \
continue; \
} \
++_i; \
} \
} \
else \
static_cast<void>(0)
/**
* This define is similar to the one above but returns a result.
* The first module to return a result other than EVENT_CONTINUE is the value to be accepted,
* and any modules after are ignored. This is used like:
*
* EventReturn MOD_RESULT;
* FOREACH_RESULT(OnUserConnect, MOD_RESULT, (user, exempt));
*/
#define FOREACH_RESULT(ename, ret, args) \
if (true) \
{ \
ret = EVENT_CONTINUE; \
std::vector<Module *> &_modules = ModuleManager::EventHandlers[I_ ## ename]; \
for (std::vector<Module *>::iterator _i = _modules.begin(); _i != _modules.end();) \
{ \
try \
{ \
EventReturn res = (*_i)->ename args; \
if (res != EVENT_CONTINUE) \
{ \
ret = res; \
break; \
} \
} \
catch (const ModuleException &modexcept) \
{ \
Log() << "Exception caught: " << modexcept.GetReason(); \
} \
catch (const NotImplementedException &) \
{ \
_i = _modules.erase(_i); \
continue; \
} \
++_i; \
} \
} \
else \
static_cast<void>(0)
/** Possible return types from events.
*/
enum EventReturn
{
EVENT_STOP,
EVENT_CONTINUE,
EVENT_ALLOW
};
enum ModuleReturn
{
MOD_ERR_OK,
MOD_ERR_PARAMS,
MOD_ERR_EXISTS,
MOD_ERR_NOEXIST,
MOD_ERR_NOLOAD,
MOD_ERR_UNKNOWN,
MOD_ERR_FILE_IO,
MOD_ERR_EXCEPTION,
MOD_ERR_VERSION
};
/** Priority types which can be returned from Module::Prioritize()
*/
enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER };
/* Module types, in the order in which they are unloaded. The order these are in is IMPORTANT */
enum
{
MT_BEGIN,
/* Module is 3rd party. All 3rd party modules should set this. Mutually exclusive to VENDOR. */
THIRD = 1 << 0,
/* A vendor module, which is made and shipped by Anope. Mutually exclusive to THIRD. */
VENDOR = 1 << 1,
/* Extra module not required for standard use. Probably requires external dependencies.
* This module does something extreme enough that we want it to show in the default /os modlist command
*/
EXTRA = 1 << 2,
/* Module provides access to a database */
DATABASE = 1 << 3,
/* Module provides encryption */
ENCRYPTION = 1 << 4,
/* Module provides a pseudoclient */
PSEUDOCLIENT = 1 << 5,
/* Module provides IRCd protocol support */
PROTOCOL = 1 << 6,
MT_END = 1 << 7
};
typedef unsigned short ModType;
struct ModuleVersionC
{
int version_major, version_minor, version_patch;
};
/** Returned by Module::GetVersion, used to see what version of Anope
* a module is compiled against.
*/
class ModuleVersion
{
private:
int version_major;
int version_minor;
int version_patch;
public:
ModuleVersion(const ModuleVersionC &);
/** Get the major version of Anope this was built against
* @return The major version
*/
int GetMajor() const;
/** Get the minor version of Anope this was built against
* @return The minor version
*/
int GetMinor() const;
/** Get the patch version this was built against
* @return The patch version
*/
int GetPatch() const;
};
class NotImplementedException : public CoreException { };
/** Every module in Anope is actually a class.
*/
class CoreExport Module : public Extensible
{
private:
bool permanent;
public:
/** The module name (e.g. os_modload)
*/
Anope::string name;
/** What type this module is
*/
ModType type;
/** The temporary path/filename
*/
Anope::string filename;
/** Handle for this module, obtained from dlopen()
*/
void *handle;
/** Time this module was created
*/
time_t created;
/** Version of this module
*/
Anope::string version;
/** Author of the module
*/
Anope::string author;
/** Creates and initialises a new module.
* @param modname The module name
* @param loadernick The nickname of the user loading the module.
* @param type The module type
*/
Module(const Anope::string &modname, const Anope::string &loadernick, ModType type = THIRD);
/** Destroys a module, freeing resources it has allocated.
*/
virtual ~Module();
/** Toggles the permanent flag on a module. If a module is permanent,
* then it may not be unloaded.
*
* Naturally, this setting should be used sparingly!
*
* @param state True if this module should be permanent, false else.
*/
void SetPermanent(bool state);
/** Retrieves whether or not a given module is permanent.
* @return true if the module is permanent, false else.
*/
bool GetPermanent() const;
/** Set the modules version info.
* @param version the version of the module
*/
void SetVersion(const Anope::string &version);
/** Set the modules author info
* @param author the author of the module
*/
void SetAuthor(const Anope::string &author);
virtual void Prioritize();
/* Everything below here are events. Modules must ModuleManager::Attach to these events
* before they will be called.
*/
/** Called before a user has been kicked from a channel.
* @param source The kicker
* @param cu The user, channel, and status of the user being kicked
* @param kickmsg The reason for the kick.
*/
virtual void OnPreUserKicked(const MessageSource &source, ChanUserContainer *cu, const Anope::string &kickmsg) { throw NotImplementedException(); }
/** Called when a user has been kicked from a channel.
* @param source The kicker
* @param target The user being kicked
* @param channel The channel the user was kicked from, which may no longer exist
* @param status The status the kicked user had on the channel before they were kicked
* @param kickmsg The reason for the kick.
*/
virtual void OnUserKicked(const MessageSource &source, User *target, const Anope::string &channel, ChannelStatus &status, const Anope::string &kickmsg) { throw NotImplementedException(); }
/** Called when Services' configuration is being (re)loaded.
* @param conf The config that is being built now and will replace the global Config object
* @throws A ConfigException to abort the config (re)loading process.
*/
virtual void OnReload(Configuration::Conf *conf) { throw NotImplementedException(); }
/** Called before a bot is assigned to a channel.
* @param sender The user assigning the bot
* @param ci The channel the bot is to be assigned to.
* @param bi The bot being assigned.
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the assign.
*/
virtual EventReturn OnPreBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) { throw NotImplementedException(); }
/** Called when a bot is assigned ot a channel
*/
virtual void OnBotAssign(User *sender, ChannelInfo *ci, BotInfo *bi) { throw NotImplementedException(); }
/** Called before a bot is unassigned from a channel.
* @param sender The user unassigning the bot
* @param ci The channel the bot is being removed from
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the unassign.
*/
virtual EventReturn OnBotUnAssign(User *sender, ChannelInfo *ci) { throw NotImplementedException(); }
/** Called when a new user connects to the network.
* @param u The connecting user.
* @param exempt set to true/is true if the user should be excepted from bans etc
*/
virtual void OnUserConnect(User *u, bool &exempt) { throw NotImplementedException(); }
/** Called when a new server connects to the network.
* @param s The server that has connected to the network
*/
virtual void OnNewServer(Server *s) { throw NotImplementedException(); }
/** Called after a user changed the nick
* @param u The user.
* @param oldnick The old nick of the user
*/
virtual void OnUserNickChange(User *u, const Anope::string &oldnick) { throw NotImplementedException(); }
/** Called when someone uses the generic/help command
* @param source Command source
* @param params Params
* @return EVENT_STOP to stop processing
*/
virtual EventReturn OnPreHelp(CommandSource &source, const std::vector<Anope::string> ¶ms) { throw NotImplementedException(); }
/** Called when someone uses the generic/help command
* @param source Command source
* @param params Params
*/
virtual void OnPostHelp(CommandSource &source, const std::vector<Anope::string> ¶ms) { throw NotImplementedException(); }
/** Called before a command is due to be executed.
* @param source The source of the command
* @param command The command the user is executing
* @param params The parameters the user is sending
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
*/
virtual EventReturn OnPreCommand(CommandSource &source, Command *command, std::vector<Anope::string> ¶ms) { throw NotImplementedException(); }
/** Called after a command has been executed.
* @param source The source of the command
* @param command The command the user executed
* @param params The parameters the user sent
*/
virtual void OnPostCommand(CommandSource &source, Command *command, const std::vector<Anope::string> ¶ms) { throw NotImplementedException(); }
/** Called when the databases are saved
*/
virtual void OnSaveDatabase() { throw NotImplementedException(); }
/** Called when the databases are loaded
* @return EVENT_CONTINUE to let other modules continue loading, EVENT_STOP to stop
*/
virtual EventReturn OnLoadDatabase() { throw NotImplementedException(); }
/** Called when anope needs to check passwords against encryption
* see src/encrypt.c for detailed informations
*/
virtual EventReturn OnEncrypt(const Anope::string &src, Anope::string &dest) { throw NotImplementedException(); }
virtual EventReturn OnDecrypt(const Anope::string &hashm, const Anope::string &src, Anope::string &dest) { throw NotImplementedException(); }
/** Called on fantasy command
* @param source The source of the command
* @param c The command
* @param ci The channel it's being used in
* @param params The params
* @return EVENT_STOP to halt processing and not run the command, EVENT_ALLOW to allow the command to be executed
*/
virtual EventReturn OnBotFantasy(CommandSource &source, Command *c, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { throw NotImplementedException(); }
/** Called on fantasy command without access
* @param source The source of the command
* @param c The command
* @param ci The channel it's being used in
* @param params The params
* @return EVENT_STOP to halt processing and not run the command, EVENT_ALLOW to allow the command to be executed
*/
virtual EventReturn OnBotNoFantasyAccess(CommandSource &source, Command *c, ChannelInfo *ci, const std::vector<Anope::string> ¶ms) { throw NotImplementedException(); }
/** Called when a bot places a ban
* @param u User being banned
* @param ci Channel the ban is placed on
* @param mask The mask being banned
*/
virtual void OnBotBan(User *u, ChannelInfo *ci, const Anope::string &mask) { throw NotImplementedException(); }
/** Called before a badword is added to the badword list
* @param ci The channel
* @param bw The badword
*/
virtual void OnBadWordAdd(ChannelInfo *ci, const BadWord *bw) { throw NotImplementedException(); }
/** Called before a badword is deleted from a channel
* @param ci The channel
* @param bw The badword
*/
virtual void OnBadWordDel(ChannelInfo *ci, const BadWord *bw) { throw NotImplementedException(); }
/** Called when a bot is created or destroyed
*/
virtual void OnCreateBot(BotInfo *bi) { throw NotImplementedException(); }
virtual void OnDelBot(BotInfo *bi) { throw NotImplementedException(); }
/** Called before a bot kicks a user
* @param bi The bot sending the kick
* @param c The channel the user is being kicked on
* @param u The user being kicked
* @param reason The reason
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
*/
virtual EventReturn OnBotKick(BotInfo *bi, Channel *c, User *u, const Anope::string &reason) { throw NotImplementedException(); }
/** Called before a user parts a channel
* @param u The user
* @param c The channel
*/
virtual void OnPrePartChannel(User *u, Channel *c) {}
/** Called when a user parts a channel
* @param u The user
* @param c The channel, may be NULL if the channel no longer exists
* @param channel The channel name
* @param msg The part reason
*/
virtual void OnPartChannel(User *u, Channel *c, const Anope::string &channel, const Anope::string &msg) { throw NotImplementedException(); }
/** Called when a user leaves a channel.
* From either parting, being kicked, or quitting/killed!
* @param u The user
* @param c The channel
*/
virtual void OnLeaveChannel(User *u, Channel *c) { throw NotImplementedException(); }
/** Called after a user joins a channel
* If this event triggers the user is allowed to be in the channel, and will
* not be kicked for restricted/akick/forbidden, etc. If you want to kick the user,
* use the CheckKick event instead.
* @param u The user
* @param channel The channel
*/
virtual void OnJoinChannel(User *u, Channel *c) { throw NotImplementedException(); }
/** Called when a new topic is set
* @param source The user changing the topic, if any
* @param c The channel
* @param setter The user who set the new topic, if there is no source
* @param topic The new topic
*/
virtual void OnTopicUpdated(User *source, Channel *c, const Anope::string &user, const Anope::string &topic) { throw NotImplementedException(); }
/** Called before a channel expires
* @param ci The channel
* @param expire Set to true to allow the chan to expire
*/
virtual void OnPreChanExpire(ChannelInfo *ci, bool &expire) { throw NotImplementedException(); }
/** Called before a channel expires
* @param ci The channel
*/
virtual void OnChanExpire(ChannelInfo *ci) { throw NotImplementedException(); }
/** Called before Anope connecs to its uplink
*/
virtual void OnPreServerConnect() { throw NotImplementedException(); }
/** Called when Anope connects to its uplink
*/
virtual void OnServerConnect() { throw NotImplementedException(); }
/** Called when we are almost done synching with the uplink, just before we send the EOB
*/
virtual void OnPreUplinkSync(Server *serv) { throw NotImplementedException(); }
/** Called when Anope disconnects from its uplink, before it tries to reconnect
*/
virtual void OnServerDisconnect() { throw NotImplementedException(); }
/** Called when services restart
*/
virtual void OnRestart() { throw NotImplementedException(); }
/** Called when services shutdown
*/
virtual void OnShutdown() { throw NotImplementedException(); }
/** Called before a nick expires
* @param na The nick
* @param expire Set to true to allow the nick to expire
*/
virtual void OnPreNickExpire(NickAlias *na, bool &expire) { throw NotImplementedException(); }
/** Called when a nick drops
* @param na The nick
*/
virtual void OnNickExpire(NickAlias *na) { throw NotImplementedException(); }
/** Called when defcon level changes
* @param level The level
*/
virtual void OnDefconLevel(int level) { throw NotImplementedException(); }
/** Called after an exception has been added
* @param ex The exception
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
*/
virtual EventReturn OnExceptionAdd(Exception *ex) { throw NotImplementedException(); }
/** Called before an exception is deleted
* @param source The source deleting it
* @param ex The exceotion
*/
virtual void OnExceptionDel(CommandSource &source, Exception *ex) { throw NotImplementedException(); }
/** Called before a XLine is added
* @param source The source of the XLine
* @param x The XLine
* @param xlm The xline manager it was added to
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to halt the command and not process it
*/
virtual EventReturn OnAddXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { throw NotImplementedException(); }
/** Called before a XLine is deleted
* @param source The source of the XLine
* @param x The XLine
* @param xlm The xline manager it was deleted from
*/
virtual void OnDelXLine(CommandSource &source, const XLine *x, XLineManager *xlm) { throw NotImplementedException(); }
/** Called when a user is checked for whether they are a services oper
* @param u The user
* @return EVENT_ALLOW to allow, anything else to deny
*/
virtual EventReturn IsServicesOper(User *u) { throw NotImplementedException(); }
/** Called when a server quits
* @param server The server
*/
virtual void OnServerQuit(Server *server) { throw NotImplementedException(); }
/** Called when a user quits, or is killed
* @param u The user
* @param msg The quit message
*/
virtual void OnUserQuit(User *u, const Anope::string &msg) { throw NotImplementedException(); }
/** Called when a user is quit, before and after being internally removed from
* This is different from OnUserQuit, which takes place at the time of the quit.
* This happens shortly after when all message processing is finished.
* all lists (channels, user list, etc)
* @param u The user
*/
virtual void OnPreUserLogoff(User *u) { throw NotImplementedException(); }
virtual void OnPostUserLogoff(User *u) { throw NotImplementedException(); }
/** Called when a new bot is made
* @param bi The bot
*/
virtual void OnBotCreate(BotInfo *bi) { throw NotImplementedException(); }
/** Called when a bot is changed
* @param bi The bot
*/
virtual void OnBotChange(BotInfo *bi) { throw NotImplementedException(); }
/** Called when a bot is deleted
* @param bi The bot
*/
virtual void OnBotDelete(BotInfo *bi) { throw NotImplementedException(); }
/** Called after an access entry is deleted from a channel
* @param ci The channel
* @param source The source of the command
* @param access The access entry that was removed
*/
virtual void OnAccessDel(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { throw NotImplementedException(); }
/** Called when access is added
* @param ci The channel
* @param source The source of the command
* @param access The access changed
*/
virtual void OnAccessAdd(ChannelInfo *ci, CommandSource &source, ChanAccess *access) { throw NotImplementedException(); }
/** Called when the access list is cleared
* @param ci The channel
* @param u The user who cleared the access
*/
virtual void OnAccessClear(ChannelInfo *ci, CommandSource &source) { throw NotImplementedException(); }
/** Called when a level for a channel is changed
* @param source The source of the command
* @param ci The channel the level was changed on
* @param priv The privilege changed
* @param what The new level
*/
virtual void OnLevelChange(CommandSource &source, ChannelInfo *ci, const Anope::string &priv, int16_t what) { throw NotImplementedException(); }
/** Called right before a channel is dropped
* @param source The user dropping the channel
* @param ci The channel
*/
virtual EventReturn OnChanDrop(CommandSource &source, ChannelInfo *ci) { throw NotImplementedException(); }
/** Called when a channel is registered
* @param ci The channel
*/
virtual void OnChanRegistered(ChannelInfo *ci) { throw NotImplementedException(); }
/** Called when a channel is suspended
* @param ci The channel
*/
virtual void OnChanSuspend(ChannelInfo *ci) { throw NotImplementedException(); }
/** Called when a channel is unsuspended
* @param ci The channel
*/
virtual void OnChanUnsuspend(ChannelInfo *ci) { throw NotImplementedException(); }
/** Called when a channel is being created, for any reason
* @param ci The channel
*/
virtual void OnCreateChan(ChannelInfo *ci) { throw NotImplementedException(); }
/** Called when a channel is being deleted, for any reason
* @param ci The channel
*/
virtual void OnDelChan(ChannelInfo *ci) { throw NotImplementedException(); }
/** Called when a new channel is created
* Note that this channel may not be introduced to the uplink at this point.
* @param c The channel
*/
virtual void OnChannelCreate(Channel *c) { throw NotImplementedException(); }
/** Called when a channel is deleted
* @param c The channel
*/
virtual void OnChannelDelete(Channel *c) { throw NotImplementedException(); }
/** Called after adding an akick to a channel
* @param source The source of the command
* @param ci The channel
* @param ak The akick
*/
virtual void OnAkickAdd(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { throw NotImplementedException(); }
/** Called before removing an akick from a channel
* @param source The source of the command
* @param ci The channel
* @param ak The akick
*/
virtual void OnAkickDel(CommandSource &source, ChannelInfo *ci, const AutoKick *ak) { throw NotImplementedException(); }
/** Called after a user join a channel when we decide whether to kick them or not
* @param u The user
* @param c The channel
* @param kick Set to true to kick
* @param mask The mask to ban, if any
* @param reason The reason for the kick
* @return EVENT_STOP to prevent the user from joining by kicking/banning the user
*/
virtual EventReturn OnCheckKick(User *u, Channel *c, Anope::string &mask, Anope::string &reason) { throw NotImplementedException(); }
/** Called when a user requests info for a channel
* @param source The user requesting info
* @param ci The channel the user is requesting info for
* @param info Data to show the user requesting information
* @param show_hidden true if we should show the user everything
*/
virtual void OnChanInfo(CommandSource &source, ChannelInfo *ci, InfoFormatter &info, bool show_hidden) { throw NotImplementedException(); }
/** Checks if access has the channel privilege 'priv'.
* @param access THe access struct
* @param priv The privilege being checked for
* @return EVENT_ALLOW for yes, EVENT_STOP to stop all processing
*/
virtual EventReturn OnCheckPriv(const ChanAccess *access, const Anope::string &priv) { throw NotImplementedException(); }
/** Check whether an access group has a privilege
* @param group The group
* @param priv The privilege
* @return MOD_ALLOW to allow, MOD_STOP to stop
*/
virtual EventReturn OnGroupCheckPriv(const AccessGroup *group, const Anope::string &priv) { throw NotImplementedException(); }
/** Called when a nick is dropped
* @param source The source of the command
* @param na The nick
*/
virtual void OnNickDrop(CommandSource &source, NickAlias *na) { throw NotImplementedException(); }
/** Called when a user groups their nick
* @param u The user grouping
* @param target The target they're grouping to
*/
virtual void OnNickGroup(User *u, NickAlias *target) { throw NotImplementedException(); }
/** Called when a user identifies to a nick
* @param u The user
*/
virtual void OnNickIdentify(User *u) { throw NotImplementedException(); }
/** Called when a user is logged into an account
* @param u The user
*/
virtual void OnUserLogin(User *u) { throw NotImplementedException(); }
/** Called when a nick logs out
* @param u The nick
*/
virtual void OnNickLogout(User *u) { throw NotImplementedException(); }
/** Called when a nick is registered
* @param user The user registering the nick, of any
* @param The nick
* @param pass The password of the newly registered nick
*/
virtual void OnNickRegister(User *user, NickAlias *na, const Anope::string &pass) { throw NotImplementedException(); }
/** Called when a nick is confirmed. This will never be called if registration confirmation is not enabled.
* @param user The user confirming the nick
* @param The account being confirmed
*/
virtual void OnNickConfirm(User *user, NickCore *) { throw NotImplementedException(); }
/** Called when a nick is suspended
* @param na The nick alias
*/
virtual void OnNickSuspend(NickAlias *na) { throw NotImplementedException(); }
/** Called when a nick is unsuspneded
* @param na The nick alias
*/
virtual void OnNickUnsuspended(NickAlias *na) { throw NotImplementedException(); }
/** Called on delnick()
* @ param na pointer to the nickalias
*/
virtual void OnDelNick(NickAlias *na) { throw NotImplementedException(); }
/** Called when a nickcore is created
* @param nc The nickcore
*/
virtual void OnNickCoreCreate(NickCore *nc) { throw NotImplementedException(); }
/** Called on delcore()
* @param nc pointer to the NickCore
*/
virtual void OnDelCore(NickCore *nc) { throw NotImplementedException(); }
/** Called on change_core_display()
* @param nc pointer to the NickCore
* @param newdisplay the new display
*/
virtual void OnChangeCoreDisplay(NickCore *nc, const Anope::string &newdisplay) { throw NotImplementedException(); }
/** called from NickCore::ClearAccess()
* @param nc pointer to the NickCore
*/
virtual void OnNickClearAccess(NickCore *nc) { throw NotImplementedException(); }
/** Called when a user adds an entry to their access list
* @param nc The nick
* @param entry The entry
*/
virtual void OnNickAddAccess(NickCore *nc, const Anope::string &entry) { throw NotImplementedException(); }
/** Called from NickCore::EraseAccess()
* @param nc pointer to the NickCore
* @param entry The access mask
*/
virtual void OnNickEraseAccess(NickCore *nc, const Anope::string &entry) { throw NotImplementedException(); }
/** called from NickCore::ClearCert()
* @param nc pointer to the NickCore
*/
virtual void OnNickClearCert(NickCore *nc) { throw NotImplementedException(); }
/** Called when a user adds an entry to their cert list
* @param nc The nick
* @param entry The entry
*/
virtual void OnNickAddCert(NickCore *nc, const Anope::string &entry) { throw NotImplementedException(); }
/** Called from NickCore::EraseCert()
* @param nc pointer to the NickCore
* @param entry The fingerprint
*/
virtual void OnNickEraseCert(NickCore *nc, const Anope::string &entry) { throw NotImplementedException(); }
/** Called when a user requests info for a nick
* @param source The user requesting info
* @param na The nick the user is requesting info from
* @param info Data to show the user requesting information
* @param show_hidden true if we should show the user everything
*/
virtual void OnNickInfo(CommandSource &source, NickAlias *na, InfoFormatter &info, bool show_hidden) { throw NotImplementedException(); }
/** Called when a user uses botserv/info on a bot or channel.
*/
virtual void OnBotInfo(CommandSource &source, BotInfo *bi, ChannelInfo *ci, InfoFormatter &info) { throw NotImplementedException(); }
/** Check whether a username and password is correct
* @param u The user trying to identify, if applicable.
* @param req The login request
*/
virtual void OnCheckAuthentication(User *u, IdentifyRequest *req) { throw NotImplementedException(); }
/** Called when a user does /ns update
* @param u The user
*/
virtual void OnNickUpdate(User *u) { throw NotImplementedException(); }
/** Called when we get informed about a users SSL fingerprint
* when we call this, the fingerprint should already be stored in the user struct
* @param u pointer to the user
*/
virtual void OnFingerprint(User *u) { throw NotImplementedException(); }
/** Called when a user becomes (un)away
* @param message The message, is .empty() if unaway
*/
virtual void OnUserAway(User *u, const Anope::string &message) { throw NotImplementedException(); }
/** Called when a user invites one of our users to a channel
* @param source The user doing the inviting
* @param c The channel the user is inviting to
* @param targ The user being invited
*/
virtual void OnInvite(User *source, Channel *c, User *targ) { throw NotImplementedException(); }
/** Called when a vhost is deleted
* @param na The nickalias of the vhost
*/
virtual void OnDeleteVhost(NickAlias *na) { throw NotImplementedException(); }
/** Called when a vhost is set
* @param na The nickalias of the vhost
*/
virtual void OnSetVhost(NickAlias *na) { throw NotImplementedException(); }
/** Called when a users host changes
* @param u The user
*/
virtual void OnSetDisplayedHost(User *) { throw NotImplementedException(); }
/** Called when a memo is sent
* @param source The source of the memo
* @param target The target of the memo
* @param mi Memo info for target
* @param m The memo
*/
virtual void OnMemoSend(const Anope::string &source, const Anope::string &target, MemoInfo *mi, Memo *m) { throw NotImplementedException(); }
/** Called when a memo is deleted
* @param target The target the memo is being deleted from (nick or channel)
* @param mi The memo info
* @param m The memo
*/
virtual void OnMemoDel(const Anope::string &target, MemoInfo *mi, const Memo *m) { throw NotImplementedException(); }
/** Called when a mode is set on a channel
* @param c The channel
* @param setter The user or server that is setting the mode
* @param mode The mode
* @param param The mode param, if there is one
* @return EVENT_STOP to make mlock/secureops etc checks not happen
*/
virtual EventReturn OnChannelModeSet(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) { throw NotImplementedException(); }
/** Called when a mode is unset on a channel
* @param c The channel
* @param setter The user or server that is unsetting the mode
* @param mode The mode
* @param param The mode param, if there is one
* @return EVENT_STOP to make mlock/secureops etc checks not happen
*/
virtual EventReturn OnChannelModeUnset(Channel *c, MessageSource &setter, ChannelMode *mode, const Anope::string ¶m) { throw NotImplementedException(); }
/** Called when a mode is set on a user
* @param setter who/what is setting the mode
* @param u The user
* @param mname The mode name
*/
virtual void OnUserModeSet(const MessageSource &setter, User *u, const Anope::string &mname) { throw NotImplementedException(); }
/** Called when a mode is unset from a user
* @param setter who/what is setting the mode
* @param u The user
* @param mname The mode name
*/
virtual void OnUserModeUnset(const MessageSource &setter, User *u, const Anope::string &mname) { throw NotImplementedException(); }
/** Called when a channel mode is introducted into Anope
* @param cm The mode
*/
virtual void OnChannelModeAdd(ChannelMode *cm) { throw NotImplementedException(); }
/** Called when a user mode is introducted into Anope
* @param um The mode
*/
virtual void OnUserModeAdd(UserMode *um) { throw NotImplementedException(); }
/** Called when a mode is about to be mlocked
* @param ci The channel the mode is being locked on
* @param lock The mode lock
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the mlock.
*/
virtual EventReturn OnMLock(ChannelInfo *ci, ModeLock *lock) { throw NotImplementedException(); }
/** Called when a mode is about to be unlocked
* @param ci The channel the mode is being unlocked from
* @param lock The mode lock
* @return EVENT_CONTINUE to let other modules decide, EVENT_STOP to deny the mlock.
*/
virtual EventReturn OnUnMLock(ChannelInfo *ci, ModeLock *lock) { throw NotImplementedException(); }
/** Called after a module is loaded
* @param u The user loading the module, can be NULL
* @param m The module
*/
virtual void OnModuleLoad(User *u, Module *m) { throw NotImplementedException(); }
/** Called before a module is unloaded
* @param u The user, can be NULL
* @param m The module
*/
virtual void OnModuleUnload(User *u, Module *m) { throw NotImplementedException(); }
/** Called when a server is synced
* @param s The server, can be our uplink server
*/
virtual void OnServerSync(Server *s) { throw NotImplementedException(); }
/** Called when we sync with our uplink
* @param s Our uplink
*/
virtual void OnUplinkSync(Server *s) { throw NotImplementedException(); }
/** Called when we receive a PRIVMSG for one of our clients
* @param u The user sending the PRIVMSG
* @param bi The target of the PRIVMSG
* @param message The message
* @return EVENT_STOP to halt processing
*/
virtual EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) { throw NotImplementedException(); }
/** Called when we receive a NOTICE for one of our clients
* @param u The user sending the NOTICE
* @param bi The target of the NOTICE
* @param message The message
*/
virtual void OnBotNotice(User *u, BotInfo *bi, Anope::string &message) { throw NotImplementedException(); }
/** Called when we receive a PRIVMSG for a registered channel we are in
* @param u The source of the message
* @param c The channel