Ampalibe is a light open source framework.
Project description
Ampalibe
Ampalibe is a light Python framework for quickly creating bots Facebook Messenger.
It provides a new concept for creating bots, it manages webhook sides, processes data sent by facebook and provides api messengers with advanced functions ( payload management. items length, ...) .
Installation
pip install ampalibe
OR you can install dev version
pip install https://github.com/iTeam-S/Ampalibe/archive/refs/heads/main.zip
Dependencies:
Usage
ampalibe create myproject
OR
$ cd myproject
$ ampalibe init
to run project, just use
ampalibe run
Documentation
About
Ampalibe is a word of Malagasy 🇲🇬 origin designating the fruit jackfruit.
We have made a promise to
- keep it light
- make it easy to use
- do it quickly to develop
Why use Ampalibe ?
- No need to manage weebhooks and data:
messages are received directly in a main function
import ampalibe
from conf import Configuration
bot = ampalibe.init(Configuration())
chat = bot.chat
@ampalibe.command('/')
def main(sender_id, cmd, **extends):
chat.send_message(sender_id, 'Hello world')
chat.send_message(senser_id, f'This is your message: {cmd}')
chat.send_message(senser_id, f'and this is your facebook id: {sender_id}')
- Manages the actions expected by the users:
define the function of the next treatment
import ampalibe
from conf import Configuration
bot = ampalibe.init(Configuration())
chat = bot.chat
query = bot.query
@ampalibe.command('/')
def main(sender_id, cmd, **extends):
chat.send_message(sender_id, 'Enter your name')
query.set_action(sender_id, '/get_name')
@ampalibe.action('/get_name')
def get_name(sender_id, cmd, **extends):
query.set_action(sender_id, None) # clear current action
chat.send_message(sender_id, f'Hello {cmd}')
- Manage temporary data:
set, get, and delete
import ampalibe
from conf import Configuration
bot = ampalibe.init(Configuration())
chat = bot.chat
query = bot.query
@ampalibe.command('/')
def main(sender_id, cmd, **extends):
chat.send_message(sender_id, 'Enter your mail')
query.set_action(sender_id, '/get_mail')
@ampalibe.action('/get_mail')
def get_mail(sender_id, cmd, **extends):
# save the mail in temporary data
query.set_temp(sender_id, 'mail', cmd)
chat.send_message(sender_id, f'Enter your password')
query.set_action(sender_id, '/get_password')
@ampalibe.action('/get_password')
def get_password(sender_id, cmd, **extends):
query.set_action(sender_id, None) # clear current action
mail = query.get_temp(sender_id, 'mail') # get mail in temporary data
chat.send_message(sender_id, f'your mail and your password are {mail} {cmd}')
query.del_temp(sender_id, 'mail') # delete temporary data
- Manage Payload:
send data with Payload object and get it in destination function's parameter
import ampalibe
from ampalibe import Payload
from conf import Configuration
bot = ampalibe.init(Configuration())
chat = bot.chat
@ampalibe.command('/')
def main(sender_id, cmd, **extends):
quick_rep = [
{
"content_type": "text",
"title": 'Angela',
"payload": Payload('/membre', name='Angela', ref='2016-sac')
},
{
"content_type": "text",
"title": 'Rivo',
"payload": Payload('/membre', name='Rivo')
}
]
chat.send_quick_reply(sender_id, quick_rep, 'Who?')
@ampalibe.command('/membre')
def get_membre(sender_id, cmd, name, **extends):
chat.send_message(sender_id, "Hello " + name)
# if the arg is not defined in the list of parameters,
# it is put in the extends variable
if extends.get('ref'):
chat.send_message(sender_id, 'your ref is ' + extends.get('ref'))
- No need to manage the length of the items to send:
A next page button will be displayed directly
import ampalibe
from ampalibe import Payload
from conf import Configuration
bot = ampalibe.init(Configuration())
chat = bot.chat
@ampalibe.command('/')
def main(sender_id, cmd, **extends):
list_items = [
{
"title": f"item n°{i+1}",
"image_url": "https://i.imgflip.com/6b45bi.jpg",
"buttons": [
{
"type": "postback",
"title": "Get item",
"payload": Payload("/item", id_item=i+1)
}
]
}
for i in range(30)
]
# next=True for displaying directly next page button.
chat.send_template(sender_id, list_items, next=True)
@ampalibe.command('/item')
def get_item(sender_id, id_item):
chat.send_message(sender_id, f"item n°{id_item} selected")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
ampalibe-1.0.1.tar.gz
(15.3 kB
view details)
Built Distributions
ampalibe-1.0.1-py3.9.egg
(26.5 kB
view details)
ampalibe-1.0.1-py3-none-any.whl
(14.8 kB
view details)
File details
Details for the file ampalibe-1.0.1.tar.gz
.
File metadata
- Download URL: ampalibe-1.0.1.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93529ca7b32c97e4f862bf06b9eb3fb1a5fdf37d448f43e27626dbe5197c5f98 |
|
MD5 | ae2c58cfa9e7ff74b0b17c398cd91c4a |
|
BLAKE2b-256 | 64031f79ee8ec4d088badd7f979be7670a8036f4990df86408bec2e653da3ce7 |
Provenance
File details
Details for the file ampalibe-1.0.1-py3.9.egg
.
File metadata
- Download URL: ampalibe-1.0.1-py3.9.egg
- Upload date:
- Size: 26.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b207bc3a5fc6bd9b872984c2688f2dbe2b3fe3636f28a049eee2015fbdf63df1 |
|
MD5 | e36b8b6fcca49eb65c20f26572019bd2 |
|
BLAKE2b-256 | 630a6af5f395d5adfbbb6ede78dfc71eb7b387a5bf86b086e622df7c0ecc0e7e |
Provenance
File details
Details for the file ampalibe-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: ampalibe-1.0.1-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60241bfe2f3c873c609970959e367833c34fe64e428d863aabb118e097daf72e |
|
MD5 | 734eb7a090dfc6a013cd4f5223d25e39 |
|
BLAKE2b-256 | 15eb70ca2b265fe437fed6a33145df4304df81227fe9b75d046559ba85f3167b |