16
16
17
17
if False :
18
18
from mypy_extensions import NoReturn
19
- from typing import Any , Optional , List , Dict , IO , Text , Set , Sequence
19
+ from typing import Any , Optional , List , Dict , IO , Text , Set , Sequence , Tuple , Callable
20
20
from types import ModuleType
21
21
22
22
from zulip import Client , ZulipError
@@ -187,14 +187,14 @@ def open(self, filepath):
187
187
"files in their local directory." .format (abs_filepath ))
188
188
189
189
def dispatch_default_commands (self , message , command_list , meta , other_commands = None ):
190
- # type: (Dict[str, Any], Sequence[Text], Dict[Text, Text], Optional[Mapping[Text, Text]]) -> Optional[Text]
190
+ # type: (Dict[str, Any], Sequence[Text], Dict[Text, Text], Optional[Mapping[Text, Tuple[ Text, Optional[Callable[[], Text]]] ]]) -> Optional[Text]
191
191
supported_commands = OrderedDict ([
192
192
("" , "" ), # No help text, as this shouldn't appear in commands/help
193
193
("about" , "The brief type and use of this bot." ),
194
194
("commands" , "A short list of the supported commands." ),
195
195
("help" , "This help text." ),
196
196
])
197
- ["" , "about" , "commands" , "help" ] # TODO: 'custom'
197
+ ["" , "about" , "commands" , "help" ]
198
198
199
199
# Check command_list has supported commands
200
200
for requested_command in command_list :
@@ -219,11 +219,14 @@ def dispatch_default_commands(self, message, command_list, meta, other_commands=
219
219
elif command == "help" :
220
220
cmd_list = OrderedDict ([(cmd , supported_commands [cmd ]) for cmd in command_list if cmd != "" ])
221
221
if other_commands is not None :
222
- cmd_list .update (other_commands )
222
+ cmd_list .update (OrderedDict ([( c , h [ 0 ]) for c , h in other_commands . items ()]) )
223
223
help_text = ("**{name}**: {description}" .format (** meta )+
224
224
"\n This bot supports the following commands:\n " +
225
225
"\n " .join (["**{}** - {}" .format (c , h ) for c , h in cmd_list .items ()]))
226
226
return help_text
227
+ if other_commands is not None and command in other_commands :
228
+ if other_commands [command ][1 ] is not None :
229
+ return other_commands [command ][1 ]()
227
230
return None
228
231
229
232
def extract_query_without_mention (message , client ):
0 commit comments