Coder Social home page Coder Social logo

actorbot's Introduction

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, InviteUser
  • KeyValue: SetVAlue, GetValue, DeleteValue, GetKeys
  • Files: UploadFile, DownloadFile
  • Stickers: CreateStickerPack, AddSticker, ShowStickers, DeleteSticker, MakeStickerPackDefault
  • Bots: CreateBot
  • Users: FindUser, ChangeUserName, ChangeUserNickname, ChangeUserAbout, ChangeUserAvatar, IsAdmin, AddSlashCommand, RemoveSlashCommand, AddUserExtString, AddUserExtBool, RemoveUserExt

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

Join in Actor group https://actor.im/join/pyactorbot

actorbot's People

Contributors

unreg avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.