Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature fix modules #464

Merged
merged 3 commits into from
Mar 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions willie/modules/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ def msg(bot, trigger):
return
if not trigger.admin:
return
if trigger.group(2) is None:
return

channel, _sep, message = trigger.group(2).partition(' ')
message = message.strip()
Expand All @@ -109,6 +111,8 @@ def me(bot, trigger):
return
if not trigger.admin:
return
if trigger.group(2) is None:
return

channel, _sep, action = trigger.group(2).partition(' ')
action = action.strip()
Expand Down
3 changes: 3 additions & 0 deletions willie/modules/calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ def c(bot, trigger):
@example('.py len([1,2,3])', '3')
def py(bot, trigger):
"""Evaluate a Python expression."""
if not trigger.group(2):
return bot.say("Need an expression to evaluate")

query = trigger.group(2)
uri = 'http://tumbolia.appspot.com/py/'
answer = web.get(uri + web.quote(query))
Expand Down
21 changes: 12 additions & 9 deletions willie/modules/rand.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,18 @@ def rand(bot, trigger):
arg1 = trigger.group(3)
arg2 = trigger.group(4)

if arg2 is not None:
low = int(arg1)
high = int(arg2)
elif arg1 is not None:
low = 0
high = int(arg1)
else:
low = 0
high = sys.maxint
try:
if arg2 is not None:
low = int(arg1)
high = int(arg2)
elif arg1 is not None:
low = 0
high = int(arg1)
else:
low = 0
high = sys.maxint
except (ValueError, TypeError):
return bot.reply("Arguments must be of integer type")

if low > high:
low, high = high, low
Expand Down