opensourcehacker / sevabot

A Skype bot supporting integration with external services
http://sevabot-skype-bot.readthedocs.org/
565 stars 121 forks source link

Various fixes and improves #37

Closed builtinnya closed 11 years ago

builtinnya commented 11 years ago

I've done some fixes and improves.

Important changes are:

miohtama commented 11 years ago

Looks good.

Something needed to get this forward

builtinnya commented 11 years ago

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

Once defined, the handler classes will be automatically instantiated and initialized when Sevabot.start(). In handler classes, you must define two methods:

If you want to add just a built-in command (!command), you define in CommandHandler class

Once defined, the method will be automatically called if !method_name_after_builtin_ message received (e.g. !reload.)

builtinnya commented 11 years ago

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('!').

miohtama commented 11 years ago

Working on this now

miohtama commented 11 years ago

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.

miohtama commented 11 years ago

Also moved to work to dev branch... I got inspired by your ideas and I am working to make stateful, reloadable, Python handlers

builtinnya commented 11 years ago

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.

miohtama commented 11 years ago

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 :)

builtinnya commented 11 years ago

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.