Speed telegram api libraly
Project description
bonfire
bonfire this framework for Telegram Bot API built on flask and requests
Ukrainian launge translate -> click
instaling
git clone https://github.com/Help-urself/bonfire
or
pip install -i https://test.pypi.org/simple/ bonfire-tg-libraly
pip install bonfire-tg-libraly
Examples
Click
1.install interceptor
- install ngrok and start the server according to the instructions on the website.
- set webhook
https://api.telegram.org/botTOKEN/setWebhook?url=you url ngrok/hosting url
Simple send_message
request
#git clone
import requests
from flask import Flask
import os
import sys
sys.path.append(os.path.abspath('you path to bonfire'))
from bonfiree.methods import *
from bonfiree.Bot import *
app = Flask(__name__)
token = "..."#token
@bot.handler
def start():
if msg.text == "/start":
send_message(token,chat_id=msg.chat_id,text=f"Hello {msg.author_username},is test bot")#send message
@commands(app)
def main():
global msg
msg=message(request.get_json())#message handler
start()#start function start
return Response('OK', status=200)#return status ok to cmd
if __name__ == '__main__':
run(app)
"""set-webhook - > https://api.telegram.org/botTOKEN/setWebhook?url=URL"""
#pip install
import requests
from flask import Flask
from bonfiree.methods import *
from bonfiree.Bot import *
app = Flask(__name__)
token = "..."#token
@bot.handler
def start():
if msg.text == "/start":
send_message(token,chat_id=msg.chat_id,text=f"Hello {msg.author_username},is test bot")#send message
@commands(app)
def main():
global msg
msg=message(request.get_json())#message handler
start()#start function start
return Response('OK', status=200)#return status ok to cmd
if __name__ == '__main__':
run(app)
"""set-webhook - > https://api.telegram.org/botTOKEN/setWebhook?url=URL"""
Documentation (in development)
Click
functions
send_message
def send_message(token,chat_id,text):
-token - keyword where you store the token
-chat_id - you can use your chat id or use the msg.chat_id method
-text -
your message text
-parse_mode( Optional ) - parse mode in HTML (optional)
example
msg=message(request.get_json())
#without parse_mode
send_message(token=bot,chat_id=msg.chat_id,text=f'hello :)')
#with parse_mode
send_message(token=bot,chat_id=msg.chat_id,text=f'<b>hello :)<b>',parse_mode='HTML') #make text bold
reply_message
def reply_message(token,chat_id,msg_id,text,parse_mode):
-token - keyword where you store the token
-chat_id - you can use your chat id or use the msg.chat_id method
-text - your message text
-msg_id - you can use your message id or use the msg.id method
-parse_mode( Optional ) - parse mode in HTML (optional)
example
msg=message(request.get_json())
#without parse_mode
reply_message(token,msg_id=msg.id,chat_id=msg.chat_id,text="reply message ._.")
#with parse_mode
reply_message(token,msg_id=msg.id,chat_id=msg.chat_id,text="<b>reply message is bold .-.</b>",parse_mode="HTML")#make text bold
send_sticker
def send_sticker(token,chat_id,sticker):
-token - keyword where you store the token
-chat_id - you can use your chat id or use the msg.chat_id method
-sticker -unique sticker key, you can get it from idstickerbot
example
send_sticker(token,chat_id=msg.chat_id,sticker="CAACAgIAAxkBAAEGdwNjd-IwPaLBzeqJW1DJvDLGnYOJpwACQBMAAvZDSUjqTxpxhtdlhisE")
delete_message
def delete_message(token,chat_id,msg_id):
-token - keyword where you store the token
-chat_id - you can use your chat id or use the msg.chat_id method
-msg_id - you can use your message id or use the msg.id method
example
delete_message(token,msg_id=msg.id,chat_id=msg.chat_id) #this code will only work in a private chat, so that it would work for the bot to have the right to delete messages or replace message_id with reply_message_id, you can find an example in the folder example->delete_message.py
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
Built Distribution
Hashes for bonfire_tg-1.0.7a0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1286b57390386e86781dd1360bf0c0022d2f136632cbdd633ff751090334f581 |
|
MD5 | 1188e25e63f01373dfc7f271bb27bcbd |
|
BLAKE2b-256 | 07131f8f42ee96250379d272083da3a5bb98db4a3a4db9a82a26fb68c6dd2f10 |