mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-30 14:59:34 +01:00
Converted Dict to the new registry format.
This commit is contained in:
parent
0b62247ccb
commit
8424761047
@ -46,10 +46,12 @@ import dictclient
|
|||||||
import conf
|
import conf
|
||||||
import utils
|
import utils
|
||||||
import plugins
|
import plugins
|
||||||
|
import registry
|
||||||
import ircutils
|
import ircutils
|
||||||
import privmsgs
|
import privmsgs
|
||||||
import callbacks
|
import callbacks
|
||||||
import configurable
|
|
||||||
|
import Owner
|
||||||
|
|
||||||
|
|
||||||
def configure(onStart, afterConnect, advanced):
|
def configure(onStart, afterConnect, advanced):
|
||||||
@ -65,20 +67,20 @@ def configure(onStart, afterConnect, advanced):
|
|||||||
onStart.append('dict config server %s' % server)
|
onStart.append('dict config server %s' % server)
|
||||||
|
|
||||||
replyTimeout = 'Timeout on the dictd server.'
|
replyTimeout = 'Timeout on the dictd server.'
|
||||||
class Dict(callbacks.Privmsg, configurable.Mixin):
|
|
||||||
|
Owner.registerPlugin('Dict', True)
|
||||||
|
# TODO: We should make this check to see if there's actually a dictd server
|
||||||
|
# running on the host given.
|
||||||
|
conf.supybot.plugins.Dict.register('server', registry.String('dict.org', """
|
||||||
|
Determines what server the bot will retrieve definitions from."""))
|
||||||
|
|
||||||
|
class Dict(callbacks.Privmsg):
|
||||||
threaded = True
|
threaded = True
|
||||||
configurables = configurable.Dictionary(
|
|
||||||
[('server', configurable.StrType, 'dict.org',
|
|
||||||
"""Determines what server the bot will connect to to receive
|
|
||||||
definitions from."""),]
|
|
||||||
)
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
callbacks.Privmsg.__init__(self)
|
callbacks.Privmsg.__init__(self)
|
||||||
configurable.Mixin.__init__(self)
|
|
||||||
|
|
||||||
def die(self):
|
def die(self):
|
||||||
callbacks.Privmsg.die(self)
|
callbacks.Privmsg.die(self)
|
||||||
configurable.Mixin.die(self)
|
|
||||||
|
|
||||||
def dictionaries(self, irc, msg, args):
|
def dictionaries(self, irc, msg, args):
|
||||||
"""takes no arguments.
|
"""takes no arguments.
|
||||||
@ -86,7 +88,8 @@ class Dict(callbacks.Privmsg, configurable.Mixin):
|
|||||||
Returns the dictionaries valid for the dict command.
|
Returns the dictionaries valid for the dict command.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
conn = dictclient.Connection(self.configurables.get('server'))
|
server = conf.supybot.plugins.Dict.server()
|
||||||
|
conn = dictclient.Connection(server)
|
||||||
dbs = conn.getdbdescs().keys()
|
dbs = conn.getdbdescs().keys()
|
||||||
dbs.sort()
|
dbs.sort()
|
||||||
irc.reply(utils.commaAndify(dbs))
|
irc.reply(utils.commaAndify(dbs))
|
||||||
@ -99,7 +102,8 @@ class Dict(callbacks.Privmsg, configurable.Mixin):
|
|||||||
Returns a random valid dictionary.
|
Returns a random valid dictionary.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
conn = dictclient.Connection(self.configurables.get('server'))
|
server = conf.supybot.plugins.Dict.server()
|
||||||
|
conn = dictclient.Connection(server)
|
||||||
dbs = conn.getdbdescs().keys()
|
dbs = conn.getdbdescs().keys()
|
||||||
irc.reply(random.choice(dbs))
|
irc.reply(random.choice(dbs))
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
@ -113,7 +117,8 @@ class Dict(callbacks.Privmsg, configurable.Mixin):
|
|||||||
if not args:
|
if not args:
|
||||||
raise callbacks.ArgumentError
|
raise callbacks.ArgumentError
|
||||||
try:
|
try:
|
||||||
conn = dictclient.Connection(self.configurables.get('server'))
|
server = conf.supybot.plugins.Dict.server()
|
||||||
|
conn = dictclient.Connection(server)
|
||||||
except socket.timeout:
|
except socket.timeout:
|
||||||
irc.error('Timeout on the dict server.')
|
irc.error('Timeout on the dict server.')
|
||||||
return
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user