mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-10 20:22:36 +01:00
Converted to commands.wrap. These are all untested, so someone should test them at some point.
This commit is contained in:
parent
8b1962068b
commit
5762ed6d74
@ -44,7 +44,7 @@ import babelfish
|
|||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
import supybot.privmsgs as privmsgs
|
from supybot.commands import *
|
||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
@ -95,16 +95,13 @@ class Babelfish(callbacks.Privmsg):
|
|||||||
"""
|
"""
|
||||||
irc.reply(utils.commaAndify(babelfish.available_languages))
|
irc.reply(utils.commaAndify(babelfish.available_languages))
|
||||||
|
|
||||||
def translate(self, irc, msg, args):
|
def translate(self, irc, msg, args, fromLang, to, toLang, text):
|
||||||
"""<from-language> [to] <to-language> <text>
|
"""<from-language> [to] <to-language> <text>
|
||||||
|
|
||||||
Returns <text> translated from <from-language> into <to-language>.
|
Returns <text> translated from <from-language> into <to-language>.
|
||||||
Beware that translating to or from languages that use multi-byte
|
Beware that translating to or from languages that use multi-byte
|
||||||
characters may result in some very odd results.
|
characters may result in some very odd results.
|
||||||
"""
|
"""
|
||||||
if len(args) >= 2 and args[1] == 'to':
|
|
||||||
args.pop(1)
|
|
||||||
(fromLang, toLang, text) = privmsgs.getArgs(args, required=3)
|
|
||||||
chan = msg.args[0]
|
chan = msg.args[0]
|
||||||
try:
|
try:
|
||||||
(fromLang, toLang) = self._getLang(fromLang, toLang, chan)
|
(fromLang, toLang) = self._getLang(fromLang, toLang, chan)
|
||||||
@ -131,15 +128,17 @@ class Babelfish(callbacks.Privmsg):
|
|||||||
except babelfish.BabelfishChangedError, e:
|
except babelfish.BabelfishChangedError, e:
|
||||||
irc.error('Babelfish has foiled our plans by changing its '
|
irc.error('Babelfish has foiled our plans by changing its '
|
||||||
'webpage format.')
|
'webpage format.')
|
||||||
|
translate = wrap(translate,
|
||||||
|
['something', optional(literal('to')),
|
||||||
|
'something', 'text'])
|
||||||
|
|
||||||
def babelize(self, irc, msg, args):
|
def babelize(self, irc, msg, args, fromLang, toLang, text):
|
||||||
"""<from-language> <to-language> <text>
|
"""<from-language> <to-language> <text>
|
||||||
|
|
||||||
Translates <text> repeatedly between <from-language> and <to-language>
|
Translates <text> repeatedly between <from-language> and <to-language>
|
||||||
until it doesn't change anymore or 12 times, whichever is fewer. One
|
until it doesn't change anymore or 12 times, whichever is fewer. One
|
||||||
of the languages must be English.
|
of the languages must be English.
|
||||||
"""
|
"""
|
||||||
(fromLang, toLang, text) = privmsgs.getArgs(args, required=3)
|
|
||||||
chan = msg.args[0]
|
chan = msg.args[0]
|
||||||
try:
|
try:
|
||||||
(fromLang, toLang) = self._getLang(fromLang, toLang, chan)
|
(fromLang, toLang) = self._getLang(fromLang, toLang, chan)
|
||||||
@ -170,14 +169,18 @@ class Babelfish(callbacks.Privmsg):
|
|||||||
except babelfish.BabelfishChangedError, e:
|
except babelfish.BabelfishChangedError, e:
|
||||||
irc.reply('Babelfish has foiled our plans by changing its '
|
irc.reply('Babelfish has foiled our plans by changing its '
|
||||||
'webpage format.')
|
'webpage format.')
|
||||||
|
babelize = wrap(babelize, ['something', 'something', 'text'])
|
||||||
|
|
||||||
def randomlanguage(self, irc, msg, args):
|
def randomlanguage(self, irc, msg, args, optlist):
|
||||||
"""[<allow-english>]
|
"""[--allow-english]
|
||||||
|
|
||||||
Returns a random language supported by babelfish. If <allow-english>
|
Returns a random language supported by babelfish. If --allow-english
|
||||||
is provided, will include English in the list of possible languages.
|
is provided, will include English in the list of possible languages.
|
||||||
"""
|
"""
|
||||||
allowEnglish = privmsgs.getArgs(args, required=0, optional=1)
|
allowEnglish = False
|
||||||
|
for (option, arg) in optlist:
|
||||||
|
if option == 'allow-english':
|
||||||
|
allowEnglish = True
|
||||||
languages = self.registryValue('languages', msg.args[0])
|
languages = self.registryValue('languages', msg.args[0])
|
||||||
if not languages:
|
if not languages:
|
||||||
irc.error('I can\'t speak any other languages.')
|
irc.error('I can\'t speak any other languages.')
|
||||||
@ -185,6 +188,7 @@ class Babelfish(callbacks.Privmsg):
|
|||||||
while not allowEnglish and language == 'English':
|
while not allowEnglish and language == 'English':
|
||||||
language = random.choice(languages)
|
language = random.choice(languages)
|
||||||
irc.reply(language)
|
irc.reply(language)
|
||||||
|
randomlanguage = wrap(randomlanguage, [getopts({'allow-english': ''})])
|
||||||
|
|
||||||
Class = Babelfish
|
Class = Babelfish
|
||||||
|
|
||||||
|
@ -42,19 +42,18 @@ import threading
|
|||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
import supybot.world as world
|
import supybot.world as world
|
||||||
|
from supybot.commands import *
|
||||||
import supybot.ircmsgs as ircmsgs
|
import supybot.ircmsgs as ircmsgs
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.privmsgs as privmsgs
|
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
|
|
||||||
class DCC(callbacks.Privmsg):
|
class DCC(callbacks.Privmsg):
|
||||||
def chat(self, irc, msg, args):
|
def chat(self, irc, msg, args, text):
|
||||||
"""<text>
|
"""<text>
|
||||||
|
|
||||||
Sends <text> to the user via a DCC CHAT. Use nested commands to your
|
Sends <text> to the user via a DCC CHAT. Use nested commands to your
|
||||||
benefit here.
|
benefit here.
|
||||||
"""
|
"""
|
||||||
text = privmsgs.getArgs(args)
|
|
||||||
def openChatPort():
|
def openChatPort():
|
||||||
try:
|
try:
|
||||||
host = ircutils.hostFromHostmask(irc.prefix)
|
host = ircutils.hostFromHostmask(irc.prefix)
|
||||||
@ -112,6 +111,7 @@ class DCC(callbacks.Privmsg):
|
|||||||
world.threadsSpawned += 1
|
world.threadsSpawned += 1
|
||||||
t.setDaemon(True)
|
t.setDaemon(True)
|
||||||
t.start()
|
t.start()
|
||||||
|
chat = wrap(chat, ['text'])
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ import supybot.utils as utils
|
|||||||
import supybot.plugins as plugins
|
import supybot.plugins as plugins
|
||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
import supybot.ircutils as ircutils
|
import supybot.ircutils as ircutils
|
||||||
import supybot.privmsgs as privmsgs
|
|
||||||
import supybot.registry as registry
|
import supybot.registry as registry
|
||||||
import supybot.webutils as webutils
|
import supybot.webutils as webutils
|
||||||
import supybot.callbacks as callbacks
|
import supybot.callbacks as callbacks
|
||||||
@ -418,53 +417,33 @@ class Sourceforge(callbacks.PrivmsgCommandAndRegexp):
|
|||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def total(self, irc, msg, args):
|
def total(self, irc, msg, args, type, project):
|
||||||
"""{bugs,rfes} [<project>]
|
"""{bugs,rfes} [<project>]
|
||||||
|
|
||||||
Returns the total count of open bugs or rfes. <project> is only
|
Returns the total count of open bugs or rfes. <project> is only
|
||||||
necessary if a default project is not set.
|
necessary if a default project is not set.
|
||||||
"""
|
"""
|
||||||
if not args:
|
|
||||||
raise callbacks.ArgumentError
|
|
||||||
type = args.pop(0)
|
|
||||||
if type == 'bugs':
|
if type == 'bugs':
|
||||||
self._totalbugs(irc, msg, args)
|
self._totalbugs(irc, msg, project)
|
||||||
elif type == 'rfes':
|
elif type == 'rfes':
|
||||||
self._totalrfes(irc, msg, args)
|
self._totalrfes(irc, msg, project)
|
||||||
else:
|
total = wrap(total, [literal(('bugs', 'rfes')), additional('something')])
|
||||||
raise callbacks.ArgumentError
|
|
||||||
|
|
||||||
def _totalbugs(self, irc, msg, args):
|
def _totalbugs(self, irc, msg, project):
|
||||||
"""[<project>]
|
|
||||||
|
|
||||||
Returns a count of the open/total bugs. <project> is not needed if a
|
|
||||||
default project is set.
|
|
||||||
"""
|
|
||||||
project = privmsgs.getArgs(args, required=0, optional=1)
|
|
||||||
project = project or self.registryValue('defaultProject', msg.args[0])
|
project = project or self.registryValue('defaultProject', msg.args[0])
|
||||||
if not project:
|
|
||||||
raise callbacks.ArgumentError
|
|
||||||
total = self._getNumBugs(project)
|
total = self._getNumBugs(project)
|
||||||
if total:
|
if total:
|
||||||
irc.reply(total)
|
irc.reply(total)
|
||||||
else:
|
else:
|
||||||
irc.error('Could not find bug statistics.')
|
irc.error('Could not find bug statistics for %s.' % project)
|
||||||
|
|
||||||
def _totalrfes(self, irc, msg, args):
|
def _totalrfes(self, irc, msg, project):
|
||||||
"""[<project>]
|
|
||||||
|
|
||||||
Returns a count of the open/total RFEs. <project> is not needed if a
|
|
||||||
default project is set.
|
|
||||||
"""
|
|
||||||
project = privmsgs.getArgs(args, required=0, optional=1)
|
|
||||||
project = project or self.registryValue('defaultProject', msg.args[0])
|
project = project or self.registryValue('defaultProject', msg.args[0])
|
||||||
if not project:
|
|
||||||
raise callbacks.ArgumentError
|
|
||||||
total = self._getNumRfes(project)
|
total = self._getNumRfes(project)
|
||||||
if total:
|
if total:
|
||||||
irc.reply(total)
|
irc.reply(total)
|
||||||
else:
|
else:
|
||||||
irc.error('Could not find RFE statistics.')
|
irc.error('Could not find RFE statistics for %s.' % project)
|
||||||
|
|
||||||
def fight(self, irc, msg, args, optlist, projects):
|
def fight(self, irc, msg, args, optlist, projects):
|
||||||
"""[--{bugs,rfes}] [--{open,closed}] <project name> <project name> \
|
"""[--{bugs,rfes}] [--{open,closed}] <project name> <project name> \
|
||||||
|
Loading…
Reference in New Issue
Block a user