@@ -41,11 +41,32 @@ class Event(Mapping[str, Any]):
41
41
:type irc_command: str
42
42
:type irc_paramlist: list[str]
43
43
:type irc_ctcp_text: str
44
+ :type irc_tags: irclib.parser.TagList
44
45
"""
45
46
46
- def __init__ (self , * , bot = None , hook = None , conn = None , base_event = None , event_type = EventType .other , content = None ,
47
- content_raw = None , target = None , channel = None , nick = None , user = None , host = None , mask = None , irc_raw = None ,
48
- irc_prefix = None , irc_command = None , irc_paramlist = None , irc_ctcp_text = None ):
47
+ def __init__ (
48
+ self ,
49
+ * ,
50
+ bot = None ,
51
+ hook = None ,
52
+ conn = None ,
53
+ base_event = None ,
54
+ event_type = EventType .other ,
55
+ content = None ,
56
+ content_raw = None ,
57
+ target = None ,
58
+ channel = None ,
59
+ nick = None ,
60
+ user = None ,
61
+ host = None ,
62
+ mask = None ,
63
+ irc_raw = None ,
64
+ irc_prefix = None ,
65
+ irc_command = None ,
66
+ irc_paramlist = None ,
67
+ irc_ctcp_text = None ,
68
+ irc_tags = None
69
+ ):
49
70
"""
50
71
All of these parameters except for `bot` and `hook` are optional.
51
72
The irc_* parameters should only be specified for IRC events.
@@ -87,6 +108,7 @@ def __init__(self, *, bot=None, hook=None, conn=None, base_event=None, event_typ
87
108
:type irc_command: str
88
109
:type irc_paramlist: list[str]
89
110
:type irc_ctcp_text: str
111
+ :type irc_tags: irclib.parser.TagList
90
112
"""
91
113
self .db = None
92
114
self .db_executor = None
@@ -114,6 +136,7 @@ def __init__(self, *, bot=None, hook=None, conn=None, base_event=None, event_typ
114
136
self .mask = base_event .mask
115
137
# clients-specific parameters
116
138
self .irc_raw = base_event .irc_raw
139
+ self .irc_tags = base_event .irc_tags
117
140
self .irc_prefix = base_event .irc_prefix
118
141
self .irc_command = base_event .irc_command
119
142
self .irc_paramlist = base_event .irc_paramlist
@@ -131,6 +154,7 @@ def __init__(self, *, bot=None, hook=None, conn=None, base_event=None, event_typ
131
154
self .mask = mask
132
155
# clients-specific parameters
133
156
self .irc_raw = irc_raw
157
+ self .irc_tags = irc_tags
134
158
self .irc_prefix = irc_prefix
135
159
self .irc_command = irc_command
136
160
self .irc_paramlist = irc_paramlist
@@ -271,9 +295,7 @@ def reply(self, *messages, target=None):
271
295
reply_ping = self .conn .config .get ("reply_ping" , True )
272
296
if target is None :
273
297
if self .chan is None :
274
- raise ValueError (
275
- "Target must be specified when chan is not assigned"
276
- )
298
+ raise ValueError ("Target must be specified when chan is not assigned" )
277
299
278
300
target = self .chan
279
301
@@ -283,9 +305,9 @@ def reply(self, *messages, target=None):
283
305
if target == self .nick or not reply_ping :
284
306
self .conn .message (target , * messages )
285
307
else :
286
- self .conn .message (target , "({}) {}" . format (
287
- self .nick , messages [0 ]
288
- ), * messages [ 1 :])
308
+ self .conn .message (
309
+ target , "({}) {}" . format ( self .nick , messages [0 ]), * messages [ 1 : ]
310
+ )
289
311
290
312
def action (self , message , target = None ):
291
313
"""sends an action to the current channel/user
@@ -295,9 +317,7 @@ def action(self, message, target=None):
295
317
"""
296
318
if target is None :
297
319
if self .chan is None :
298
- raise ValueError (
299
- "Target must be specified when chan is not assigned"
300
- )
320
+ raise ValueError ("Target must be specified when chan is not assigned" )
301
321
302
322
target = self .chan
303
323
@@ -311,9 +331,7 @@ def ctcp(self, message, ctcp_type, target=None):
311
331
"""
312
332
if target is None :
313
333
if self .chan is None :
314
- raise ValueError (
315
- "Target must be specified when chan is not assigned"
316
- )
334
+ raise ValueError ("Target must be specified when chan is not assigned" )
317
335
318
336
target = self .chan
319
337
@@ -349,9 +367,7 @@ def has_permission(self, permission, notice=True):
349
367
if not self .mask :
350
368
raise ValueError ("has_permission requires mask is not assigned" )
351
369
352
- return self .conn .permissions .has_perm_mask (
353
- self .mask , permission , notice = notice
354
- )
370
+ return self .conn .permissions .has_perm_mask (self .mask , permission , notice = notice )
355
371
356
372
async def check_permission (self , permission , notice = True ):
357
373
""" returns whether or not the current user has a given permission
@@ -363,9 +379,7 @@ async def check_permission(self, permission, notice=True):
363
379
return True
364
380
365
381
for perm_hook in self .bot .plugin_manager .perm_hooks [permission ]:
366
- ok , res = await self .bot .plugin_manager .internal_launch (
367
- perm_hook , self
368
- )
382
+ ok , res = await self .bot .plugin_manager .internal_launch (perm_hook , self )
369
383
if ok and res :
370
384
return True
371
385
@@ -404,23 +418,54 @@ class CommandEvent(Event):
404
418
:type triggered_command: str
405
419
"""
406
420
407
- def __init__ (self , * , bot = None , hook , text , triggered_command , cmd_prefix ,
408
- conn = None , base_event = None , event_type = None , content = None ,
409
- content_raw = None , target = None , channel = None , nick = None ,
410
- user = None , host = None , mask = None , irc_raw = None , irc_prefix = None ,
411
- irc_command = None , irc_paramlist = None ):
421
+ def __init__ (
422
+ self ,
423
+ * ,
424
+ bot = None ,
425
+ hook ,
426
+ text ,
427
+ triggered_command ,
428
+ cmd_prefix ,
429
+ conn = None ,
430
+ base_event = None ,
431
+ event_type = None ,
432
+ content = None ,
433
+ content_raw = None ,
434
+ target = None ,
435
+ channel = None ,
436
+ nick = None ,
437
+ user = None ,
438
+ host = None ,
439
+ mask = None ,
440
+ irc_raw = None ,
441
+ irc_prefix = None ,
442
+ irc_command = None ,
443
+ irc_paramlist = None
444
+ ):
412
445
"""
413
446
:param text: The arguments for the command
414
447
:param triggered_command: The command that was triggered
415
448
:type text: str
416
449
:type triggered_command: str
417
450
"""
418
451
super ().__init__ (
419
- bot = bot , hook = hook , conn = conn , base_event = base_event ,
420
- event_type = event_type , content = content , content_raw = content_raw ,
421
- target = target , channel = channel , nick = nick , user = user , host = host ,
422
- mask = mask , irc_raw = irc_raw , irc_prefix = irc_prefix ,
423
- irc_command = irc_command , irc_paramlist = irc_paramlist
452
+ bot = bot ,
453
+ hook = hook ,
454
+ conn = conn ,
455
+ base_event = base_event ,
456
+ event_type = event_type ,
457
+ content = content ,
458
+ content_raw = content_raw ,
459
+ target = target ,
460
+ channel = channel ,
461
+ nick = nick ,
462
+ user = user ,
463
+ host = host ,
464
+ mask = mask ,
465
+ irc_raw = irc_raw ,
466
+ irc_prefix = irc_prefix ,
467
+ irc_command = irc_command ,
468
+ irc_paramlist = irc_paramlist ,
424
469
)
425
470
self .hook = hook
426
471
self .text = text
@@ -455,21 +500,50 @@ class RegexEvent(Event):
455
500
:type match: re.__Match
456
501
"""
457
502
458
- def __init__ (self , * , bot = None , hook , match , conn = None , base_event = None ,
459
- event_type = None , content = None , content_raw = None , target = None ,
460
- channel = None , nick = None , user = None , host = None , mask = None ,
461
- irc_raw = None , irc_prefix = None , irc_command = None ,
462
- irc_paramlist = None ):
503
+ def __init__ (
504
+ self ,
505
+ * ,
506
+ bot = None ,
507
+ hook ,
508
+ match ,
509
+ conn = None ,
510
+ base_event = None ,
511
+ event_type = None ,
512
+ content = None ,
513
+ content_raw = None ,
514
+ target = None ,
515
+ channel = None ,
516
+ nick = None ,
517
+ user = None ,
518
+ host = None ,
519
+ mask = None ,
520
+ irc_raw = None ,
521
+ irc_prefix = None ,
522
+ irc_command = None ,
523
+ irc_paramlist = None
524
+ ):
463
525
"""
464
526
:param: match: The match objected returned by the regex search method
465
527
:type match: re.__Match
466
528
"""
467
529
super ().__init__ (
468
- bot = bot , conn = conn , hook = hook , base_event = base_event ,
469
- event_type = event_type , content = content , content_raw = content_raw ,
470
- target = target , channel = channel , nick = nick , user = user , host = host ,
471
- mask = mask , irc_raw = irc_raw , irc_prefix = irc_prefix ,
472
- irc_command = irc_command , irc_paramlist = irc_paramlist
530
+ bot = bot ,
531
+ conn = conn ,
532
+ hook = hook ,
533
+ base_event = base_event ,
534
+ event_type = event_type ,
535
+ content = content ,
536
+ content_raw = content_raw ,
537
+ target = target ,
538
+ channel = channel ,
539
+ nick = nick ,
540
+ user = user ,
541
+ host = host ,
542
+ mask = mask ,
543
+ irc_raw = irc_raw ,
544
+ irc_prefix = irc_prefix ,
545
+ irc_command = irc_command ,
546
+ irc_paramlist = irc_paramlist ,
473
547
)
474
548
self .match = match
475
549
@@ -493,9 +567,7 @@ async def prepare(self):
493
567
try :
494
568
self .parsed_line = Message .parse (self .line )
495
569
except Exception :
496
- logger .exception (
497
- "Unable to parse line requested by hook %s" , self .hook
498
- )
570
+ logger .exception ("Unable to parse line requested by hook %s" , self .hook )
499
571
self .parsed_line = None
500
572
501
573
def prepare_threaded (self ):
@@ -505,9 +577,7 @@ def prepare_threaded(self):
505
577
try :
506
578
self .parsed_line = Message .parse (self .line )
507
579
except Exception :
508
- logger .exception (
509
- "Unable to parse line requested by hook %s" , self .hook
510
- )
580
+ logger .exception ("Unable to parse line requested by hook %s" , self .hook )
511
581
self .parsed_line = None
512
582
513
583
@property
@@ -516,8 +586,15 @@ def line(self):
516
586
517
587
518
588
class PostHookEvent (Event ):
519
- def __init__ (self , * args , launched_hook = None , launched_event = None ,
520
- result = None , error = None , ** kwargs ):
589
+ def __init__ (
590
+ self ,
591
+ * args ,
592
+ launched_hook = None ,
593
+ launched_event = None ,
594
+ result = None ,
595
+ error = None ,
596
+ ** kwargs
597
+ ):
521
598
super ().__init__ (* args , ** kwargs )
522
599
self .launched_hook = launched_hook
523
600
self .launched_event = launched_event
0 commit comments