Skip to main content

No project description provided

Project description

botovod

MIT license built with Python3 paypal

Description

This is a simple and easy-to-use library for interacting with the Instagram. The library works through the web interface of the Instagram and does not depend on the official API

NOT UPDATED INFORMATION

Contents

Release Notes

Version 0.1.4

  • Add new dbdriver - Gino
  • Fix bugs

Version 0.1.5

  • Add new methods for telegram Agent
  • Add emoji

Version 0.1.6

  • Fix gino getting follower
  • Adding item assignments for Botovod objects

Getting Started

Installation from Pip

For installation botovod library from pip you should have pip with python (prefer python3.6 or later)

pip install botovod

Installation from GitHub

To basic installation from GitHub repository you should have git, python3 (prefer python3.6 or later), pip (optionally) in your system

git clone https://github.com/OlegYurchik/botovod.git
cd botovod
pip install .

or

git clone https://github.com/OlegYurchik/botovod.git
cd botovod
python setup.py install

Quick Start

After installation, you can use the library in your code. Below is a sneak example of using the library

from botovod import Botovod
from botovod.agents.telegram import TelegramAgent


def echo(agent, chat, messsage):
    agent.send_message(chat, text=message.text)


botovod = Botovod()
botovod.handlers.append(echo)

telegram_agent = TelegramAgent(token="your-telegram-token", method="polling)
botovod.agents["telegram"] = telegram_agent

botovod.start()

This code setup and run Telegram echo-bot by polling

from botovod import Botovod
from botovod.agents.telegram import TelegramAgent
from botovod.dbdrivers.sqlalchemy import DBDriver
from botovod.dialogs import Dialog


class RegisterDialog(Dialog):
    def start(self):
        self.reply(text="Hello, my friend!")
        self.reply(text="What is your name?")
        self.set_next_step(self.what_name)

    def what_name(self):
        name = self.message.text
        self.follower.set_value("name", name)
        self.reply(text="Nice to meet you, %s. What would you want?" % name)
        self.set_next_step(self.menu)

    def menu(self):
        pass
        # your code


botovod = Botovod(DBDriver(engine="sqlite", database="file.mdb"))
botovod.handlers.append(RegisterDialog)

telegram_agent = TelegramAgent(token="your-telegram-token")
botovod.agents["telegram"] = telegram_agent

botovod.start()

This code setup and run telegram code which working with database and followers

Documentation

botovod

package botovod

botovod.AgentDict

class botovod.AgentDict

Attributes

  • botovod: botovod.Botovod

Botovod object

Methods

  • __init__(self, botovod: botovod.Botovod)

Constructor for AgentDict

  • __setitem__(self, key: str, value: botovod.agents.Agent)

Setting agents like a dict

  • __delitem__(self, key: str)

Deleting agents like a dict

botovod.Botovod

class botovod.Botovod

Attributes

  • dbdriver: botovod.dbdrivers.DBDriver or None

Driver for working with database (for save data about followers and dialogs)

  • agents: botovod.AgentDict

Dictionary for bots agents

  • handlers: list

List with message and event handlers

  • logger: logging.Logger Logger

Methods

  • __init__(self, dbdriver: (DBDriver, None)=None, logger: logging.Logger=logging.getLogger(name))

This method initial botovod object

  • start(self)

Starting all agents in botovod

  • a_start(self)

Coroutine. Starting all agents in botovod

  • stop(self)

Stopping all agents in botovod

  • a_stop(self)

Coroutine. Stopping all agents in botovod

  • listen(selfname: str, headers: dict, body: string) -> (int, dict, str) or None

Method, providing for webservers for listening requests from messengers servers and handle it.

  • a_listen(self, name: str, headers: dict, body: string) -> (int, dict, str} or None

Coroutine, providing for webservers for listening requests from messengers servers and handle it.

botovod.agents

package botovod.agents

botovod.agents.Agent

class botovod.agent.Agent

Attributes

  • botovod: botovod.Botovod

Botovod object

  • name: str

Agent name in botovod

  • running: bool

Varibale which True if agent is running else False

  • logger: logging.Logger

Logger

Methods

  • __init__(self, logger: logging.Logger=logging.getLogger(name)):

Agent constructor

  • __repr__(self) -> str

Returning name of class

  • listen(self, headers: dict, body: string) -> (int, dict, str) or None:

Method for getting requests from agent messenger and handle it

  • a_listen(self, headers: dict, body: string) -> (int, dict, str) or None:

Coroutine for getting requests from agent messenger and handler it

  • start(self):

Abstract method for run agent

  • a_start(self):

Abstract coroutine for run agent

  • stop(self):

Abstract method for stop agent

  • a_stop(self):

Abstract coroutine for stop agent

  • parser(self, headers: dict, body: str) -> list[tuple(Chat, Message))

Abstract method for parsing request and return list[tuple(Chat, Message))

  • a_parser(self, headers: dict, body: str) -> list[tuple(Chat, Message)]

Abstract coroutine for parsing request and return list[tuple(Chat, Message)]

  • responser(self, headers: dict, body: str) -> (int, dict, str)

Abstract method who return tuple with info for response to messenger

  • a_responser(self, headers: dict, body: str) -> (int, dict, str)

Abstract coroutine who return tuple with info for response to messenger

  • send_message(self, chat: botovod.agents.Chat, text: str or None=None, images: Iterator of botovod.agents.Image=[], audios: Iterator of botovod.agents.Audio]=[], documents: Iterator of botovod.agents.Document=[], videos: Iterator of botovod.agents.Video=[], locations: Iterator of botovod.agents.Location=[], keyboard: botovod.agents.Keyboard or None=None, raw: dict or None=None)

