Split core commands into its own (broken) class.
This commit is contained in:
parent
815cd46be9
commit
37cd7d1924
1 changed files with 915 additions and 911 deletions
|
@ -30,8 +30,12 @@ from decorators import command_args_parser
|
|||
from . structs import Command, POSSIBLE_SHOW
|
||||
|
||||
|
||||
@command_args_parser.quoted(0, 1)
|
||||
def command_help(self, args):
|
||||
class CommandCore:
|
||||
def __init__(self, core):
|
||||
self.core = core
|
||||
|
||||
@command_args_parser.quoted(0, 1)
|
||||
def command_help(self, args):
|
||||
"""
|
||||
/help [command_name]
|
||||
"""
|
||||
|
@ -82,8 +86,8 @@ def command_help(self, args):
|
|||
msg = tup[1]
|
||||
self.information(msg, 'Help')
|
||||
|
||||
@command_args_parser.quoted(1)
|
||||
def command_runkey(self, args):
|
||||
@command_args_parser.quoted(1)
|
||||
def command_runkey(self, args):
|
||||
"""
|
||||
/runkey <key>
|
||||
"""
|
||||
|
@ -103,8 +107,8 @@ def command_runkey(self, args):
|
|||
if res:
|
||||
self.refresh_window()
|
||||
|
||||
@command_args_parser.quoted(1, 1, [None])
|
||||
def command_status(self, args):
|
||||
@command_args_parser.quoted(1, 1, [None])
|
||||
def command_status(self, args):
|
||||
"""
|
||||
/status <status> [msg]
|
||||
"""
|
||||
|
@ -136,8 +140,8 @@ def command_status(self, args):
|
|||
if is_muctab and current.joined and show not in ('away', 'xa'):
|
||||
current.send_chat_state('active')
|
||||
|
||||
@command_args_parser.quoted(1, 2, [None, None])
|
||||
def command_presence(self, args):
|
||||
@command_args_parser.quoted(1, 2, [None, None])
|
||||
def command_presence(self, args):
|
||||
"""
|
||||
/presence <JID> [type] [status]
|
||||
"""
|
||||
|
@ -173,15 +177,15 @@ def command_presence(self, args):
|
|||
if self.current_tab() in tab.privates:
|
||||
self.current_tab().send_chat_state(chatstate, True)
|
||||
|
||||
@command_args_parser.quoted(1)
|
||||
def command_theme(self, args=None):
|
||||
@command_args_parser.quoted(1)
|
||||
def command_theme(self, args=None):
|
||||
"""/theme <theme name>"""
|
||||
if args is None:
|
||||
return self.command_help('theme')
|
||||
self.command_set('theme %s' % (args[0],))
|
||||
|
||||
@command_args_parser.quoted(1)
|
||||
def command_win(self, args):
|
||||
@command_args_parser.quoted(1)
|
||||
def command_win(self, args):
|
||||
"""
|
||||
/win <number>
|
||||
"""
|
||||
|
@ -217,8 +221,8 @@ def command_win(self, args):
|
|||
self.current_tab().on_gain_focus()
|
||||
self.refresh_window()
|
||||
|
||||
@command_args_parser.quoted(2)
|
||||
def command_move_tab(self, args):
|
||||
@command_args_parser.quoted(2)
|
||||
def command_move_tab(self, args):
|
||||
"""
|
||||
/move_tab old_pos new_pos
|
||||
"""
|
||||
|
@ -257,8 +261,8 @@ def command_move_tab(self, args):
|
|||
self.current_tab_nb = self.tabs.index(current_tab)
|
||||
self.refresh_window()
|
||||
|
||||
@command_args_parser.quoted(0, 1)
|
||||
def command_list(self, args):
|
||||
@command_args_parser.quoted(0, 1)
|
||||
def command_list(self, args):
|
||||
"""
|
||||
/list [server]
|
||||
Opens a MucListTab containing the list of the room in the specified server
|
||||
|
@ -277,8 +281,8 @@ def command_list(self, args):
|
|||
self.xmpp.plugin['xep_0030'].get_items(jid=jid,
|
||||
callback=cb)
|
||||
|
||||
@command_args_parser.quoted(1)
|
||||
def command_version(self, args):
|
||||
@command_args_parser.quoted(1)
|
||||
def command_version(self, args):
|
||||
"""
|
||||
/version <jid>
|
||||
"""
|
||||
|
@ -307,8 +311,8 @@ def command_version(self, args):
|
|||
else:
|
||||
fixes.get_version(self.xmpp, jid, callback=callback)
|
||||
|
||||
@command_args_parser.quoted(0, 2)
|
||||
def command_join(self, args):
|
||||
@command_args_parser.quoted(0, 2)
|
||||
def command_join(self, args):
|
||||
"""
|
||||
/join [room][/nick] [password]
|
||||
"""
|
||||
|
@ -387,8 +391,8 @@ def command_join(self, args):
|
|||
tab.refresh()
|
||||
self.doupdate()
|
||||
|
||||
@command_args_parser.quoted(0, 2)
|
||||
def command_bookmark_local(self, args):
|
||||
@command_args_parser.quoted(0, 2)
|
||||
def command_bookmark_local(self, args):
|
||||
"""
|
||||
/bookmark_local [room][/nick] [password]
|
||||
"""
|
||||
|
@ -399,8 +403,8 @@ def command_bookmark_local(self, args):
|
|||
|
||||
_add_bookmark(self, jid, True, password, 'local')
|
||||
|
||||
@command_args_parser.quoted(0, 3)
|
||||
def command_bookmark(self, args):
|
||||
@command_args_parser.quoted(0, 3)
|
||||
def command_bookmark(self, args):
|
||||
"""
|
||||
/bookmark [room][/nick] [autojoin] [password]
|
||||
"""
|
||||
|
@ -419,7 +423,7 @@ def command_bookmark(self, args):
|
|||
|
||||
_add_bookmark(self, jid, autojoin, password, 'remote')
|
||||
|
||||
def _add_bookmark(self, jid, autojoin, password, method):
|
||||
def _add_bookmark(self, jid, autojoin, password, method):
|
||||
nick = None
|
||||
if not jid:
|
||||
tab = self.current_tab()
|
||||
|
@ -455,7 +459,7 @@ def _add_bookmark(self, jid, autojoin, password, method):
|
|||
self.bookmarks.save_local()
|
||||
self.bookmarks.save_remote(self.xmpp, callback)
|
||||
|
||||
def _add_wildcard_bookmarks(self, method):
|
||||
def _add_wildcard_bookmarks(self, method):
|
||||
new_bookmarks = []
|
||||
for tab in self.get_tabs(tabs.MucTab):
|
||||
bookmark = self.bookmarks[tab.name]
|
||||
|
@ -477,8 +481,8 @@ def _add_wildcard_bookmarks(self, method):
|
|||
self.bookmarks.save_local()
|
||||
self.bookmarks.save_remote(self.xmpp, _cb)
|
||||
|
||||
@command_args_parser.ignored
|
||||
def command_bookmarks(self):
|
||||
@command_args_parser.ignored
|
||||
def command_bookmarks(self):
|
||||
"""/bookmarks"""
|
||||
tab = self.get_tab_by_name('Bookmarks', tabs.BookmarksTab)
|
||||
old_tab = self.current_tab()
|
||||
|
@ -492,8 +496,8 @@ def command_bookmarks(self):
|
|||
tab.on_gain_focus()
|
||||
self.refresh_window()
|
||||
|
||||
@command_args_parser.quoted(0, 1)
|
||||
def command_remove_bookmark(self, args):
|
||||
@command_args_parser.quoted(0, 1)
|
||||
def command_remove_bookmark(self, args):
|
||||
"""/remove_bookmark [jid]"""
|
||||
|
||||
def cb(success):
|
||||
|
@ -516,8 +520,8 @@ def command_remove_bookmark(self, args):
|
|||
else:
|
||||
self.information('No bookmark to remove', 'Info')
|
||||
|
||||
@command_args_parser.quoted(0, 3)
|
||||
def command_set(self, args):
|
||||
@command_args_parser.quoted(0, 3)
|
||||
def command_set(self, args):
|
||||
"""
|
||||
/set [module|][section] <option> [value]
|
||||
"""
|
||||
|
@ -600,8 +604,8 @@ def command_set(self, args):
|
|||
return self.command_help('set')
|
||||
self.information(*info)
|
||||
|
||||
@command_args_parser.quoted(1, 2)
|
||||
def command_set_default(self, args):
|
||||
@command_args_parser.quoted(1, 2)
|
||||
def command_set_default(self, args):
|
||||
"""
|
||||
/set_default [section] <option>
|
||||
"""
|
||||
|
@ -620,8 +624,8 @@ def command_set_default(self, args):
|
|||
return self.information(*info)
|
||||
self.command_set('%s %s %s' % (section, option, default_config[option]))
|
||||
|
||||
@command_args_parser.quoted(1)
|
||||
def command_toggle(self, args):
|
||||
@command_args_parser.quoted(1)
|
||||
def command_toggle(self, args):
|
||||
"""
|
||||
/toggle <option>
|
||||
shortcut for /set <option> toggle
|
||||
|
@ -632,8 +636,8 @@ def command_toggle(self, args):
|
|||
if args[0]:
|
||||
self.command_set('%s toggle' % args[0])
|
||||
|
||||
@command_args_parser.quoted(1, 1)
|
||||
def command_server_cycle(self, args):
|
||||
@command_args_parser.quoted(1, 1)
|
||||
def command_server_cycle(self, args):
|
||||
"""
|
||||
Do a /cycle on each room of the given server.
|
||||
If none, do it on the current tab
|
||||
|
@ -662,8 +666,8 @@ def command_server_cycle(self, args):
|
|||
else:
|
||||
self.command_join('"%s/%s"' %(tab.name, tab.own_nick))
|
||||
|
||||
@command_args_parser.quoted(1)
|
||||
def command_last_activity(self, args):
|
||||
@command_args_parser.quoted(1)
|
||||
def command_last_activity(self, args):
|
||||
"""
|
||||
/last_activity <jid>
|
||||
"""
|
||||
|
@ -697,8 +701,8 @@ def command_last_activity(self, args):
|
|||
self.xmpp.plugin['xep_0012'].get_last_activity(jid,
|
||||
callback=callback)
|
||||
|
||||
@command_args_parser.quoted(0, 2)
|
||||
def command_mood(self, args):
|
||||
@command_args_parser.quoted(0, 2)
|
||||
def command_mood(self, args):
|
||||
"""
|
||||
/mood [<mood> [text]]
|
||||
"""
|
||||
|
@ -717,8 +721,8 @@ def command_mood(self, args):
|
|||
self.xmpp.plugin['xep_0107'].publish_mood(mood, text,
|
||||
callback=dumb_callback)
|
||||
|
||||
@command_args_parser.quoted(0, 3)
|
||||
def command_activity(self, args):
|
||||
@command_args_parser.quoted(0, 3)
|
||||
def command_activity(self, args):
|
||||
"""
|
||||
/activity [<general> [specific] [text]]
|
||||
"""
|
||||
|
@ -748,8 +752,8 @@ def command_activity(self, args):
|
|||
self.xmpp.plugin['xep_0108'].publish_activity(general, specific, text,
|
||||
callback=dumb_callback)
|
||||
|
||||
@command_args_parser.quoted(0, 2)
|
||||
def command_gaming(self, args):
|
||||
@command_args_parser.quoted(0, 2)
|
||||
def command_gaming(self, args):
|
||||
"""
|
||||
/gaming [<game name> [server address]]
|
||||
"""
|
||||
|
@ -765,8 +769,8 @@ def command_gaming(self, args):
|
|||
server_address=address,
|
||||
callback=dumb_callback)
|
||||
|
||||
@command_args_parser.quoted(2, 1, [None])
|
||||
def command_invite(self, args):
|
||||
@command_args_parser.quoted(2, 1, [None])
|
||||
def command_invite(self, args):
|
||||
"""/invite <to> <room> [reason]"""
|
||||
|
||||
if args is None:
|
||||
|
@ -778,8 +782,8 @@ def command_invite(self, args):
|
|||
self.invite(to.full, room, reason=reason)
|
||||
self.information('Invited %s to %s' % (to.bare, room), 'Info')
|
||||
|
||||
@command_args_parser.quoted(1, 1, [''])
|
||||
def command_decline(self, args):
|
||||
@command_args_parser.quoted(1, 1, [''])
|
||||
def command_decline(self, args):
|
||||
"""/decline <room@server.tld> [reason]"""
|
||||
if args is None:
|
||||
return self.command_help('decline')
|
||||
|
@ -794,8 +798,8 @@ def command_decline(self, args):
|
|||
|
||||
### Commands without a completion in this class ###
|
||||
|
||||
@command_args_parser.ignored
|
||||
def command_invitations(self):
|
||||
@command_args_parser.ignored
|
||||
def command_invitations(self):
|
||||
"""/invitations"""
|
||||
build = ""
|
||||
for invite in self.pending_invites:
|
||||
|
@ -807,8 +811,8 @@ def command_invitations(self):
|
|||
build = "You do not have any pending invitations."
|
||||
self.information(build, 'Info')
|
||||
|
||||
@command_args_parser.quoted(0, 1, [None])
|
||||
def command_quit(self, args):
|
||||
@command_args_parser.quoted(0, 1, [None])
|
||||
def command_quit(self, args):
|
||||
"""
|
||||
/quit [message]
|
||||
"""
|
||||
|
@ -828,8 +832,8 @@ def command_quit(self, args):
|
|||
self.disconnect(msg)
|
||||
self.xmpp.add_event_handler("disconnected", self.exit, disposable=True)
|
||||
|
||||
@command_args_parser.quoted(0, 1, [''])
|
||||
def command_destroy_room(self, args):
|
||||
@command_args_parser.quoted(0, 1, [''])
|
||||
def command_destroy_room(self, args):
|
||||
"""
|
||||
/destroy_room [JID]
|
||||
"""
|
||||
|
@ -841,8 +845,8 @@ def command_destroy_room(self, args):
|
|||
else:
|
||||
self.information('Invalid JID: "%s"' % args[0], 'Error')
|
||||
|
||||
@command_args_parser.quoted(1, 1, [''])
|
||||
def command_bind(self, args):
|
||||
@command_args_parser.quoted(1, 1, [''])
|
||||
def command_bind(self, args):
|
||||
"""
|
||||
Bind a key.
|
||||
"""
|
||||
|
@ -857,8 +861,8 @@ def command_bind(self, args):
|
|||
else:
|
||||
self.information('%s is now unbound' % args[0], 'Info')
|
||||
|
||||
@command_args_parser.raw
|
||||
def command_rawxml(self, args):
|
||||
@command_args_parser.raw
|
||||
def command_rawxml(self, args):
|
||||
"""
|
||||
/rawxml <xml stanza>
|
||||
"""
|
||||
|
@ -897,8 +901,8 @@ def command_rawxml(self, args):
|
|||
exc_info=True)
|
||||
|
||||
|
||||
@command_args_parser.quoted(1, 256)
|
||||
def command_load(self, args):
|
||||
@command_args_parser.quoted(1, 256)
|
||||
def command_load(self, args):
|
||||
"""
|
||||
/load <plugin> [<otherplugin> …]
|
||||
# TODO: being able to load more than 256 plugins at once, hihi.
|
||||
|
@ -906,16 +910,16 @@ def command_load(self, args):
|
|||
for plugin in args:
|
||||
self.plugin_manager.load(plugin)
|
||||
|
||||
@command_args_parser.quoted(1, 256)
|
||||
def command_unload(self, args):
|
||||
@command_args_parser.quoted(1, 256)
|
||||
def command_unload(self, args):
|
||||
"""
|
||||
/unload <plugin> [<otherplugin> …]
|
||||
"""
|
||||
for plugin in args:
|
||||
self.plugin_manager.unload(plugin)
|
||||
|
||||
@command_args_parser.ignored
|
||||
def command_plugins(self):
|
||||
@command_args_parser.ignored
|
||||
def command_plugins(self):
|
||||
"""
|
||||
/plugins
|
||||
"""
|
||||
|
@ -923,8 +927,8 @@ def command_plugins(self):
|
|||
repr(list(self.plugin_manager.plugins.keys())),
|
||||
'Info')
|
||||
|
||||
@command_args_parser.quoted(1, 1)
|
||||
def command_message(self, args):
|
||||
@command_args_parser.quoted(1, 1)
|
||||
def command_message(self, args):
|
||||
"""
|
||||
/message <jid> [message]
|
||||
"""
|
||||
|
@ -948,8 +952,8 @@ def command_message(self, args):
|
|||
if len(args) == 2:
|
||||
tab.command_say(args[1])
|
||||
|
||||
@command_args_parser.ignored
|
||||
def command_xml_tab(self):
|
||||
@command_args_parser.ignored
|
||||
def command_xml_tab(self):
|
||||
"""/xml_tab"""
|
||||
xml_tab = self.focus_tab_named('XMLTab', tabs.XMLTab)
|
||||
if not xml_tab:
|
||||
|
@ -957,8 +961,8 @@ def command_xml_tab(self):
|
|||
self.add_tab(tab, True)
|
||||
self.xml_tab = tab
|
||||
|
||||
@command_args_parser.quoted(1)
|
||||
def command_adhoc(self, args):
|
||||
@command_args_parser.quoted(1)
|
||||
def command_adhoc(self, args):
|
||||
if not args:
|
||||
return self.command_help('ad-hoc')
|
||||
jid = safeJID(args[0])
|
||||
|
@ -968,8 +972,8 @@ def command_adhoc(self, args):
|
|||
self.xmpp.plugin['xep_0050'].get_commands(jid=jid, local=False,
|
||||
callback=cb)
|
||||
|
||||
@command_args_parser.ignored
|
||||
def command_self(self):
|
||||
@command_args_parser.ignored
|
||||
def command_self(self):
|
||||
"""
|
||||
/self
|
||||
"""
|
||||
|
@ -987,13 +991,13 @@ def command_self(self):
|
|||
self.information(info, 'Info')
|
||||
|
||||
|
||||
@command_args_parser.ignored
|
||||
def command_reload(self):
|
||||
@command_args_parser.ignored
|
||||
def command_reload(self):
|
||||
"""
|
||||
/reload
|
||||
"""
|
||||
self.reload_config()
|
||||
|
||||
def dumb_callback(*args, **kwargs):
|
||||
def dumb_callback(*args, **kwargs):
|
||||
"mock callback"
|
||||
|
||||
|
|
Loading…
Reference in a new issue