@@ -37,27 +37,22 @@ def echo(ctx, msg, data): # pylint: disable=missing-docstring
37
37
def admin (ctx , msg , frame ):
38
38
"""Handle /admin BOTNAME echo."""
39
39
40
- modconf = frame . value
41
- command , _ , text = frame .text . partition ( ' ' )
42
- command = command . lower ( )
43
-
44
- if not command :
40
+ menu = adminui . Menu ()
41
+ for command , data in sorted ( frame .value . items ()):
42
+ menu . add ( command , desc = data . get ( 'text' , '' ). replace ( ' \n ' , ' ' ) )
43
+ frame , handler = menu . select ( ctx , msg , frame , create = True )
44
+ if not handler :
45
45
msg .action = 'Choose a command'
46
46
msg .add (
47
47
"Type the name of a command to add (like <code>rules</code>\u2014 don't include a slash "
48
48
'at the beginning!), or select an existing echo.' )
49
- for command , data in sorted (modconf .items ()):
50
- title = '/' + command
51
- if data .get ('text' ):
52
- title = '%s (%s)' % (title , data ['text' ].replace ('\n ' , ' ' ))
53
- msg .button (title , command )
54
- return
49
+ return menu .display (ctx , msg , frame , 'command' )
55
50
56
- msg .path (command )
51
+ msg .path (frame . field )
57
52
58
53
adminui .Menu (
59
54
('text' , adminui .freeform ,
60
- 'The message, sticker, or image to send in response to /%s.' % command ),
55
+ 'The message, sticker, or image to send in response to /%s.' % frame . field ),
61
56
('paginate' , adminui .bool , 'For multiline messages, display just one line at a time?' ),
62
57
('private' , adminui .bool , 'Send the message in group chats, or just in private?' ),
63
- ).handle (ctx , msg , adminui . Frame ( modconf , command , None , text ) )
58
+ ).handle (ctx , msg , frame )
0 commit comments