Compare commits

..

No commits in common. "98abab560e1ecafc1c9e36b53a3982e729282704" and "420a7b147205fe8b46cdf1eea43c7d20c0358c9c" have entirely different histories.

2 changed files with 6 additions and 3 deletions

View File

@ -181,7 +181,7 @@ exclude =
.tox/ .tox/
versioneer.py versioneer.py
_version.py _version.py
**/migrations/ instance/
extend-ignore = T101 extend-ignore = T101
max-complexity = 10 max-complexity = 10
max-line-length = 120 max-line-length = 120

View File

@ -1,17 +1,20 @@
"""Report on the weather via wttr.in."""
import logging import logging
from ircbot.lib import Plugin from ircbot.lib import Plugin
from weather.lib import weather_summary from weather.lib import weather_summary
log = logging.getLogger('weather.ircplugin') log = logging.getLogger('weather.ircplugin')
class Weather(Plugin): class Weather(Plugin):
"""Have IRC commands to do IRC things (join channels, quit, etc.).""" """Have IRC commands to do IRC things (join channels, quit, etc.)."""
def start(self): def start(self):
"""Set up the handlers.""" """Set up the handlers."""
self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!weather\s+(.*)$', self.connection.reactor.add_global_regex_handler(['pubmsg', 'privmsg'], r'^!weather\s+(.*)$',
self.handle_weather, -20) self.handle_weather, -20)
@ -19,12 +22,12 @@ class Weather(Plugin):
def stop(self): def stop(self):
"""Tear down handlers.""" """Tear down handlers."""
self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_weather) self.connection.reactor.remove_global_regex_handler(['pubmsg', 'privmsg'], self.handle_weather)
super(Weather, self).stop() super(Weather, self).stop()
def handle_weather(self, connection, event, match): def handle_weather(self, connection, event, match):
"""Make the weather query and format it for IRC."""
query = match.group(1) query = match.group(1)
queryitems = query.split(" ") queryitems = query.split(" ")
if len(queryitems) <= 0: if len(queryitems) <= 0: