Skip to main content

A mini framework for building bots using python and can be served using different ways.

Project description

iaBot

iaBot is a Python library for creating simple bots and serving it with the different ways available.

PyPI version Build

Installation

Use the package manager pip to install iaBot.

pip install iaBot

A simple bot

from iabot import CreateBot
from iabot.handlers import SystemInformationHandler
from iabot.servers import HttpServer

handlers = [
   SystemInformationHandler
]
bot = CreateBot(
   handlers=handlers
)
bot_server = HttpServer(bot)
bot_server.run()

This creates a simple bot that will be listening to HttpRequests on the port 8000. Using any tool available send a post request to http://<your_domain.com>:8000/ with the following data.

{
  "handler": "system",
  "action": "time"
}

On successfull request you will get time in the response as json.

Handlers

These are used to group a set of similar actions. You can create your own handlers by inheriting the base handler.

from iabot.handlers import BaseHandler

class StockHandler(BaseHandler):
    handle = 'stock'

    def get_stocks(self, *args, **kwargs):
      .....
      ....

Once you create a handler with the actions you can register it to a bot by adding the handler to the list of handlers.

Actions

These are functions that a bot can execute to do the job when asked for. In the above StockHandler, get_stocks is an action. The response of all the actions should be a dictionary.

When a request reaches the server it will execute the particular action inside the handler. You can also send some additional data to your actions by passing it as a dict using data key in the request data. Remember a handler should always return a dict.

{
  "handler": "stock",
  "action": "get_stocks",
  "data": {
     "date": "04-5-2010"
   }
}

Will be updating more and adding more type of servers to serve the bot.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

-

Python Powered

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

iaBot-0.0.7.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

iaBot-0.0.7-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file iaBot-0.0.7.tar.gz.

File metadata

  • Download URL: iaBot-0.0.7.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

File hashes

Hashes for iaBot-0.0.7.tar.gz
Algorithm Hash digest
SHA256 de12763cdb9fff7f028d1713ab0a919a0b741615089986ad370c180c2bc375a8
MD5 cb3d7b452933a33fe4702a81d7013d79
BLAKE2b-256 1ca3615dd21dbf22423632e30f21288501fc259a6dc045e50b65416a1f14f24c

See more details on using hashes here.

File details

Details for the file iaBot-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: iaBot-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.6

File hashes

Hashes for iaBot-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 35e525d3716ca63d43fa286d1461514f5c870759663def093df831f764594ff7
MD5 ce68921f71eede5f4046d2bb42528ae6
BLAKE2b-256 f0d9fe71b755c7a3ab1f57c68c8d9aac2c56f8522fc24c6f1ef1aa4e49662631

See more details on using hashes here.

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