mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-23 11:09:23 +01:00
Merge branch 'testing' of github.com:ProgVal/Limnoria into testing
This commit is contained in:
commit
b673cdb037
@ -7,7 +7,7 @@ python:
|
||||
- "pypy"
|
||||
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
|
||||
install:
|
||||
- pip install pytz feedparser charade sqlalchemy python-gnupg --use-mirrors
|
||||
- pip install pytz feedparser charade sqlalchemy python-gnupg python-dateutil --use-mirrors
|
||||
# command to run tests, e.g. python setup.py test
|
||||
script:
|
||||
- echo $TRAVIS_PYTHON_VERSION
|
||||
|
@ -358,9 +358,11 @@ class ChannelStats(callbacks.Plugin):
|
||||
Returns the statistics for <channel>. <channel> is only necessary if
|
||||
the message isn't sent on the channel itself.
|
||||
"""
|
||||
if msg.nick not in irc.state.channels[channel].users:
|
||||
irc.error(format('You must be in %s to use this command.', channel))
|
||||
return
|
||||
if channel not in irc.state.channels:
|
||||
irc.error(_('I am not in %s.', channel), Raise=True)
|
||||
elif msg.nick not in irc.state.channels[channel].users:
|
||||
irc.error(_('You must be in %s to use this command.') % channel,
|
||||
Raise=True)
|
||||
try:
|
||||
channeldb = conf.supybot.databases.plugins.channelSpecific. \
|
||||
getChannelLink(channel)
|
||||
|
@ -254,6 +254,10 @@ repositories = {
|
||||
'Jonimoose',
|
||||
'Supybot-plugins',
|
||||
),
|
||||
'skgsergio': GithubRepository(
|
||||
'skgsergio',
|
||||
'Limnoria-plugins',
|
||||
),
|
||||
}
|
||||
|
||||
class PluginDownloader(callbacks.Plugin):
|
||||
|
@ -31,8 +31,6 @@ import time
|
||||
TIME = time # For later use.
|
||||
from datetime import datetime
|
||||
|
||||
from dateutil import parser
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.utils as utils
|
||||
from supybot.commands import *
|
||||
@ -40,20 +38,25 @@ import supybot.callbacks as callbacks
|
||||
from supybot.i18n import PluginInternationalization, internationalizeDocstring
|
||||
_ = PluginInternationalization('Time')
|
||||
|
||||
def parse(s):
|
||||
todo = []
|
||||
s = s.replace('noon', '12:00')
|
||||
s = s.replace('midnight', '00:00')
|
||||
if 'tomorrow' in s:
|
||||
todo.append(lambda i: i + 86400)
|
||||
s = s.replace('tomorrow', '')
|
||||
if 'next week' in s:
|
||||
todo.append(lambda i: i + 86400*7)
|
||||
s = s.replace('next week', '')
|
||||
i = int(time.mktime(parser.parse(s, fuzzy=True).timetuple()))
|
||||
for f in todo:
|
||||
i = f(i)
|
||||
return i
|
||||
|
||||
try:
|
||||
from dateutil import parser
|
||||
def parse(s):
|
||||
todo = []
|
||||
s = s.replace('noon', '12:00')
|
||||
s = s.replace('midnight', '00:00')
|
||||
if 'tomorrow' in s:
|
||||
todo.append(lambda i: i + 86400)
|
||||
s = s.replace('tomorrow', '')
|
||||
if 'next week' in s:
|
||||
todo.append(lambda i: i + 86400*7)
|
||||
s = s.replace('next week', '')
|
||||
i = int(time.mktime(parser.parse(s, fuzzy=True).timetuple()))
|
||||
for f in todo:
|
||||
i = f(i)
|
||||
return i
|
||||
except ImportError:
|
||||
parse = None
|
||||
|
||||
class Time(callbacks.Plugin):
|
||||
@internationalizeDocstring
|
||||
@ -99,6 +102,9 @@ class Time(callbacks.Plugin):
|
||||
<time string> can be any number of natural formats; just try something
|
||||
and see if it will work.
|
||||
"""
|
||||
if not parse:
|
||||
irc.error(_('This command is not available on this bot, ask the '
|
||||
'owner to install the python-dateutil library.'), Raise=True)
|
||||
now = int(time.time())
|
||||
new = parse(s)
|
||||
if new != now:
|
||||
@ -113,6 +119,9 @@ class Time(callbacks.Plugin):
|
||||
|
||||
Returns the number of seconds until <time string>.
|
||||
"""
|
||||
if not parse:
|
||||
irc.error(_('This command is not available on this bot, ask the '
|
||||
'owner to install the python-dateutil library.'), Raise=True)
|
||||
now = int(time.time())
|
||||
new = parse(s)
|
||||
if new != now:
|
||||
|
@ -52,6 +52,10 @@ conf.registerChannelValue(Web, 'titleSnarfer',
|
||||
conf.registerChannelValue(Web, 'snarferReportIOExceptions',
|
||||
registry.Boolean(False, _("""Determines whether the bot will notfiy the user
|
||||
about network exceptions like hostnotfound, timeout ....""")))
|
||||
conf.registerChannelValue(Web, 'snarferShowTargetDomain',
|
||||
registry.Boolean(False, _("""Determines whether the domain name displayed
|
||||
by the snarfer will be the original one (posted on IRC) or the target one
|
||||
(got after following redirects, if any).""")))
|
||||
conf.registerChannelValue(Web, 'nonSnarfingRegexp',
|
||||
registry.Regexp(None, _("""Determines what URLs matching the given regexp
|
||||
will not be snarfed. Give the empty string if you have no URLs that you'd
|
||||
|
@ -131,11 +131,13 @@ class Web(callbacks.PluginRegexp):
|
||||
return
|
||||
try:
|
||||
size = conf.supybot.protocols.http.peekSize()
|
||||
text = utils.web.getUrl(url, size=size)
|
||||
except utils.web.Error, e:
|
||||
fd = utils.web.getUrlFd(url)
|
||||
text = fd.read(size)
|
||||
fd.close()
|
||||
except socket.timeout, e:
|
||||
self.log.info('Couldn\'t snarf title of %u: %s.', url, e)
|
||||
if self.registryValue('snarferReportIOExceptions', channel):
|
||||
irc.reply(url+" : "+utils.web.strError(e), prefixNick=False)
|
||||
irc.reply(url+" : "+utils.web.TIMED_OUT, prefixNick=False)
|
||||
return
|
||||
try:
|
||||
text = text.decode(utils.web.getEncoding(text) or 'utf8',
|
||||
@ -149,7 +151,9 @@ class Web(callbacks.PluginRegexp):
|
||||
self.log.debug('Encountered a problem parsing %u. Title may '
|
||||
'already be set, though', url)
|
||||
if parser.title:
|
||||
domain = utils.web.getDomain(url)
|
||||
domain = utils.web.getDomain(fd.geturl()
|
||||
if self.registryValue('snarferShowTargetDomain', channel)
|
||||
else url)
|
||||
title = utils.web.htmlToText(parser.title.strip())
|
||||
if sys.version_info[0] < 3:
|
||||
if isinstance(title, unicode):
|
||||
|
@ -226,8 +226,8 @@ def banmask(hostmask):
|
||||
else:
|
||||
return '*!*@' + host
|
||||
|
||||
_plusRequireArguments = 'ovhblkqe'
|
||||
_minusRequireArguments = 'ovhbkqe'
|
||||
_plusRequireArguments = 'ovhblkqeI'
|
||||
_minusRequireArguments = 'ovhbkqeI'
|
||||
def separateModes(args):
|
||||
"""Separates modelines into single mode change tuples. Basically, you
|
||||
should give it the .args of a MODE IrcMsg.
|
||||
|
@ -199,7 +199,14 @@ class HtmlToText(HTMLParser, object):
|
||||
self.data.append(data)
|
||||
|
||||
def handle_entityref(self, data):
|
||||
self.data.append(unichr(htmlentitydefs.name2codepoint[data]))
|
||||
if data in htmlentitydefs.name2codepoint:
|
||||
self.data.append(unichr(htmlentitydefs.name2codepoint[data]))
|
||||
elif sys.version_info[0] >= 3 and isinstance(data, bytes):
|
||||
self.data.append(data.decode())
|
||||
elif sys.version_info[0] < 3 and isinstance(data, str):
|
||||
self.data.append(data.decode('utf8', errors='replace'))
|
||||
else:
|
||||
self.data.append(data)
|
||||
|
||||
def getText(self):
|
||||
text = ''.join(self.data).strip()
|
||||
|
Loading…
Reference in New Issue
Block a user