Stop calc from flooding, and can now join channels with a key.

master
Sean B. Palmer 2008-06-19 18:58:24 +01:00
parent 68f2036546
commit bf20b46f74
5 changed files with 14 additions and 10 deletions

5
bot.py
View File

@ -152,11 +152,12 @@ class Phenny(irc.Bot):
self.bot = phenny
def __getattr__(self, attr):
sender = origin.sender or text
if attr == 'reply':
return (lambda msg:
self.bot.msg(origin.sender, origin.nick + ': ' + msg))
self.bot.msg(sender, origin.nick + ': ' + msg))
elif attr == 'say':
return lambda msg: self.bot.msg(origin.sender, msg)
return lambda msg: self.bot.msg(sender, msg)
return getattr(self.bot, attr)
return PhennyWrapper(self)

View File

@ -12,10 +12,13 @@ def join(phenny, input):
# 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']
channel, key = input.group(1), input.group(2)
if not key:
phenny.write(['JOIN'], channel)
else: phenny.write(['JOIN', channel, key])
join.rule = r'\.join (#\S+)(?: *(\S+))?'
join.priority = 'low'
join.example = '.join #example'
join.example = '.join #example or .join #example key'
def part(phenny, input):
"""Part the specified channel. This is an admin-only command."""

View File

@ -61,7 +61,7 @@ def calc(phenny, input):
elif ' in ' in q:
result += ' ' + q.split(' in ', 1)[1]
phenny.say(q + ' = ' + result)
phenny.say(q + ' = ' + result[:350])
else: phenny.reply("Sorry, can't calculate that.")
calc.commands = ['calc']
calc.example = '.calc 5 + 3'

View File

@ -64,7 +64,7 @@ def tr(phenny, context):
else: msg = 'The %s to %s translation failed, sorry!' % (input, output)
phenny.reply(msg)
else: phenny.reply('Ehwhatnow?')
else: phenny.reply('Language guessing failed, so try suggesting one!')
tr.rule = ('$nick', ur'(?:([a-z]{2}) +)?(?:([a-z]{2}) +)?["“](.+?)["”]\? *$')
tr.example = '$nickname: "mon chien"? or $nickname: fr "mon chien"?'

View File

@ -24,7 +24,7 @@ r_redirect = re.compile(
abbrs = ['etc', 'ca', 'cf', 'Co', 'Ltd', 'Inc', 'Mt', 'Mr', 'Mrs',
'Dr', 'Ms', 'Rev', 'Fr', 'St', 'Sgt', 'pron', 'approx', 'lit',
'syn'] \
'syn', 'transl'] \
+ list('ABCDEFGHIJKLMNOPQRSTUVWXYZ') \
+ list('abcdefghijklmnopqrstuvwxyz')
t_sentence = r'^.{5,}?(?<!\b%s)(?:\.(?= [A-Z0-9]|\Z)|\Z)'
@ -97,8 +97,8 @@ def wikipedia(term, last=False):
and not '(images and media)' in para
and not 'This article contains a' in para
and not 'id="coordinates"' in para
and not 'class="thumb' in para
and not 'style="display:none"' in para]
and not 'class="thumb' in para]
# and not 'style="display:none"' in para]
for i, para in enumerate(paragraphs):
para = para.replace('<sup>', '|')