summaryrefslogtreecommitdiff
path: root/src/tabs/conversationtab.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/tabs/conversationtab.py')
-rw-r--r--src/tabs/conversationtab.py73
1 files changed, 35 insertions, 38 deletions
diff --git a/src/tabs/conversationtab.py b/src/tabs/conversationtab.py
index 52c503d7..1d8c60a4 100644
--- a/src/tabs/conversationtab.py
+++ b/src/tabs/conversationtab.py
@@ -11,8 +11,6 @@ There are two different instances of a ConversationTab:
the time.
"""
-from gettext import gettext as _
-
import logging
log = logging.getLogger(__name__)
@@ -29,6 +27,7 @@ from config import config
from decorators import refresh_wrapper
from roster import roster
from theming import get_theme, dump_tuple
+from decorators import command_args_parser
class ConversationTab(OneToOneTab):
"""
@@ -53,18 +52,18 @@ class ConversationTab(OneToOneTab):
self.key_func['^I'] = self.completion
# commands
self.register_command('unquery', self.command_unquery,
- shortdesc=_('Close the tab.'))
+ shortdesc='Close the tab.')
self.register_command('close', self.command_unquery,
- shortdesc=_('Close the tab.'))
+ shortdesc='Close the tab.')
self.register_command('version', self.command_version,
- desc=_('Get the software version of the current interlocutor (usually its XMPP client and Operating System).'),
- shortdesc=_('Get the software version of the user.'))
+ desc='Get the software version of the current interlocutor (usually its XMPP client and Operating System).',
+ shortdesc='Get the software version of the user.')
self.register_command('info', self.command_info,
- shortdesc=_('Get the status of the contact.'))
+ shortdesc='Get the status of the contact.')
self.register_command('last_activity', self.command_last_activity,
- usage=_('[jid]'),
- desc=_('Get the last activity of the given or the current contact.'),
- shortdesc=_('Get the activity.'),
+ usage='[jid]',
+ desc='Get the last activity of the given or the current contact.',
+ shortdesc='Get the activity.',
completion=self.core.completion_last_activity)
self.resize()
self.update_commands()
@@ -88,6 +87,7 @@ class ConversationTab(OneToOneTab):
def completion(self):
self.complete_commands(self.input)
+ @command_args_parser.raw
def command_say(self, line, attention=False, correct=False):
msg = self.core.xmpp.make_message(self.get_dest_jid())
msg['type'] = 'chat'
@@ -149,19 +149,13 @@ class ConversationTab(OneToOneTab):
self.text_win.refresh()
self.input.refresh()
- def command_xhtml(self, arg):
- message = self.generate_xhtml_message(arg)
- if message:
- message.send()
- self.core.add_message_to_text_buffer(self._text_buffer, message['body'], None, self.core.own_nick)
- self.refresh()
-
- def command_last_activity(self, arg):
+ @command_args_parser.quoted(0, 1)
+ def command_last_activity(self, args):
"""
- /activity [jid]
+ /last_activity [jid]
"""
- if arg.strip():
- return self.core.command_last_activity(arg)
+ if args and args[0]:
+ return self.core.command_last_activity(args[0])
def callback(iq):
if iq['type'] != 'result':
@@ -188,10 +182,11 @@ class ConversationTab(OneToOneTab):
self.add_message(msg)
self.core.refresh_window()
- self.core.xmpp.plugin['xep_0012'].get_last_activity(self.general_jid, callback=callback)
+ self.core.xmpp.plugin['xep_0012'].get_last_activity(self.get_dest_jid(), callback=callback)
@refresh_wrapper.conditional
- def command_info(self, arg):
+ @command_args_parser.ignored
+ def command_info(self):
contact = roster[self.get_dest_jid()]
jid = safeJID(self.get_dest_jid())
if contact:
@@ -202,7 +197,7 @@ class ConversationTab(OneToOneTab):
else:
resource = None
if resource:
- status = (_('Status: %s') % resource.status) if resource.status else ''
+ status = ('Status: %s' % resource.status) if resource.status else ''
self._text_buffer.add_message("\x19%(info_col)s}Show: %(show)s, %(status)s\x19o" % {
'show': resource.show or 'available', 'status': status, 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)})
return True
@@ -210,23 +205,25 @@ class ConversationTab(OneToOneTab):
self._text_buffer.add_message("\x19%(info_col)s}No information available\x19o" % {'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)})
return True
- def command_unquery(self, arg):
+ @command_args_parser.ignored
+ def command_unquery(self):
self.core.close_tab()
- def command_version(self, arg):
+ @command_args_parser.quoted(0, 1)
+ def command_version(self, args):
"""
- /version
+ /version [jid]
"""
def callback(res):
if not res:
return self.core.information('Could not get the software version from %s' % (jid,), 'Warning')
version = '%s is running %s version %s on %s' % (jid,
- res.get('name') or _('an unknown software'),
- res.get('version') or _('unknown'),
- res.get('os') or _('an unknown platform'))
+ res.get('name') or 'an unknown software',
+ res.get('version') or 'unknown',
+ res.get('os') or 'an unknown platform')
self.core.information(version, 'Info')
- if arg:
- return self.core.command_version(arg)
+ if args:
+ return self.core.command_version(args[0])
jid = safeJID(self.name)
if not jid.resource:
if jid in roster:
@@ -381,7 +378,7 @@ class DynamicConversationTab(ConversationTab):
self.info_header = windows.DynamicConversationInfoWin()
ConversationTab.__init__(self, jid)
self.register_command('unlock', self.unlock_command,
- shortdesc=_('Unlock the conversation from a particular resource.'))
+ shortdesc='Unlock the conversation from a particular resource.')
def lock(self, resource):
"""
@@ -393,8 +390,8 @@ class DynamicConversationTab(ConversationTab):
info = '\x19%s}' % dump_tuple(get_theme().COLOR_INFORMATION_TEXT)
jid_c = '\x19%s}' % dump_tuple(get_theme().COLOR_MUC_JID)
- message = _('%(info)sConversation locked to '
- '%(jid_c)s%(jid)s/%(resource)s%(info)s.') % {
+ message = ('%(info)sConversation locked to '
+ '%(jid_c)s%(jid)s/%(resource)s%(info)s.') % {
'info': info,
'jid_c': jid_c,
'jid': self.name,
@@ -418,14 +415,14 @@ class DynamicConversationTab(ConversationTab):
jid_c = '\x19%s}' % dump_tuple(get_theme().COLOR_MUC_JID)
if from_:
- message = _('%(info)sConversation unlocked (received activity'
- ' from %(jid_c)s%(jid)s%(info)s).') % {
+ message = ('%(info)sConversation unlocked (received activity'
+ ' from %(jid_c)s%(jid)s%(info)s).') % {
'info': info,
'jid_c': jid_c,
'jid': from_}
self.add_message(message, typ=0)
else:
- message = _('%sConversation unlocked.') % info
+ message = '%sConversation unlocked.' % info
self.add_message(message, typ=0)
def get_dest_jid(self):