@@ -254,18 +254,18 @@ def load_plugin(self, path):
254254 self .connect_hooks .append (connect_hook )
255255 self ._log_hook (connect_hook )
256256
257- # sort sieve hooks by priority
258- self .sieves . sort ( key = lambda x : x . priority )
259- self .connect_hooks . sort ( key = attrgetter ( "priority" ) )
257+ for out_hook in plugin . irc_out_hooks :
258+ self .out_sieves . append ( out_hook )
259+ self ._log_hook ( out_hook )
260260
261261 # Sort hooks
262262 self .regex_hooks .sort (key = lambda x : x [1 ].priority )
263263 dicts_of_lists_of_hooks = (self .event_type_hooks , self .raw_triggers )
264- lists_of_hooks = [self .catch_all_triggers , self .sieves ]
264+ lists_of_hooks = [self .catch_all_triggers , self .sieves , self . connect_hooks , self . out_sieves ]
265265 lists_of_hooks .extend (chain .from_iterable (d .values () for d in dicts_of_lists_of_hooks ))
266266
267267 for lst in lists_of_hooks :
268- lst .sort (key = lambda x : x . priority )
268+ lst .sort (key = attrgetter ( " priority" ) )
269269
270270 # we don't need this anymore
271271 del plugin .run_on_start
@@ -351,6 +351,9 @@ def unload_plugin(self, path):
351351 for connect_hook in plugin .connect_hooks :
352352 self .connect_hooks .remove (connect_hook )
353353
354+ for out_hook in plugin .irc_out_hooks :
355+ self .out_sieves .remove (out_hook )
356+
354357 # Run on_stop hooks
355358 for on_stop_hook in plugin .run_on_stop :
356359 event = Event (bot = self .bot , hook = on_stop_hook )
@@ -592,7 +595,7 @@ def __init__(self, filepath, filename, title, code):
592595 self .commands , self .regexes , self .raw_hooks , * hooks = hooks
593596 self .sieves , self .events , self .periodic , * hooks = hooks
594597 self .run_on_start , self .run_on_stop , self .on_cap_ack , * hooks = hooks
595- self .on_cap_available , self .connect_hooks , * hooks = hooks
598+ self .on_cap_available , self .connect_hooks , self . irc_out_hooks , * hooks = hooks
596599 # we need to find tables for each plugin so that they can be unloaded from the global metadata when the
597600 # plugin is reloaded
598601 self .tables = find_tables (code )
0 commit comments