Skip to content

unreg/actorbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

82 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ActorBot

A simple python implementation Actor Messaging bot API ======================================================

Features

  • simple, small and extensible. It's easy to write own Actor Messaging bots.
  • pure Python with asyncio and aiohttp
  • websocket connection to Actor ws|wss API-endpoint
  • sending and receiving messages
  • API module
  • LICENSE

API module

  • Messaging: SendMessage, UpdateMessageContent
  • Groups: CreateGroup, CreateGroupWithOwner, UpdateShortName, AddGroupExtString, AddGroupExtBool, RemoveExt, InviteUser
  • KeyValue: SetVAlue, GetValue, DeleteValue, GetKeys
  • Files: UploadFile, DownloadFile
  • Stickers: CreateStickerPack, AddSticker, ShowStickerPacks, ShowStickers, DeleteSticker, MakeStickerPackDefault, UnmakeStickerPackDefault,
  • Bots: CreateBot
  • Users: FindUser, ChangeUserName, ChangeUserNickname, ChangeUserAbout, ChangeUserAvatar, IsAdmin, AddSlashCommand, RemoveSlashCommand, AddUserExtString, AddUserExtBool, RemoveUserExt
  • WebHooks: RegisterHook, GetHooks

Requirements

Getting started

Make your own conversation inherited from base class Conversation. For example simple echo bot (more in Wiki):

from actorbot.bots import Conversation
from actorbot.api import messaging


class EchoConversation(Conversation):
    """ Simple echo bot """
    async def message_handler(self, message):
        out_msg = messaging.SendMessage(self._get_id(),
                                        peer=self._peer,
                                        message=message)
        await self.send(out_msg)

    async def response_handler(self, message):
        await super().response_handler(message)

run one or more bots through starter:

from actorbot import Bot
from actorbot.bots import EchoConversation

...

ownbot = Bot(endpoint='YOUR_ACTOR_SERVER_ENDPOINT',
             token='YOUR_BOT_TOKEN',
             name='SOME_BOT_NAME',
             conversation=EchoConversation)

bots = [ownbot]

transports = [asyncio.ensure_future(bot.transport.run()) for bot in bots]
processors = [asyncio.ensure_future(bot.run()) for bot in bots]

loop.run_until_complete(asyncio.wait(transports + processors))

...

Feedback

https://gitter.im/pyactorbot

About

A simple python implementation Actor Messaging bot API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages