summaryrefslogtreecommitdiff
path: root/poezio/core/command_defs.py
blob: 770b349265afb1a489f352567360ffa25217a843 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
from typing import Callable, List, Optional

from poezio.core.commands import CommandCore
from poezio.core.completions import CompletionCore
from poezio.plugin_manager import PluginManager
from poezio.types import TypedDict


CommandDict = TypedDict(
    "CommandDict",
    {
        "name": str,
        "func": Callable,
        "shortdesc": str,
        "desc": str,
        "usage": str,
        "completion": Optional[Callable],
    },
    total=False,
)


def get_commands(commands: CommandCore, completions: CompletionCore, plugin_manager: PluginManager) -> List[CommandDict]:
    """
    Get the set of default poezio commands.
    """
    return [
        {
            "name": "help",
            "func": commands.help,
            "usage": "[command]",
            "shortdesc": "\\_o< KOIN KOIN KOIN",
            "completion": completions.help,
        },
        {
            "name": "join",
            "func": commands.join,
            "usage": "[room_name][@server][/nick] [password]",
            "desc": (
                "Join the specified room. You can specify a nickname "
                "after a slash (/). If no nickname is specified, you will"
                " use the default_nick in the configuration file. You can"
                " omit the room name: you will then join the room you're"
                " looking at (useful if you were kicked). You can also "
                "provide a room_name without specifying a server, the "
                "server of the room you're currently in will be used. You"
                " can also provide a password to join the room.\nExamples"
                ":\n/join room@server.tld\n/join room@server.tld/John\n"
                "/join room2\n/join /me_again\n/join\n/join room@server"
                ".tld/my_nick password\n/join / password"
            ),
            "shortdesc": "Join a room",
            "completion": completions.join,
        },
        {
            "name": "exit",
            "func": commands.quit,
            "desc": "Just disconnect from the server and exit poezio.",
            "shortdesc": "Exit poezio.",
        },
        {
            "name": "quit",
            "func": commands.quit,
            "desc": "Just disconnect from the server and exit poezio.",
            "shortdesc": "Exit poezio.",
        },
        {
            "name": "next",
            "func": commands.rotate_rooms_right,
            "shortdesc": "Go to the next room.",
        },
        {
            "name": "prev",
            "func": commands.rotate_rooms_left,
            "shortdesc": "Go to the previous room.",
        },
        {
            "name": "win",
            "func": commands.win,
            "usage": "<number or name>",
            "shortdesc": "Go to the specified room",
            "completion": completions.win,
        },
        {
            "name": "w",
            "func": commands.win,
            "usage": "<number or name>",
            "shortdesc": "Go to the specified room",
            "completion": completions.win,
        },
        {
            "name": "wup",
            "func": commands.wup,
            "usage": "<prefix>",
            "shortdesc": "Go to the tab whose name uniquely starts with prefix",
            "completion": completions.win,
        },
        {
            "name": "move_tab",
            "func": commands.move_tab,
            "usage": "<source> <destination>",
            "desc": (
                "Insert the <source> tab at the position of "
                "<destination>. This will make the following tabs shift in"
                " some cases (refer to the documentation). A tab can be "
                "designated by its number or by the beginning of its "
                'address. You can use "." as a shortcut for the current '
                "tab."
            ),
            "shortdesc": "Move a tab.",
            "completion": completions.move_tab,
        },
        {
            "name": "destroy_room",
            "func": commands.destroy_room,
            "usage": "[room JID]",
            "desc": (
                "Try to destroy the room [room JID], or the current"
                " tab if it is a multi-user chat and [room JID] is "
                "not given."
            ),
            "shortdesc": "Destroy a room.",
            "completion": None,
        },
        {
            "name": "status",
            "func": commands.status,
            "usage": "<availability> [status message]",
            "desc": (
                "Sets your availability and (optionally) your status "
                'message. The <availability> argument is one of "available'
                ', chat, away, afk, dnd, busy, xa" and the optional '
                "[status message] argument will be your status message."
            ),
            "shortdesc": "Change your availability.",
            "completion": completions.status,
        },
        {
            "name": "show",
            "func": commands.status,
            "usage": "<availability> [status message]",
            "desc": (
                "Sets your availability and (optionally) your status "
                'message. The <availability> argument is one of "available'
                ', chat, away, afk, dnd, busy, xa" and the optional '
                "[status message] argument will be your status message."
            ),
            "shortdesc": "Change your availability.",
            "completion": completions.status,
        },
        {
            "name": "bookmark_local",
            "func": commands.bookmark_local,
            "usage": "[roomname][/nick] [password]",
            "desc": (
                "Bookmark Local: Bookmark locally the specified room "
                "(you will then auto-join it on each poezio start). This"
                " commands uses almost the same syntaxe as /join. Type "
                "/help join for syntax examples. Note that when typing "
                '"/bookmark" on its own, the room will be bookmarked '
                "with the nickname you're currently using in this room "
                "(instead of default_nick)"
            ),
            "shortdesc": "Bookmark a room locally.",
            "completion": completions.bookmark_local,
        },
        {
            "name": "bookmark",
            "func": commands.bookmark,
            "usage": "[roomname][/nick] [autojoin] [password]",
            "desc": (
                "Bookmark: Bookmark online the specified room (you "
                "will then auto-join it on each poezio start if autojoin"
                " is specified and is 'true'). This commands uses almost"
                " the same syntax as /join. Type /help join for syntax "
                'examples. Note that when typing "/bookmark" alone, the'
                " room will be bookmarked with the nickname you're "
                "currently using in this room (instead of default_nick)."
            ),
            "shortdesc": "Bookmark a room online.",
            "completion": completions.bookmark,
        },
        {
            "name": "accept",
            "func": commands.accept,
            "usage": "[jid]",
            "desc": (
                "Allow the provided JID (or the selected contact "
                "in your roster), to see your presence."
            ),
            "shortdesc": "Allow a user your presence.",
            "completion": completions.roster_barejids,
        },
        {
            "name": "add",
            "func": commands.add,
            "usage": "<jid>",
            "desc": (
                "Add the specified JID to your roster, ask them to"
                " allow you to see his presence, and allow them to"
                " see your presence."
            ),
            "shortdesc": "Add a user to your roster.",
        },
        {
            "name": "deny",
            "func": commands.deny,
            "usage": "[jid]",
            "desc": (
                "Deny your presence to the provided JID (or the "
                "selected contact in your roster), who is asking"
                "you to be in their roster."
            ),
            "shortdesc": "Deny a user your presence.",
            "completion": completions.roster_barejids,
        },
        {
            "name": "remove",
            "func": commands.remove,
            "usage": "[jid]",
            "desc": (
                "Remove the specified JID from your roster. This "
                "will unsubscribe you from its presence, cancel "
                "its subscription to yours, and remove the item "
                "from your roster."
            ),
            "shortdesc": "Remove a user from your roster.",
            "completion": completions.remove,
        },
        {
            "name": "reconnect",
            "func": commands.command_reconnect,
            "usage": "[reconnect]",
            "desc": (
                "Disconnect from the remote server if you are "
                "currently connected and then connect to it again."
            ),
            "shortdesc": "Disconnect and reconnect to the server.",
        },
        {
            "name": "set",
            "func": commands.set,
            "usage": "[plugin|][section] <option> [value]",
            "desc": (
                "Set the value of an option in your configuration file."
                " You can, for example, change your default nickname by "
                "doing `/set default_nick toto` or your resource with `/set"
                " resource blabla`. You can also set options in specific "
                "sections with `/set bindings M-i ^i` or in specific plugin"
                " with `/set mpd_client| host 127.0.0.1`. `toggle` can be "
                "used as a special value to toggle a boolean option."
            ),
            "shortdesc": "Set the value of an option",
            "completion": completions.set,
        },
        {
            "name": "set_default",
            "func": commands.set_default,
            "usage": "[section] <option>",
            "desc": (
                "Set the default value of an option. For example, "
                "`/set_default resource` will reset the resource "
                "option. You can also reset options in specific "
                "sections by doing `/set_default section option`."
            ),
            "shortdesc": "Set the default value of an option",
            "completion": completions.set_default,
        },
        {
            "name": "toggle",
            "func": commands.toggle,
            "usage": "<option>",
            "desc": "Shortcut for /set <option> toggle",
            "shortdesc": "Toggle an option",
            "completion": completions.toggle,
        },
        {
            "name": "theme",
            "func": commands.theme,
            "usage": "[theme name]",
            "desc": (
                "Reload the theme defined in the config file. If theme"
                "_name is provided, set that theme before reloading it."
            ),
            "shortdesc": "Load a theme",
            "completion": completions.theme,
        },
        {
            "name": "list",
            "func": commands.list,
            "usage": "[server]",
            "desc": "Get the list of public rooms" " on the specified server.",
            "shortdesc": "List the rooms.",
            "completion": completions.list,
        },
        {
            "name": "message",
            "func": commands.message,
            "usage": "<jid> [optional message]",
            "desc": (
                "Open a conversation with the specified JID (even if it"
                " is not in our roster), and send a message to it, if the "
                "message is specified."
            ),
            "shortdesc": "Send a message",
            "completion": completions.message,
        },
        {
            "name": "version",
            "func": commands.version,
            "usage": "<jid>",
            "desc": (
                "Get the software version of the given JID (usually its"
                " XMPP client and Operating System)."
            ),
            "shortdesc": "Get the software version of a JID.",
            "completion": completions.version,
        },
        {
            "name": "server_cycle",
            "func": commands.server_cycle,
            "usage": "[domain] [message]",
            "desc": "Disconnect and reconnect in all the rooms in domain.",
            "shortdesc": "Cycle a range of rooms",
            "completion": completions.server_cycle,
        },
        {
            "name": "bind",
            "func": commands.bind,
            "usage": "<key> <equ>",
            "desc": (
                "Bind a key to another key or to a “command”. For "
                'example "/bind ^H KEY_UP" makes Control + h do the'
                " same same as the Up key."
            ),
            "completion": completions.bind,
            "shortdesc": "Bind a key to another key.",
        },
        {
            "name": "load",
            "func": commands.load,
            "usage": "<plugin> [<otherplugin> …]",
            "shortdesc": "Load the specified plugin(s)",
            "completion": plugin_manager.completion_load,
        },
        {
            "name": "unload",
            "func": commands.unload,
            "usage": "<plugin> [<otherplugin> …]",
            "shortdesc": "Unload the specified plugin(s)",
            "completion": plugin_manager.completion_unload,
        },
        {
            "name": "plugins",
            "func": commands.plugins,
            "shortdesc": "Show the plugins in use.",
        },
        {
            "name": "presence",
            "func": commands.presence,
            "usage": "<JID> [type] [status]",
            "desc": "Send a directed presence to <JID> and using"
            " [type] and [status] if provided.",
            "shortdesc": "Send a directed presence.",
            "completion": completions.presence,
        },
        {
            "name": "rawxml",
            "func": commands.rawxml,
            "usage": "<xml>",
            "shortdesc": "Send a custom xml stanza.",
        },
        {
            "name": "invite",
            "func": commands.invite,
            "usage": "<jid> <room> [reason]",
            "desc": "Invite jid in room with reason.",
            "shortdesc": "Invite someone in a room.",
            "completion": completions.invite,
        },
        {
            "name": "impromptu",
            "func": commands.impromptu,
            "usage": "<jid> [jid ...]",
            "desc": "Invite specified JIDs into a newly created room.",
            "shortdesc": "Invite specified JIDs into newly created room.",
            "completion": completions.impromptu,
        },
        {
            "name": "invitations",
            "func": commands.invitations,
            "shortdesc": "Show the pending invitations.",
        },
        {
            "name": "bookmarks",
            "func": commands.bookmarks,
            "shortdesc": "Show the current bookmarks.",
        },
        {
            "name": "remove_bookmark",
            "func": commands.remove_bookmark,
            "usage": "[jid]",
            "desc": "Remove the specified bookmark, or the "
            "bookmark on the current tab, if any.",
            "shortdesc": "Remove a bookmark",
            "completion": completions.remove_bookmark,
        },
        {
            "name": "xml_tab",
            "func": commands.xml_tab,
            "shortdesc": "Open an XML tab.",
        },
        {
            "name": "runkey",
            "func": commands.runkey,
            "usage": "<key>",
            "shortdesc": "Execute the action defined for <key>.",
            "completion": completions.runkey,
        },
        {
            "name": "self",
            "func": commands.self_,
            "shortdesc": "Remind you of who you are.",
        },
        {
            "name": "last_activity",
            "func": commands.last_activity,
            "usage": "<jid>",
            "desc": "Informs you of the last activity of a JID.",
            "shortdesc": "Get the activity of someone.",
            "completion": completions.last_activity,
        },
        {
            "name": "ad-hoc",
            "func": commands.adhoc,
            "usage": "<jid>",
            "shortdesc": "List available ad-hoc commands on the given jid",
        },
        {
            "name": "reload",
            "func": commands.reload,
            "shortdesc": "Reload the config. You can achieve the same by "
            "sending SIGUSR1 to poezio.",
        },
        {
            "name": "debug",
            "func": commands.debug,
            "usage": "[debug_filename]",
            "shortdesc": "Enable or disable debug logging according to the "
            "presence of [debug_filename].",
        },
    ]