@@ -41,11 +41,32 @@ class Event(Mapping[str, Any]):
4141 :type irc_command: str
4242 :type irc_paramlist: list[str]
4343 :type irc_ctcp_text: str
44+ :type irc_tags: irclib.parser.TagList
4445 """
4546
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+ ):
4970 """
5071 All of these parameters except for `bot` and `hook` are optional.
5172 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
87108 :type irc_command: str
88109 :type irc_paramlist: list[str]
89110 :type irc_ctcp_text: str
111+ :type irc_tags: irclib.parser.TagList
90112 """
91113 self .db = None
92114 self .db_executor = None
@@ -114,6 +136,7 @@ def __init__(self, *, bot=None, hook=None, conn=None, base_event=None, event_typ
114136 self .mask = base_event .mask
115137 # clients-specific parameters
116138 self .irc_raw = base_event .irc_raw
139+ self .irc_tags = base_event .irc_tags
117140 self .irc_prefix = base_event .irc_prefix
118141 self .irc_command = base_event .irc_command
119142 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
131154 self .mask = mask
132155 # clients-specific parameters
133156 self .irc_raw = irc_raw
157+ self .irc_tags = irc_tags
134158 self .irc_prefix = irc_prefix
135159 self .irc_command = irc_command
136160 self .irc_paramlist = irc_paramlist
@@ -271,9 +295,7 @@ def reply(self, *messages, target=None):
271295 reply_ping = self .conn .config .get ("reply_ping" , True )
272296 if target is None :
273297 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" )
277299
278300 target = self .chan
279301
@@ -283,9 +305,9 @@ def reply(self, *messages, target=None):
283305 if target == self .nick or not reply_ping :
284306 self .conn .message (target , * messages )
285307 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+ )
289311
290312 def action (self , message , target = None ):
291313 """sends an action to the current channel/user
@@ -295,9 +317,7 @@ def action(self, message, target=None):
295317 """
296318 if target is None :
297319 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" )
301321
302322 target = self .chan
303323
@@ -311,9 +331,7 @@ def ctcp(self, message, ctcp_type, target=None):
311331 """
312332 if target is None :
313333 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" )
317335
318336 target = self .chan
319337
@@ -349,9 +367,7 @@ def has_permission(self, permission, notice=True):
349367 if not self .mask :
350368 raise ValueError ("has_permission requires mask is not assigned" )
351369
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 )
355371
356372 async def check_permission (self , permission , notice = True ):
357373 """ returns whether or not the current user has a given permission
@@ -363,9 +379,7 @@ async def check_permission(self, permission, notice=True):
363379 return True
364380
365381 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 )
369383 if ok and res :
370384 return True
371385
@@ -404,23 +418,54 @@ class CommandEvent(Event):
404418 :type triggered_command: str
405419 """
406420
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+ ):
412445 """
413446 :param text: The arguments for the command
414447 :param triggered_command: The command that was triggered
415448 :type text: str
416449 :type triggered_command: str
417450 """
418451 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 ,
424469 )
425470 self .hook = hook
426471 self .text = text
@@ -455,21 +500,50 @@ class RegexEvent(Event):
455500 :type match: re.__Match
456501 """
457502
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+ ):
463525 """
464526 :param: match: The match objected returned by the regex search method
465527 :type match: re.__Match
466528 """
467529 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 ,
473547 )
474548 self .match = match
475549
@@ -493,9 +567,7 @@ async def prepare(self):
493567 try :
494568 self .parsed_line = Message .parse (self .line )
495569 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 )
499571 self .parsed_line = None
500572
501573 def prepare_threaded (self ):
@@ -505,9 +577,7 @@ def prepare_threaded(self):
505577 try :
506578 self .parsed_line = Message .parse (self .line )
507579 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 )
511581 self .parsed_line = None
512582
513583 @property
@@ -516,8 +586,15 @@ def line(self):
516586
517587
518588class 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+ ):
521598 super ().__init__ (* args , ** kwargs )
522599 self .launched_hook = launched_hook
523600 self .launched_event = launched_event
0 commit comments