diff --git a/plugins/ChannelStats/plugin.py b/plugins/ChannelStats/plugin.py index 028e05335..6dc0a5520 100644 --- a/plugins/ChannelStats/plugin.py +++ b/plugins/ChannelStats/plugin.py @@ -249,6 +249,9 @@ class ChannelStats(callbacks.Plugin): necessary if the message isn't sent on the channel itself. If 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 . 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) diff --git a/plugins/Math/plugin.py b/plugins/Math/plugin.py index 3e648d8ac..4491d943e 100644 --- a/plugins/Math/plugin.py +++ b/plugins/Math/plugin.py @@ -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: diff --git a/plugins/Seen/plugin.py b/plugins/Seen/plugin.py index 58ff91583..3fc0c5eab 100644 --- a/plugins/Seen/plugin.py +++ b/plugins/Seen/plugin.py @@ -221,6 +221,9 @@ class Seen(callbacks.Plugin): saying. is only necessary if the message isn't sent on the channel itself. 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 . 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 . 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): 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 \ diff --git a/src/utils/net.py b/src/utils/net.py index 544371acd..289a2fe28 100644 --- a/src/utils/net.py +++ b/src/utils/net.py @@ -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