From e5325a48ba2116f6cff33c624fdfafcaafb24e95 Mon Sep 17 00:00:00 2001 From: Pratyush Desai Date: Sun, 5 Sep 2021 02:26:38 +0530 Subject: [PATCH 1/2] req.txt and config target fix --- config.py | 12 +++++++++--- plugin.py | 4 ++-- requirements.txt | 3 +++ 3 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 requirements.txt diff --git a/config.py b/config.py index 5a9ebbd..a585def 100644 --- a/config.py +++ b/config.py @@ -28,7 +28,7 @@ ### -from supybot import conf, registry +from supybot import conf, registry, ircutils try: from supybot.i18n import PluginInternationalization _ = PluginInternationalization('SnoParser') @@ -37,6 +37,12 @@ except: # without the i18n module _ = 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): # This will be called by supybot to configure this module. advanced is @@ -52,8 +58,8 @@ SnoParser = conf.registerPlugin('SnoParser') # conf.registerGlobalValue(SnoParser, 'someConfigVariableName', # registry.Boolean(False, _("""Help for someConfigVariableName."""))) -conf.registerGlobalValue(SnoParser, 'targetChannel', - registry.String(None, ("""Sends reformatted snolines to the """))) +conf.registerNetworkValue(SnoParser, 'targetChannel', ValidChannel, + ("", ("""Determines which channel the bot should send snolines"""))) conf.registerGlobalValue(SnoParser, 'AutoVhost', registry.String('libcasa/user/', ("""Configure the vhost eg. libcasa/user/$account"""))) diff --git a/plugin.py b/plugin.py index d10c8e0..ec1ec38 100644 --- a/plugin.py +++ b/plugin.py @@ -397,11 +397,11 @@ class SnoParser(callbacks.Plugin): def _sendSnotice(self, irc, msg, repl): try: channel = self.registryValue('targetChannel') - if channel[0] == '#': + if irc.isChannel(channel): irc.queueMsg(msg=ircmsgs.IrcMsg(command='NOTICE', args=(channel, repl))) # what sort of exception does one raise - except: + except : pass diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..82d9a1a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +dnspython==2.0.0 +ipwhois==1.2.0 +redis==3.5.3 -- 2.35.3 From 7df5fb405c663f208c1df4a60540d6e1f97c3633 Mon Sep 17 00:00:00 2001 From: Pratyush Desai Date: Sun, 5 Sep 2021 23:36:29 +0530 Subject: [PATCH 2/2] empty space --- plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.py b/plugin.py index ec1ec38..c06a6e4 100644 --- a/plugin.py +++ b/plugin.py @@ -401,7 +401,7 @@ class SnoParser(callbacks.Plugin): irc.queueMsg(msg=ircmsgs.IrcMsg(command='NOTICE', args=(channel, repl))) # what sort of exception does one raise - except : + except: pass -- 2.35.3