Skip to content

Commit

Permalink
Merge branch 'eternnoir:master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
EgorKhabarov authored Jul 10, 2024
2 parents 7364530 + f9f525b commit 3ea0fc1
Show file tree
Hide file tree
Showing 19 changed files with 2,509 additions and 544 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/setup_python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10']
python-version: [ '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy-3.9', 'pypy-3.10']
name: ${{ matrix.python-version }} and tests
steps:
- uses: actions/checkout@v2
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
<p align="center">Both synchronous and asynchronous.</p>

## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#march-31-2024">7.2</a>!
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#july-7-2024">7.7</a>!

<h2><a href='https://pytba.readthedocs.io/en/latest/index.html'>Official documentation</a></h2>
<h2><a href='https://pytba.readthedocs.io/ru/latest/index.html'>Official ru documentation</a></h2>
Expand Down Expand Up @@ -262,7 +262,7 @@ Handle shipping queries
`@bot.shipping_query_handler() # <- passes a ShippingQuery type object to your function`

#### Pre Checkout Query Handler
Handle pre checkoupt queries
Handle pre checkout queries
`@bot.pre_checkout_query_handler() # <- passes a PreCheckoutQuery type object to your function`

#### Poll Handler
Expand Down Expand Up @@ -303,7 +303,7 @@ def query_text(inline_query):

#### Chosen Inline handler

Use chosen_inline_handler to get chosen_inline_result in telebot. Don't forgot add the /setinlinefeedback
Use chosen_inline_handler to get chosen_inline_result in telebot. Don't forget to add the /setinlinefeedback
command for @Botfather.

More information : [collecting-feedback](https://core.telegram.org/bots/inline#collecting-feedback)
Expand Down Expand Up @@ -890,5 +890,6 @@ Here are some examples of template:
* [Best Instagram Downloader Bot](https://t.me/Best_Instagram_Downloader_Bot) ([source](https://github.com/arashnm80/best-instagram-downloader)) by [Arashnm80](https://github.com/arashnm80). Free and open source telegram bot to download posts and reels from Instagram.
* [4K YouTube Downloader](https://github.com/hansanaD/TelegramYTDLBot/) - Youtube Downloader with upto 4K resolution support.
* [DrinkGenius-Bot](https://t.me/cocktail_recommendation_bot) ([source](https://github.com/Povladarchik/DrinkGenius-Bot)) by [Povladarchik](https://github.com/Povladarchik). Your personal assistant in the world of cocktails.
* [Pytgpt-Bot](https://t.me/pytgpt_bot) ([source](https://github.com/Simatwa/pytgpt-bot)) by [Smartwa](https://github.com/Simatwa). AI powered bot for chatting, text-to-image and text-to-speech conversions.

**Want to have your bot listed here? Just make a pull request. Only bots with public source code are accepted.**
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
copyright = f'2022-{datetime.now().year}, {author}'

# The full version, including alpha/beta/rc tags
release = '4.17.0'
release = '4.21.0'


# -- General configuration ---------------------------------------------------
Expand Down
10 changes: 4 additions & 6 deletions examples/asynchronous_telebot/echo_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@

# This is a simple echo bot using the decorator mechanism.
# It echoes any incoming text messages.
import asyncio

from telebot.async_telebot import AsyncTeleBot
bot = AsyncTeleBot('TOKEN')

bot = AsyncTeleBot('TOKEN')


# Handle '/start' and '/help'
@bot.message_handler(commands=['help', 'start'])
async def send_welcome(message):
await bot.reply_to(message, """\
Hi there, I am EchoBot.
I am here to echo your kind words back to you. Just say anything nice and I'll say the exact same thing to you!\
""")
text = 'Hi, I am EchoBot.\nJust write me something and I will repeat it!'
await bot.reply_to(message, text)


# Handle all other messages with content_type 'text' (content_types defaults to ['text'])
Expand All @@ -23,5 +22,4 @@ async def echo_message(message):
await bot.reply_to(message, message.text)


import asyncio
asyncio.run(bot.polling())
1 change: 1 addition & 0 deletions examples/serverless/flask_google_cloud_bot/.gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
env/
4 changes: 4 additions & 0 deletions examples/serverless/flask_google_cloud_bot/app.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
runtime: python38

env_variables:
BUCKET_NAME: "your-google-application"
65 changes: 65 additions & 0 deletions examples/serverless/flask_google_cloud_bot/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
'''
Simple bot for Google cloud deployment.
Docs:
https://cloud.google.com/run/docs/quickstarts/build-and-deploy/deploy-python-service
1. Receive your bot's token from https://t.me/BotFather
2. Create a Google Cloud project. https://cloud.google.com/resource-manager/docs/creating-managing-projects
3. Install the Google Cloud CLI. https://cloud.google.com/sdk/docs/install
4. Move to telegram_google_cloud_bot folder
cd telegram_google_cloud_bot/
5. Initialize the gcloud CLI:
gcloud init
6. To set the default project for your Cloud Run service:
gcloud config set project PROJECT_ID
7. Deploy:
gcloud run deploy
'''

import os

from flask import Flask, request

import telebot

TOKEN = 'token_from_botfather'

bot = telebot.TeleBot(TOKEN)

app = Flask(__name__)


@bot.message_handler(commands=['start'])
def start(message):
bot.reply_to(message, 'Hello, ' + message.from_user.first_name)


@bot.message_handler(func=lambda message: True, content_types=['text'])
def echo_message(message):
bot.reply_to(message, message.text)


@app.route('/' + TOKEN, methods=['POST'])
def getMessage():
json_string = request.get_data().decode('utf-8')
update = telebot.types.Update.de_json(json_string)
bot.process_new_updates([update])
return '!', 200


@app.route('/')
def webhook():
bot.remove_webhook()
bot.set_webhook(url='https://mydomain.com/' + TOKEN)
return '!', 200
4 changes: 4 additions & 0 deletions examples/serverless/flask_google_cloud_bot/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pyTelegramBotAPI==4.11.0
Flask==3.0.0
gunicorn==22.0.0
Werkzeug==3.0.3
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "pyTelegramBotAPI"
version = "4.17.0"
version = "4.21.0"
description = "Python Telegram bot api."
authors = [{name = "eternnoir", email = "[email protected]"}]
license = {text = "GPL2"}
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pytest
requests==2.31.0
requests==2.32.0
wheel==0.38.1
aiohttp==3.9.4
Loading

0 comments on commit 3ea0fc1

Please sign in to comment.