Abstract method for sending message

  • a_send_message(self, chat: botovod.agents.Chat, text: str or None=None, images: Iterator of botovod.agents.Image=[], audios: Iterator of botovod.agents.Audio]=[], documents: Iterator of botovod.agents.Document=[], videos: Iterator of botovod.agents.Video=[], locations: Iterator of botovod.agents.Location=[], keyboard: botovod.agents.Keyboard or None=None, raw: dict or None=None)

Abstract coroutine for sending message

botovod.agents.Entity

class botovod.agents.Entity

Attributes

  • raw: dict

Dictonary with additional information

Methods

  • __init__(self)

Constructor for Entity

botovod.agents.Chat

class botovod.agents.Chat(botovod.agents.Entity)

Attributes

  • agent: botovod.agents.Agent

Agent for this Chat

  • id: str

Chat ID for this messenger

Nethods

  • __init__(self, agent: botovod.agents.Agent, id: str)

Chat constructor

botovod.agents.Message

class botovod.agents.Message(botovod.agents.Entity)

Attributes

  • text: str or None

Message text

  • images: list of botovod.agents.Image

Message images

  • audios: list of botovod.agents.Audio

Message audios

  • videos: list of botovod.agents.Video

Message videos

  • documents: list of botovod.agents.Document

Message documents

  • locations: list of botovod.agents.Location

Message locations

  • date: datetime.datetime

Date and time of message recieved

Methods

  • __init__(self)

Message constructor

botovod.agents.Attachment

class botovod.agents.Attachment(botovod.agents.Entity)

Attributes

  • url: str or None

URL for attachment

  • file: str or None

File path in hard disk to attachment

botovod.agents.Image

class botovod.agents.Image(botovod.agents.Attachment)

botovod.agents.Audio

class botovod.agents.Audio(botovod.agents.Attachment)

botovod.agents.Video

class botovod.agents.Video(botovod.agents.Attachment)

botovod.agents.Document

class botovod.agents.Document(botovod.agents.Attachment)

botovod.agents.Location

class botovod.agents.Location(botovod.agents.Entity)

Attributes

  • latitude: float

Location latitude

  • longitude: float

Location longitude

Methods

  • __init__(self, latitude: float, longitude: float)

Location constructor

botovod.agents.Keyboard

class botovod.agents.Keyboard(botovod.agents.Entity)

Attributes

  • buttons: Iterator of botovod.agents.KeyboardButton

buttons for Keyboard

Methods

  • __init__(self, *butons: Iterator of botovod.agents.KeyboardButton)

Keyboard constructor

botovod.agents.KeyboardButton

class botovod.agents.KeyboardButton

Attributes

  • text: str

Button text

Methods

  • __init__(self, text: str)

KeyboardButton constructor

botovod.dbdrivers

package botovod.dbdrivers

botovod.dbdrivers.DBDriver

class botovod.dbdrivers.DBDriver

botovod.dbdrivers.Follower

class botovod.dbdrivers.Follower

botovod.dialogs

module botovod.dialogs

botovod.dialogs.Dialog

class botovod.dialogs.Dialog

Attributes

  • agent: botovod.agents.Agent

Agent which get message

  • chat: botovod.agents.Chat

Chat

  • message: botovod.agents.Message

Message

  • follower: botovod.dbdrivers.Folower

Follower

Methods

  • __init__(self, agent: botovod.agents.Agent, chat: botovod.agents.Chat, message: botovod.agents.Message)

Constructor for creating dialog object

  • __new__(self, agent: botovod.agents.Agent, chat: botovod.agents.Chat, message: botovod.agents.Message)

Method for handling request

  • reply(self, text: str or None=None, images: Iterator of botovod.agents.Image=[], audios: Iterator of botovod.agents.Audio=[], documents: Iterator of botovod.agents.Document=[], videos: Iterator of botovod.agents.Video=[], locations: Iterator of botovod.agents.Location=[], keyboard: botovod.agents.Keyboard or None=None, raw=None)

Method for replying to message

  • a_reply(self, text: str or None=None, images: Iterator of botovod.agents.Image=[], audios: Iterator of botovod.agents.Audio=[], documents: Iterator of botovod.agents.Document=[], videos: Iterator of botovod.agents.Video=[], locations: Iterator of botovod.agents.Location=[], keyboard: botovod.agents.Keyboard or None=None, raw=None)

Corotuine for replying to message

  • set_next_step(self, function: Callable)

Method for setting next function for handling message in dialog

  • a_set_next_step(self, function: Callable)

Coroutine for setting next function for handling message in dialog

  • start(self)

Abstract method or coroutine for handling first message from request

Message

class botovod.Message

  • init()

Message constructor, create fields:

  • text - Message text
  • images - List of images
  • audios - List of audios
  • videos - List of videos
  • documents - List of documents
  • locations - List of locations

Attachment

class botovod.Attachment

Fields:

  • url - Url for getting file
  • file_path - File in local disk

Classes Image, Audio, Video and Document is a subclass of Attchment and has no extensions

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

botovod-0.1.5.tar.gz (40.1 kB view hashes)

Uploaded Source

Built Distribution

botovod-0.1.5-py3-none-any.whl (41.1 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page