bnotify
Bnotify is an open source Python telegram bots notifications module designed for humans. It
allows to provide regular notifications to your telegram bot. Bnotify offers native support for MongoDB.
How to install
python3 setup.py install --user
Bnotify is Simple
from bnotify import BotNotifier, Message
def send_hi():
yield Message(
text="Hi",
chat_id=0000000
)
app = BotNotifier()
app.tasks += (send_hi, 100, "TELEGRAM_TOKEN")
app.run()
Tasks are now alive and ready to send messages.
To make notifications more functional, you can connect to your API or database to retrieve users information.
Make sure that the way you use data storages is thread-safe.
Bnotify comes with native thread-safe support for mongodb:
from bnotify import BotNotifier, Message
from mongo import MongoClient
def send_hi(db: MongoClient):
for user in db.user.find({}, {"chat_id":1}):
yield Message(
text="Hi",
chat_id=user["chat_id"]
)
app = BotNotifier(
mongo_url="mongodb://localhost:27017",
db_name="sample_db"
)
app.tasks += (send_hi, 100, "TELEGRAM_TOKEN")
app.run()
Features
- Parallel tasks
- Enhanced Logging
- Operations Log
- MongoDB Support
License
Bnotify is a Stepan Starovoitov open source project,
distributed under the BSD license.