summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean B. Palmer <http://inamidst.com/sbp/>2008-06-19 18:58:24 +0100
committerSean B. Palmer <http://inamidst.com/sbp/>2008-06-19 18:58:24 +0100
commitbf20b46f7473ec323cd38464fd8662c5fbc2c72a (patch)
tree4d6b8ac3f2277999dc60b3ec20cb3ac7687c0c61
parent68f2036546c286bb864dbc2ade251041bf7e6be9 (diff)
downloadbot-bf20b46f7473ec323cd38464fd8662c5fbc2c72a.tar.gz
bot-bf20b46f7473ec323cd38464fd8662c5fbc2c72a.tar.bz2
bot-bf20b46f7473ec323cd38464fd8662c5fbc2c72a.zip
Stop calc from flooding, and can now join channels with a key.
-rwxr-xr-xbot.py5
-rwxr-xr-xmodules/admin.py9
-rwxr-xr-xmodules/calc.py2
-rwxr-xr-xmodules/translate.py2
-rwxr-xr-xmodules/wikipedia.py6
5 files changed, 14 insertions, 10 deletions
diff --git a/bot.py b/bot.py
index 0ba11d6..3564712 100755
--- a/bot.py
+++ b/bot.py
@@ -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)
diff --git a/modules/admin.py b/modules/admin.py
index e1dd908..3c3356f 100755
--- a/modules/admin.py
+++ b/modules/admin.py
@@ -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."""
diff --git a/modules/calc.py b/modules/calc.py
index 9a3b174..e664cb2 100755
--- a/modules/calc.py
+++ b/modules/calc.py
@@ -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'
diff --git a/modules/translate.py b/modules/translate.py
index 06efa62..baa430d 100755
--- a/modules/translate.py
+++ b/modules/translate.py
@@ -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"?'
diff --git a/modules/wikipedia.py b/modules/wikipedia.py
index 1af1c79..9827cc6 100755
--- a/modules/wikipedia.py
+++ b/modules/wikipedia.py
@@ -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>', '|')