[telepathy-ashes/master] Case insensitive commands and cleanup.
David Laban
david.laban at collabora.co.uk
Sat Oct 24 08:21:13 PDT 2009
---
ashes/tools/commands.py | 21 +++++++++++++--------
1 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/ashes/tools/commands.py b/ashes/tools/commands.py
index 5607df1..d8e0588 100644
--- a/ashes/tools/commands.py
+++ b/ashes/tools/commands.py
@@ -49,7 +49,7 @@ class CommandExecutor(TextChannelEchoer):
"""
Dispatches the command to the correct function.
"""
- command_name = text.partition(" ")[0][1:]
+ command_name = text.partition(" ")[0][1:].lower()
method = getattr(self, "do_" + command_name, None)
if isinstance(method, types.MethodType):
try:
@@ -94,7 +94,7 @@ class CommandExecutor(TextChannelEchoer):
Prints help on command or the list of all commands.
"""
help_, _, arg = text.partition(' ')
- assert help_ == "!help"
+ assert help_.lower() == "!help"
if arg.strip(): # ignore whitespace
return self.get_help_for(arg)
else:
@@ -109,9 +109,9 @@ class CommandExecutor(TextChannelEchoer):
"""
ret = []
cm_version = os.environ.get('CM_VERSION', None)
- other_versions = os.environ.get('OTHER_VERSIONS', None)
- git_revision = os.environ.get('GIT_REVISION', None)
- git_url = os.environ.get('GIT_URL', None)
+ other_versions = os.environ.get('TELEPATHY_VERSIONS', None)
+ git_revision = os.environ.get('ECHO_GIT_REVISION', None)
+ git_url = os.environ.get('ECHO_GIT_URL', None)
ret.append("I am the Telepathy Echo Bot, written by David Laban "
"<david.laban at collabora.co.uk>")
@@ -126,7 +126,7 @@ class CommandExecutor(TextChannelEchoer):
if other_versions:
- ret.append("Other telepathy components installed are: %s"
+ ret.append("Telepathy components installed are: %s"
% other_versions.replace('\n', ' '))
return '\n'.join(ret)
@@ -136,11 +136,16 @@ class CommandExecutor(TextChannelEchoer):
!delay timeout message
Pretends that message actually arrived timeout seconds later than it did.
+ For example, !delay 10 !callme will start a call in 10 seconds' time.
"""
delay_, _, args = text.partition(' ')
- assert delay_ == "!delay"
+ assert delay_.lower() == "!delay"
timeout, _, message = args.strip().partition(' ')
- timeout = int(timeout)
+ try:
+ timeout = int(timeout)
+ except ValueError:
+ return ("timeout must be an integer number of seconds:\n"
+ + self.get_help_for('delay'))
gobject.timeout_add_seconds(timeout, self.handle_message_and_reply,
id, timestamp+timeout, sender, type, flags, message)
--
1.5.6.5
More information about the telepathy-commits
mailing list