@@ -44,9 +44,10 @@ def decorator_message(func):
4444
4545def CommandHandlerDecorator (_func = None , command = None , * args , ** kwargs ):
4646 def decorator_command (func ):
47- if not isinstance (command ,str ):
48- command = func .__name__
49- return CommandHandler (command ,func ,* args ,** kwargs )
47+ command_ = command
48+ if not isinstance (command_ ,str ):
49+ command_ = func .__name__
50+ return CommandHandler (command_ ,func ,* args ,** kwargs )
5051
5152 if _func :
5253 return decorator_command (_func )
@@ -59,11 +60,12 @@ def __init__(self, dispatcher:Dispatcher):
5960
6061 def commandHandler (self , _func = None , command = None , group = 1 , * args , ** kwargs ):
6162 def decorator_command (func ):
62- if not isinstance (command ,str ):
63- command = func .__name__
64- logging .debug (f'add command handler. command:{ command } => { func } ' )
63+ command_ = command
64+ if not isinstance (command_ , str ):
65+ command_ = func .__name__
66+ logging .debug (f'add command handler. command:{ command_ } => { func } ' )
6567 try :
66- self .dispatcher .add_handler (CommandHandler (command ,func ,* args ,** kwargs ), group )
68+ self .dispatcher .add_handler (CommandHandler (command_ ,func ,* args ,** kwargs ), group )
6769 except :
6870 logging .exception ('exception while trying to add a command' )
6971 BugReporter .exception ('exception while trying to add a command' )
@@ -76,7 +78,7 @@ def decorator_command(func):
7678 else :
7779 return decorator_command
7880
79- def messageHandler (self , _func = None , filters = Filters .all , group = 1 , * args , ** kwargs ):
81+ def messageHandler (self , filters = Filters .all , group = 1 , * args , ** kwargs ):
8082 def decorator_message (func ):
8183 logging .debug (f'add message handler. handler: { func } ' )
8284 try :
@@ -86,11 +88,7 @@ def decorator_message(func):
8688 BugReporter .exception ('exception while trying to add a command' )
8789
8890 return func
89-
90- if _func :
91- return decorator_message (_func )
92- else :
93- return decorator_message
91+ return decorator_message
9492
9593 def addHandler (self , handler_ :Handler = None , group = 1 ):
9694 def decorator_handler (handler :Handler ):
@@ -135,4 +133,8 @@ def fallback(self, handler:Handler):
135133 return handler
136134
137135 def get_handler (self ):
138- return ConversationHandler (self .entry_points , self .state , self .fallbacks , ** self .__kwargs )
136+ return ConversationHandler (
137+ entry_points = self .entry_points ,
138+ states = self .states ,
139+ fallbacks = self .fallbacks ,
140+ ** self .__kwargs )
0 commit comments