Fix pep8 support in src/plugins.
This commit is contained in:
parent
e51a8a650b
commit
0dca274360
1 changed files with 1052 additions and 1079 deletions
|
|
@ -23,16 +23,17 @@ from twisted.words.protocols.jabber import jid
|
|||
from logging import debug, info, warning, error
|
||||
|
||||
PLUGIN_INFO = {
|
||||
"name": "Text commands",
|
||||
"import_name": "text-commands",
|
||||
"type": "Misc",
|
||||
"protocols": [],
|
||||
"dependencies": ["XEP-0045", "EXP-PARROT"],
|
||||
"main": "TextCommands",
|
||||
"handler": "no",
|
||||
"description": _("""IRC like text commands""")
|
||||
"name": "Text commands",
|
||||
"import_name": "text-commands",
|
||||
"type": "Misc",
|
||||
"protocols": [],
|
||||
"dependencies": ["XEP-0045", "EXP-PARROT"],
|
||||
"main": "TextCommands",
|
||||
"handler": "no",
|
||||
"description": _("""IRC like text commands""")
|
||||
}
|
||||
|
||||
|
||||
class TextCommands(object):
|
||||
#FIXME: doc strings for commands have to be translatable
|
||||
# plugins need a dynamic translation system (translation
|
||||
|
|
@ -52,13 +53,13 @@ class TextCommands(object):
|
|||
if command.isalpha():
|
||||
# looks like an actual command, we try to call the corresponding method
|
||||
try:
|
||||
mess_data["unparsed"] = msg[1+len(command):] #part not yet parsed of the message
|
||||
return getattr(self,"cmd_%s" % command)(mess_data,profile)
|
||||
mess_data["unparsed"] = msg[1 + len(command):] # part not yet parsed of the message
|
||||
return getattr(self, "cmd_%s" % command)(mess_data, profile)
|
||||
except AttributeError:
|
||||
pass
|
||||
elif msg[0] == '\\': #we have escape char
|
||||
elif msg[0] == '\\': # we have escape char
|
||||
try:
|
||||
if msg[1] in ('/','\\'): # we have '\/' or '\\', we escape to '/' or '\'
|
||||
if msg[1] in ('/', '\\'): # we have '\/' or '\\', we escape to '/' or '\'
|
||||
mess_data["message"] = msg[1:]
|
||||
except IndexError:
|
||||
pass
|
||||
|
|
@ -72,9 +73,9 @@ class TextCommands(object):
|
|||
"""
|
||||
nb_arobas = arg.count('@')
|
||||
if nb_arobas == 1:
|
||||
if arg[-1] !='@':
|
||||
if arg[-1] != '@':
|
||||
return jid.JID(arg)
|
||||
return jid.JID(arg+service_jid)
|
||||
return jid.JID(arg + service_jid)
|
||||
return jid.JID(u"%s@%s" % (arg, service_jid))
|
||||
|
||||
def _feedBack(self, message, mess_data, profile):
|
||||
|
|
@ -99,7 +100,7 @@ class TextCommands(object):
|
|||
nick = mess_data["unparsed"].strip()
|
||||
room = mess_data["to"]
|
||||
|
||||
self.host.plugins["XEP-0045"].nick(room,nick,profile)
|
||||
self.host.plugins["XEP-0045"].nick(room, nick, profile)
|
||||
|
||||
return False
|
||||
|
||||
|
|
@ -134,7 +135,7 @@ class TextCommands(object):
|
|||
else:
|
||||
room = mess_data["to"]
|
||||
|
||||
self.host.plugins["XEP-0045"].leave(room,profile)
|
||||
self.host.plugins["XEP-0045"].leave(room, profile)
|
||||
|
||||
return False
|
||||
|
||||
|
|
@ -183,7 +184,7 @@ class TextCommands(object):
|
|||
self.host.plugins["EXP-PARROT"].addParrot(link_left_jid, link_right_jid, profile)
|
||||
self.host.plugins["EXP-PARROT"].addParrot(link_right_jid, link_left_jid, profile)
|
||||
|
||||
self._feedBack("Parrot mode activated for %s" % (unicode(link_left_jid),), mess_data, profile)
|
||||
self._feedBack("Parrot mode activated for %s" % (unicode(link_left_jid), ), mess_data, profile)
|
||||
|
||||
return False
|
||||
|
||||
|
|
@ -210,7 +211,7 @@ class TextCommands(object):
|
|||
|
||||
def cmd_help(self, mess_data, profile):
|
||||
"""show help on available commands"""
|
||||
commands=filter(lambda method: method.startswith('cmd_'), dir(self))
|
||||
commands = filter(lambda method: method.startswith('cmd_'), dir(self))
|
||||
longuest = max([len(command) for command in commands])
|
||||
help_cmds = []
|
||||
|
||||
|
|
@ -223,7 +224,5 @@ class TextCommands(object):
|
|||
spaces = (longuest - len(command)) * ' '
|
||||
help_cmds.append(" /%s: %s %s" % (command[4:], spaces, help_str))
|
||||
|
||||
help_mess = _(u"Text commands available:\n%s") % (u'\n'.join(help_cmds),)
|
||||
help_mess = _(u"Text commands available:\n%s") % (u'\n'.join(help_cmds), )
|
||||
self._feedBack(help_mess, mess_data, profile)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue