Closed builtinnya closed 11 years ago
Looks good.
Something needed to get this forward
Your simpler version looks nice.
Here is an explanation how to add and include message handlers:
If you want to add a completely new handler, you define
Handler
(e.g. CommandHandler
) in sevabot.bot.handlers
moduleOnce defined, the handler classes will be automatically instantiated and initialized when Sevabot.start()
.
In handler classes, you must define two methods:
init(self, skype)
that is used to initialize a handler objecthandle(self, msg, status)
that is automatically called on every message received and sentIf you want to add just a built-in command (!command
), you define in CommandHandler
class
builtin_
(e.g. builtin_reload(self, args, msg, status)
)Once defined, the method will be automatically called if !method_name_after_builtin_
message received
(e.g. !reload
.)
I wrote in 70ba7a8
that msg.Chat.Body.encode('utf-8') seems to fail on some languages (e.g. Japanese)
but that was wrong.
It is the undecoded (remaining encoded) string that causes the error when calling keyword.startswith('!')
.
We can fix it by calling decode('utf-8')
on each word before checking keyword.startswith('!')
.
Working on this now
I think we stil need to update manual regarding new build-in commands (call). I am not sure what one is supposed to do with that.
Also moved to work to dev branch... I got inspired by your ideas and I am working to make stateful, reloadable, Python handlers
Great! Stateful handlers are what I want.
The built-in !call
command is for hosting a conference call of a chat so that the caller (one typed !call) can feel
free to disconnect from the call.
This is just my local need. Now I think !call
should not be a built-in command.
Now when we have stateful handlers maybe we can refactor !call to be its own handler?
I think we just need to route more Skype events to the handlers - now it only has callback for chat message.
After this is done we could release version 1.2 :)
I'm working on the stateful handler version of the !call
.
I think callback manager (adder/remover) is enough for the handlers to handle every Skype event. Each added callback will be called in order.
I've done some fixes and improves.
Important changes are: