plugins: Update use of tab.name to tab.jid where appropriate
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
200f229464
commit
7a1b2b982f
11 changed files with 34 additions and 28 deletions
|
@ -95,7 +95,7 @@ class Plugin(BasePlugin):
|
|||
is_muctab = isinstance(tab, tabs.MucTab)
|
||||
msg_id = tab.last_sent_message["id"]
|
||||
increment = self.config.get('refresh')
|
||||
roll = DiceRoll(duration, num_dice, is_muctab, tab.name, msg_id,
|
||||
roll = DiceRoll(duration, num_dice, is_muctab, tab.jid, msg_id,
|
||||
increment)
|
||||
event = self.api.create_delayed_event(increment, self.delayed_event,
|
||||
roll)
|
||||
|
|
|
@ -376,7 +376,7 @@ class Plugin(BasePlugin):
|
|||
"""
|
||||
gateway = self.config.get('gateway', 'irc.poez.io')
|
||||
current = self.api.current_tab()
|
||||
current_jid = common.safeJID(current.name)
|
||||
current_jid = current.jid
|
||||
if not current_jid.server == gateway:
|
||||
self.api.information(
|
||||
'The current tab does not appear to be an IRC one', 'Warning')
|
||||
|
|
|
@ -68,7 +68,7 @@ class Plugin(BasePlugin):
|
|||
tab.command_say(args)
|
||||
is_muctab = isinstance(tab, tabs.MucTab)
|
||||
msg_id = tab.last_sent_message["id"]
|
||||
jid = tab.name
|
||||
jid = tab.jid
|
||||
|
||||
event = self.api.create_delayed_event(
|
||||
self.config.get("refresh"), self.delayed_event, jid, args, msg_id,
|
||||
|
|
|
@ -325,7 +325,7 @@ def hl(tab):
|
|||
if tab.state != 'current':
|
||||
tab.state = 'private'
|
||||
|
||||
conv_jid = safeJID(tab.name)
|
||||
conv_jid = tab.jid
|
||||
if 'private' in config.get('beep_on', 'highlight private').split():
|
||||
if not config.get_by_tabname(
|
||||
'disable_beep', conv_jid.bare, default=False):
|
||||
|
@ -806,7 +806,7 @@ class Plugin(BasePlugin):
|
|||
On message sent
|
||||
"""
|
||||
name = tab.name
|
||||
jid = safeJID(tab.name)
|
||||
jid = tab.jid
|
||||
|
||||
format_dict = {
|
||||
'jid_c': '\x19%s}' % dump_tuple(get_theme().COLOR_MUC_JID),
|
||||
|
@ -846,7 +846,7 @@ class Plugin(BasePlugin):
|
|||
elif not is_relevant(tab) and ctx and (
|
||||
ctx.state == STATE_ENCRYPTED
|
||||
or ctx.getPolicy('REQUIRE_ENCRYPTION')):
|
||||
contact = roster[tab.name]
|
||||
contact = roster[tab.jid.bare]
|
||||
res = []
|
||||
if contact:
|
||||
res = [resource.jid for resource in contact.resources]
|
||||
|
@ -884,13 +884,13 @@ class Plugin(BasePlugin):
|
|||
return self.core.command.help('otr')
|
||||
action = args.pop(0)
|
||||
tab = self.api.current_tab()
|
||||
name = tab.name
|
||||
name = tab.jid.full
|
||||
format_dict = {
|
||||
'jid_c': '\x19%s}' % dump_tuple(get_theme().COLOR_MUC_JID),
|
||||
'info': '\x19%s}' % dump_tuple(get_theme().COLOR_INFORMATION_TEXT),
|
||||
'normal': '\x19%s}' % dump_tuple(get_theme().COLOR_NORMAL_TEXT),
|
||||
'jid': name,
|
||||
'bare_jid': safeJID(name).bare
|
||||
'jid': tab.jid.full,
|
||||
'bare_jid': tab.jid.bare,
|
||||
}
|
||||
|
||||
if action == 'end': # close the session
|
||||
|
@ -991,12 +991,12 @@ class Plugin(BasePlugin):
|
|||
question = secret = None
|
||||
|
||||
tab = self.api.current_tab()
|
||||
name = tab.name
|
||||
name = tab.jid.full
|
||||
format_dict = {
|
||||
'jid_c': '\x19%s}' % dump_tuple(get_theme().COLOR_MUC_JID),
|
||||
'info': '\x19%s}' % dump_tuple(get_theme().COLOR_INFORMATION_TEXT),
|
||||
'jid': name,
|
||||
'bare_jid': safeJID(name).bare
|
||||
'jid': tab.jid.full,
|
||||
'bare_jid': tab.jid.bare,
|
||||
}
|
||||
|
||||
ctx = self.get_context(name)
|
||||
|
|
|
@ -22,6 +22,7 @@ Command
|
|||
the current interlocutor.
|
||||
"""
|
||||
|
||||
from slixmpp import InvalidJID
|
||||
from poezio.decorators import command_args_parser
|
||||
from poezio.plugin import BasePlugin
|
||||
from poezio.roster import roster
|
||||
|
@ -116,7 +117,7 @@ class Plugin(BasePlugin):
|
|||
def command_private_ping(self, arg):
|
||||
if arg:
|
||||
return self.command_ping(arg)
|
||||
self.command_ping(self.api.current_tab().name)
|
||||
self.command_ping(self.api.current_tab().jid)
|
||||
|
||||
@command_args_parser.raw
|
||||
def command_muc_ping(self, arg):
|
||||
|
@ -124,10 +125,13 @@ class Plugin(BasePlugin):
|
|||
return
|
||||
user = self.api.current_tab().get_user_by_name(arg)
|
||||
if user:
|
||||
jid = safeJID(self.api.current_tab().name)
|
||||
jid = self.api.current_tab().jid
|
||||
jid.resource = user.nick
|
||||
else:
|
||||
jid = safeJID(arg)
|
||||
try:
|
||||
jid = JID(arg)
|
||||
except InvalidJID:
|
||||
return self.api.information('Invalid JID: %s' % arg, 'Error')
|
||||
self.command_ping(jid.full)
|
||||
|
||||
@command_args_parser.raw
|
||||
|
|
|
@ -112,7 +112,7 @@ def parse_runtime_tablist(tablist):
|
|||
i += 1
|
||||
result = check_tab(tab)
|
||||
if result:
|
||||
props.append((i, '%s:%s' % (result, tab.name)))
|
||||
props.append((i, '%s:%s' % (result, tab.jid.full)))
|
||||
return props
|
||||
|
||||
|
||||
|
|
|
@ -102,11 +102,11 @@ def replace_random_user(message, tab):
|
|||
if isinstance(tab, tabs.MucTab):
|
||||
return random.choice(tab.users).nick
|
||||
elif isinstance(tab, tabs.PrivateTab):
|
||||
return random.choice([JID(tab.name).resource, tab.own_nick])
|
||||
return random.choice([tab.jid.resource, tab.own_nick])
|
||||
else:
|
||||
# that doesn’t make any sense. By why use this pattern in a
|
||||
# ConversationTab anyway?
|
||||
return str(tab.name)
|
||||
return tab.jid.full
|
||||
|
||||
|
||||
def replace_dice(message, tab):
|
||||
|
|
|
@ -39,7 +39,7 @@ class Plugin(BasePlugin):
|
|||
if not args and not isinstance(current_tab, MucTab):
|
||||
return self.core.command_help('server_part')
|
||||
elif not args:
|
||||
jid = safeJID(current_tab.name).bare
|
||||
jid = current_tab.jid.bare
|
||||
message = None
|
||||
elif len(args) == 1:
|
||||
jid = safeJID(args[0]).domain
|
||||
|
@ -60,6 +60,6 @@ class Plugin(BasePlugin):
|
|||
serv_list = set()
|
||||
for tab in self.core.get_tabs(MucTab):
|
||||
if tab.joined:
|
||||
serv = safeJID(tab.name).server
|
||||
serv = tab.jid.server
|
||||
serv_list.add(serv)
|
||||
return Completion(the_input.new_completion, sorted(serv_list), 1, ' ')
|
||||
|
|
|
@ -75,7 +75,7 @@ class Plugin(BasePlugin):
|
|||
if not self.tabs.get(tab):
|
||||
self.api.information('No message queued.', 'Info')
|
||||
return
|
||||
build = ['Messages queued for %s:' % tab.name]
|
||||
build = ['Messages queued for %s:' % tab.jid.bare]
|
||||
for nick, messages in self.tabs[tab].items():
|
||||
build.append(' for %s:' % nick)
|
||||
for message in messages:
|
||||
|
|
|
@ -36,7 +36,7 @@ from datetime import datetime, timedelta
|
|||
class Plugin(BasePlugin):
|
||||
def init(self):
|
||||
self.api.add_event_handler("muc_msg", self.on_muc_msg)
|
||||
# Dict of MucTab.name: last_message date, so we don’t have to
|
||||
# Dict of MucTab.jid.bare: last_message date, so we don’t have to
|
||||
# retrieve the messages of the given muc to look for the last
|
||||
# message’s date each time. Also, now that I think about it, the
|
||||
# date of the message is not event kept in the Message object, so…
|
||||
|
@ -66,8 +66,8 @@ class Plugin(BasePlugin):
|
|||
res += "%s seconds, " % seconds
|
||||
return res[:-2]
|
||||
|
||||
last_message_date = self.last_messages.get(tab.name)
|
||||
self.last_messages[tab.name] = datetime.now()
|
||||
last_message_date = self.last_messages.get(tab.jid.bare)
|
||||
self.last_messages[tab.jid.bare] = datetime.now()
|
||||
if last_message_date:
|
||||
delta = datetime.now() - last_message_date
|
||||
if delta >= timedelta(0, self.config.get('delay', 900)):
|
||||
|
|
|
@ -273,7 +273,7 @@ class Plugin(BasePlugin):
|
|||
if arg:
|
||||
self.command_vcard(arg)
|
||||
return
|
||||
self.command_vcard(self.api.current_tab().name)
|
||||
self.command_vcard(self.api.current_tab().jid.full)
|
||||
|
||||
@command_args_parser.raw
|
||||
def command_muc_vcard(self, arg):
|
||||
|
@ -282,10 +282,12 @@ class Plugin(BasePlugin):
|
|||
return
|
||||
user = self.api.current_tab().get_user_by_name(arg)
|
||||
if user:
|
||||
# No need to use safeJID here, we already know the JID is valid.
|
||||
jid = JID(self.api.current_tab().name + '/' + user.nick)
|
||||
jid = self.api.current_tab().jid.bare + '/' + user.nick
|
||||
else:
|
||||
jid = safeJID(arg)
|
||||
try:
|
||||
jid = safeJID(arg)
|
||||
except InvalidJID:
|
||||
return self.api.information('Invalid JID: %s' % arg, 'Error')
|
||||
self._get_vcard(jid)
|
||||
|
||||
@command_args_parser.raw
|
||||
|
|
Loading…
Reference in a new issue