Merge branch 'merge-gribble' into testing

This commit is contained in:
Valentin Lorentz 2012-08-30 11:38:56 +02:00
commit 619dd2ce82
4 changed files with 25 additions and 2 deletions

View File

@ -249,6 +249,9 @@ class ChannelStats(callbacks.Plugin):
necessary if the message isn't sent on the channel itself. If <name>
isn't given, it defaults to the user sending the command.
"""
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 name and ircutils.strEqual(name, irc.nick):
id = 0
elif not name:
@ -310,6 +313,9 @@ class ChannelStats(callbacks.Plugin):
'kicks', 'kicked', 'topics', and 'modes'. Any simple mathematical
expression involving those variables is permitted.
"""
if msg.nick not in irc.state.channels[channel].users:
irc.error(format('You must be in %s to use this command.', channel))
return
# XXX I could do this the right way, and abstract out a safe eval,
# or I could just copy/paste from the Math plugin.
if self._calc_match_forbidden_chars.match(expr):
@ -352,6 +358,9 @@ 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
try:
stats = self.db.getChannelStats(channel)
curUsers = len(irc.state.channels[channel].users)

View File

@ -197,7 +197,7 @@ class Math(callbacks.Plugin):
# use of str() on large numbers loses information:
# str(float(33333333333333)) => '3.33333333333e+13'
# float('3.33333333333e+13') => 33333333333300.0
return '%f' % x
return '%.16f' % x
return str(x)
text = self._mathRe.sub(handleMatch, text)
try:

View File

@ -221,6 +221,9 @@ class Seen(callbacks.Plugin):
saying. <channel> is only necessary if the message isn't sent on the
channel itself. <nick> may contain * as a wildcard.
"""
if msg.nick not in irc.state.channels[channel].users:
irc.error(format('You must be in %s to use this command.', channel))
return
self._seen(irc, channel, name)
seen = wrap(seen, ['channel', 'something'])
@ -235,6 +238,9 @@ class Seen(callbacks.Plugin):
and returns the last time user was active in <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 name and optlist:
raise callbacks.ArgumentError
elif name:
@ -269,6 +275,9 @@ class Seen(callbacks.Plugin):
Returns the last thing said in <channel>. <channel> is only necessary
if the message isn't sent in 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
self._last(irc, channel)
last = wrap(last, ['channel'])
@ -295,6 +304,9 @@ class Seen(callbacks.Plugin):
<channel> is only necessary if the message isn't sent in 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
self._user(irc, channel, user)
user = wrap(user, ['channel', 'otherUser'])
@ -313,6 +325,8 @@ class Seen(callbacks.Plugin):
irc.error(format(_('%s must be in %s to use this command.'),
('You' if nick == msg.nick else nick), channel))
return
if nick is None:
nick = msg.nick
end = None # By default, up until the most recent message.
for (i, m) in utils.seq.renumerate(irc.state.history):
if end is None and m.command == 'JOIN' and \

View File

@ -114,7 +114,7 @@ def isIPV4(s):
0
"""
try:
return bool(socket.inet_aton(s))
return bool(socket.inet_aton(str(s)))
except socket.error:
return False