iaBot
iaBot is a Python library for creating simple bots and serving it with the different ways available.
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.
-
Metadata
Release files for iaBot 0.0.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| iaBot-0.0.7.tar.gz | 4.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| iaBot-0.0.7-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.6 kB
Release files / iaBot-0.0.7.tar.gz
| Download URL | iaBot-0.0.7.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de12763cdb9fff7f028d1713ab0a919a0b741615089986ad370c180c2bc375a8
|
|
BLAKE2b-256 checksum How to use checksums |
1ca3615dd21dbf22423632e30f21288501fc259a6dc045e50b65416a1f14f24c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|
Release files / iaBot-0.0.7-py3-none-any.whl
| Download URL | iaBot-0.0.7-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
35e525d3716ca63d43fa286d1461514f5c870759663def093df831f764594ff7
|
|
BLAKE2b-256 checksum How to use checksums |
f0d9fe71b755c7a3ab1f57c68c8d9aac2c56f8522fc24c6f1ef1aa4e49662631
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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
|