fix/config #17
12
config.py
12
config.py
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
from supybot import conf, registry
|
from supybot import conf, registry, ircutils
|
||||||
try:
|
try:
|
||||||
from supybot.i18n import PluginInternationalization
|
from supybot.i18n import PluginInternationalization
|
||||||
_ = PluginInternationalization('SnoParser')
|
_ = PluginInternationalization('SnoParser')
|
||||||
@ -37,6 +37,12 @@ except:
|
|||||||
# without the i18n module
|
# without the i18n module
|
||||||
_ = lambda x: x
|
_ = lambda x: x
|
||||||
|
|
||||||
|
class ValidChannel(registry.string):
|
||||||
|
"""Value must be a valid channel"""
|
||||||
|
def setValue(self, v):
|
||||||
|
if not (ircutils.isChannel(v)):
|
||||||
|
self.error()
|
||||||
|
registry.String.setValue(self, v)
|
||||||
|
|
||||||
def configure(advanced):
|
def configure(advanced):
|
||||||
# This will be called by supybot to configure this module. advanced is
|
# This will be called by supybot to configure this module. advanced is
|
||||||
@ -52,8 +58,8 @@ SnoParser = conf.registerPlugin('SnoParser')
|
|||||||
# conf.registerGlobalValue(SnoParser, 'someConfigVariableName',
|
# conf.registerGlobalValue(SnoParser, 'someConfigVariableName',
|
||||||
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
|
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
|
||||||
|
|
||||||
conf.registerGlobalValue(SnoParser, 'targetChannel',
|
conf.registerNetworkValue(SnoParser, 'targetChannel', ValidChannel,
|
||||||
registry.String(None, ("""Sends reformatted snolines to the <channel>""")))
|
("", ("""Determines which channel the bot should send snolines""")))
|
||||||
|
|
||||||
conf.registerGlobalValue(SnoParser, 'AutoVhost',
|
conf.registerGlobalValue(SnoParser, 'AutoVhost',
|
||||||
registry.String('libcasa/user/', ("""Configure the vhost eg. libcasa/user/$account""")))
|
registry.String('libcasa/user/', ("""Configure the vhost eg. libcasa/user/$account""")))
|
||||||
|
@ -397,7 +397,7 @@ class SnoParser(callbacks.Plugin):
|
|||||||
def _sendSnotice(self, irc, msg, repl):
|
def _sendSnotice(self, irc, msg, repl):
|
||||||
try:
|
try:
|
||||||
channel = self.registryValue('targetChannel')
|
channel = self.registryValue('targetChannel')
|
||||||
if channel[0] == '#':
|
if irc.isChannel(channel):
|
||||||
irc.queueMsg(msg=ircmsgs.IrcMsg(command='NOTICE',
|
irc.queueMsg(msg=ircmsgs.IrcMsg(command='NOTICE',
|
||||||
args=(channel, repl)))
|
args=(channel, repl)))
|
||||||
# what sort of exception does one raise
|
# what sort of exception does one raise
|
||||||
|
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
dnspython==2.0.0
|
||||||
|
ipwhois==1.2.0
|
||||||
|
redis==3.5.3
|
Loading…
Reference in New Issue
Block a user