@@ -228,8 +228,14 @@ def load_plugin(self, path):
228228 self .sieves .append (sieve_hook )
229229 self ._log_hook (sieve_hook )
230230
231- # sort sieve hooks by priority
232- self .sieves .sort (key = lambda x : x .priority )
231+ # Sort hooks
232+ self .regex_hooks .sort (key = lambda x : x [1 ].priority )
233+ dicts_of_lists_of_hooks = (self .event_type_hooks , self .raw_triggers )
234+ lists_of_hooks = [self .catch_all_triggers , self .sieves ]
235+ lists_of_hooks .extend (d .values () for d in dicts_of_lists_of_hooks )
236+
237+ for lst in lists_of_hooks :
238+ lst .sort (key = lambda x : x .priority )
233239
234240 # we don't need this anymore
235241 del plugin .run_on_start
@@ -596,6 +602,7 @@ def __init__(self, _type, plugin, func_hook):
596602 self .permissions = func_hook .kwargs .pop ("permissions" , [])
597603 self .single_thread = func_hook .kwargs .pop ("singlethread" , False )
598604 self .action = func_hook .kwargs .pop ("action" , Action .CONTINUE )
605+ self .priority = func_hook .kwargs .pop ("priority" , Priority .NORMAL )
599606
600607 if func_hook .kwargs :
601608 # we should have popped all the args, so warn if there are any left
@@ -652,7 +659,6 @@ def __init__(self, plugin, regex_hook):
652659 :type regex_hook: cloudbot.util.hook._RegexHook
653660 """
654661 self .run_on_cmd = regex_hook .kwargs .pop ("run_on_cmd" , False )
655- self .priority = regex_hook .kwargs .pop ("priority" , Priority .NORMAL )
656662 self .only_no_match = regex_hook .kwargs .pop ("only_no_match" , False )
657663
658664 self .regexes = regex_hook .regexes
0 commit comments