Skip to content

mollyporph/skypebot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

skypebot

community automation through skype

Builds Build status Build status

This is a modular/service approach applied to a skype chatbot.

if you want to develop your own integration or service all you have to do is implement IChatbotService and add your service to the ninjectmodule in ChatbotModule.

All chatbotservices implement IChatbotService

public interface IChatBotService
    {
        bool CanHandleCommand(string command);
        void HandleCommand(string fromHandle,string fromDisplayName, string command,string parameters);
    }

You also need to add an IChatBot variable and inject it through your constructor if you want to send messages.

When your chatbotservice is done, add it as a module in chatbotmodule.cs

  public override void Load()
        {
            Bind<IChatBotService>().To<MyAwesomeService>().InSingletonScope();
            ...
        }

Your CanHandleCommand should probably either use a list of commands or in case of a logger return true for all non-commands

//A typical command-oriented service
public bool CanHandleCommand(string command)
    {
        return new List<string>(){ "!command1", "!command2" }.Contains(command);
    }
//Might not want to capture the commands if you're doing a logger-type service
public bool CanHandleCommand(string command)
    {
       return !command.StartsWith("!");
    }

There is also a persisted user-database if you need it, which containts skype-handles and permissions. By default all permissions are rebuilt in the database through reflection (the permission beeing the typename of the service)

I've also built a small function to apply all permissions to my own handle, feel free to change this (In the future I'll add module isolation and build a config-file for admin-account so we don't keep that in code :)

To implement authorization in your HandleCommand use the following snippet:

  public void HandleCommand(string fromHandle, string fromDisplayName, string command, string parameters)
        {
          if (!_authorizationManager.HasPermission(fromHandle, this.GetType().Name)) return;
          ....
        }

You also need to edit the JoinChat chatname to whichever chat you want to use. The easiest way to get the chatname of a chat is to put a breakpoint in processcommand, then look at the msg-parameter and get the chatname.

About

community automation through skype

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages