-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'eternnoir:master' into develop
- Loading branch information
Showing
19 changed files
with
2,509 additions
and
544 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
env/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
runtime: python38 | ||
|
||
env_variables: | ||
BUCKET_NAME: "your-google-application" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.