Some documentation and minor fixes.
parent
5cad6661c9
commit
fb2cd452e9
|
@ -8,22 +8,27 @@ http://inamidst.com/phenny/
|
|||
"""
|
||||
|
||||
def join(phenny, input):
|
||||
"""Join the specified channel. This is an admin-only command."""
|
||||
# Can only be done in privmsg by an admin
|
||||
if input.sender.startswith('#'): return
|
||||
if input.admin:
|
||||
phenny.write(['JOIN'], input.group(2))
|
||||
join.commands = ['join']
|
||||
join.priority = 'low'
|
||||
join.example = '.join #example'
|
||||
|
||||
def part(phenny, input):
|
||||
"""Part the specified channel. This is an admin-only command."""
|
||||
# Can only be done in privmsg by an admin
|
||||
if input.sender.startswith('#'): return
|
||||
if input.admin:
|
||||
phenny.write(['PART'], input.group(2))
|
||||
part.commands = ['part']
|
||||
part.priority = 'low'
|
||||
part.example = '.part #example'
|
||||
|
||||
def quit(phenny, input):
|
||||
"""Quit from the server. This is an owner-only command."""
|
||||
# Can only be done in privmsg by the owner
|
||||
if input.sender.startswith('#'): return
|
||||
if input.owner:
|
||||
|
|
|
@ -28,6 +28,7 @@ subs = [
|
|||
]
|
||||
|
||||
def calc(phenny, input):
|
||||
"""Use the Frink online calculator."""
|
||||
q = input.group(2)
|
||||
if not q:
|
||||
return phenny.say('0?')
|
||||
|
@ -63,6 +64,7 @@ def calc(phenny, input):
|
|||
phenny.say(q + ' = ' + result)
|
||||
else: phenny.reply("Sorry, can't calculate that.")
|
||||
calc.commands = ['calc']
|
||||
calc.example = '.calc 5 + 3'
|
||||
|
||||
if __name__ == '__main__':
|
||||
print __doc__.strip()
|
||||
|
|
|
@ -186,7 +186,7 @@ TimeZones.update(TZ1)
|
|||
|
||||
@deprecated
|
||||
def f_time(self, origin, match, args):
|
||||
""".t [ <timezone> ] - Returns the current time"""
|
||||
"""Returns the current time."""
|
||||
tz = match.group(2) or 'GMT'
|
||||
|
||||
# Personal time zones, because they're rad
|
||||
|
@ -231,8 +231,11 @@ def f_time(self, origin, match, args):
|
|||
msg = time.strftime("%a, %d %b %Y %H:%M:%S " + str(tz), timenow)
|
||||
self.msg(origin.sender, msg)
|
||||
f_time.commands = ['t']
|
||||
f_time.name = 't'
|
||||
f_time.example = '.t UTC'
|
||||
|
||||
def beats(phenny, input):
|
||||
"""Shows the internet time in Swatch beats."""
|
||||
beats = ((time.time() + 3600) % 86400) / 86.4
|
||||
beats = int(math.floor(beats))
|
||||
phenny.say('@%03i' % beats)
|
||||
|
@ -243,6 +246,7 @@ def divide(input, by):
|
|||
return (input / by), (input % by)
|
||||
|
||||
def yi(phenny, input):
|
||||
"""Shows whether it is currently yi or not."""
|
||||
quadraels, remainder = divide(int(time.time()), 1753200)
|
||||
raels = quadraels * 4
|
||||
extraraels, remainder = divide(remainder, 432000)
|
||||
|
@ -255,6 +259,7 @@ yi.priority = 'low'
|
|||
# d8uv d8uv d8uv d8uv d8uv d8uv d8uv
|
||||
|
||||
def tock(phenny, input):
|
||||
"""Shows the time from the USNO's atomic clock."""
|
||||
u = urllib.urlopen('http://tycho.usno.navy.mil/cgi-bin/timer.pl')
|
||||
info = u.info()
|
||||
u.close()
|
||||
|
|
|
@ -65,6 +65,7 @@ def codepoint_extended(arg):
|
|||
yield about(u, cp, name)
|
||||
|
||||
def u(phenny, input):
|
||||
"""Look up unicode information."""
|
||||
arg = input.bytes[3:]
|
||||
# phenny.msg('#inamidst', '%r' % arg)
|
||||
if not arg:
|
||||
|
@ -115,11 +116,14 @@ def u(phenny, input):
|
|||
phenny.reply(' '.join('U+%04X' % ord(c) for c in text))
|
||||
else: phenny.reply('Sorry, your input is too long!')
|
||||
u.commands = ['u']
|
||||
u.example = '.u 203D'
|
||||
|
||||
def bytes(phenny, input):
|
||||
"""Show the input as pretty printed bytes."""
|
||||
b = input.bytes
|
||||
phenny.reply('%r' % b[b.find(' ') + 1:])
|
||||
bytes.commands = ['bytes']
|
||||
bytes.example = '.bytes \xe3\x8b\xa1'
|
||||
|
||||
if __name__ == '__main__':
|
||||
print __doc__.strip()
|
||||
|
|
|
@ -67,7 +67,9 @@ def f_title(self, origin, match, args):
|
|||
uri = (uri or '').encode('utf-8')
|
||||
|
||||
if not uri and hasattr(self, 'last_seen_uri'):
|
||||
uri = self.last_seen_uri
|
||||
uri = self.last_seen_uri.get('#swhack')
|
||||
if not uri:
|
||||
return phenny.msg(origin.sender, 'I need a URI to give the title of...')
|
||||
|
||||
if not ':' in uri:
|
||||
uri = 'http://' + uri
|
||||
|
@ -140,7 +142,9 @@ f_title.commands = ['title']
|
|||
|
||||
def noteuri(phenny, input):
|
||||
uri = input.group(1).encode('utf-8')
|
||||
phenny.bot.last_seen_uri = uri
|
||||
if not hasattr(phenny.bot, 'last_seen_uri'):
|
||||
phenny.bot.last_seen_uri = {}
|
||||
phenny.bot.last_seen_uri[input.sender] = uri
|
||||
noteuri.rule = r'.*(http://[^<> "]+)[,.]?'
|
||||
noteuri.priority = 'low'
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ help.rule = ('$nick', r'(?i)help(?:[?!]+)?$')
|
|||
help.priority = 'low'
|
||||
|
||||
def stats(phenny, input):
|
||||
"""Show information on command usage patterns."""
|
||||
commands = {}
|
||||
users = {}
|
||||
channels = {}
|
||||
|
|
|
@ -48,6 +48,7 @@ def formatnumber(n):
|
|||
return ''.join(parts)
|
||||
|
||||
def g(phenny, input):
|
||||
"""Queries Google for the specified input."""
|
||||
query = input.group(2)
|
||||
if not query:
|
||||
return phenny.reply('.g what?')
|
||||
|
@ -57,8 +58,10 @@ def g(phenny, input):
|
|||
else: phenny.reply("No results found for '%s'." % query)
|
||||
g.commands = ['g']
|
||||
g.priority = 'high'
|
||||
g.example = '.g swhack'
|
||||
|
||||
def gc(phenny, input):
|
||||
"""Returns the number of Google results for the specified input."""
|
||||
query = input.group(2)
|
||||
if not query:
|
||||
return phenny.reply('.gc what?')
|
||||
|
@ -66,6 +69,7 @@ def gc(phenny, input):
|
|||
phenny.say(query + ': ' + num)
|
||||
gc.commands = ['gc']
|
||||
gc.priority = 'high'
|
||||
gc.example = '.gc extrapolate'
|
||||
|
||||
r_query = re.compile(
|
||||
r'\+?"[^"\\]*(?:\\.[^"\\]*)*"|\[[^]\\]*(?:\\.[^]\\]*)*\]|\S+'
|
||||
|
|
|
@ -40,7 +40,8 @@ def dumpReminders(fn, data):
|
|||
for remindon in data[tellee]:
|
||||
line = '\t'.join((tellee,) + remindon)
|
||||
f.write(line + '\n')
|
||||
f.close()
|
||||
try: f.close()
|
||||
except IOError: pass
|
||||
return True
|
||||
|
||||
def setup(self):
|
||||
|
|
|
@ -84,6 +84,9 @@ def f_weather(self, origin, match, args):
|
|||
if args[0].startswith('.weather '): return
|
||||
|
||||
icao_code = match.group(2)
|
||||
if not icao_code:
|
||||
return self.msg(origin.sender, 'Try .weather London, for example?')
|
||||
|
||||
if (not len(icao_code) == 4) or \
|
||||
(len(icao_code) > 1 and icao_code[0] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' and
|
||||
icao_code[1] in 'abcdefghijklmnopqrstuvwxyz'):
|
||||
|
|
Loading…
Reference in New Issue