Simple framework for building Instagram chat bots with menu driven interface
Project description
instachatbot
Simple framework for building Instagram chat bots with menu driven interface
Installation
pip3 install instachatbot
To install development version:
pip3 install git+https://github.com/art-vasilyev/instachatbot.git
How to use
Create sample script main.py
:
from instachatbot.bot import InstagramChatBot
from instachatbot.nodes import (
MenuNode, MenuItem, MessageNode, QuestionnaireNode, NotifyAdminNode)
menu = MenuNode(
'💡Choose menu:\n',
[
MenuItem(
'text message',
MessageNode('This is a message😀')),
MenuItem(
'questionnaire',
QuestionnaireNode(
[
'What is your favourite book? 📚',
'What is your favourite fruit? 🍐 🍊 🍋'
],
header='Please answer the following questions',
admin_username='<user to send results to>',
response='Thank your for your answers')),
MenuItem(
'send notification to admin',
NotifyAdminNode(
'Thank you',
notification='Sample notification from bot user',
admin_username='<username to send notification to>'
)
),
],
error_message='Failed to select menu.'
)
chatbot = InstagramChatBot(menu=menu)
chatbot.login(
username='<instagram-username>',
password='<instagram-password>')
chatbot.start()
Run the script:
python3 main.py
Persistent conversation state
By default conversation state is discarded on bot restart, to make it persistent you should provide persistent storage on bot initialization:
chatbot = InstagramChatBot(menu=menu, storage=FileStorage())
Menu triggers
By default a bot sends the menu on any message it receives. If you want menu to appear only if bot receives special message, set trigger
argument on bot initialization:
chatbot = InstagramChatBot(menu=menu, trigger='/menu')
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
instachatbot-0.4.tar.gz
(6.0 kB
view hashes)
Built Distribution
Close
Hashes for instachatbot-0.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bfc6ca6eeaf75f24e00156792a04d55c39a472accbd36f6c6efc89880ea3b50 |
|
MD5 | aa101d2b2250eeaacd7a659d8cfc3c9f |
|
BLAKE2b-256 | 0dae95e1c53387df77058796699a671ea5b204d7d52ef32d5d07f78e77a91557 |