Update app.py
Browse files
app.py
CHANGED
@@ -12,9 +12,6 @@ import globs
|
|
12 |
from flask import render_template
|
13 |
from api_logic import api
|
14 |
|
15 |
-
import telegram
|
16 |
-
from telebot.credentials import bot_token, bot_user_name,URL
|
17 |
-
from telebot.mastermind import get_response
|
18 |
|
19 |
|
20 |
load_dotenv()
|
@@ -102,40 +99,7 @@ app.config['DEBUG'] = True
|
|
102 |
|
103 |
|
104 |
|
105 |
-
# Прямо здесь передаем данные
|
106 |
-
bot_token = 'YOUR_BOT_TOKEN'
|
107 |
-
bot_user_name = 'YOUR_BOT_USER_NAME'
|
108 |
-
URL = 'YOUR_WEBHOOK_URL'
|
109 |
|
110 |
-
bot = telegram.Bot(token=bot_token)
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
@app.route('/{}'.format(bot_token), methods=['POST'])
|
115 |
-
def respond():
|
116 |
-
update = telegram.Update.de_json(request.get_json(force=True), bot)
|
117 |
-
|
118 |
-
chat_id = update.message.chat.id
|
119 |
-
msg_id = update.message.message_id
|
120 |
-
|
121 |
-
text = update.message.text.encode('utf-8').decode()
|
122 |
-
|
123 |
-
response = 'Your response' # Замени на свою логику для ответа
|
124 |
-
bot.sendMessage(chat_id=chat_id, text=response, reply_to_message_id=msg_id)
|
125 |
-
|
126 |
-
return 'ok'
|
127 |
-
|
128 |
-
@app.route('/set_webhook', methods=['GET', 'POST'])
|
129 |
-
def set_webhook():
|
130 |
-
s = bot.setWebhook('{URL}{HOOK}'.format(URL=URL, HOOK=bot_token))
|
131 |
-
if s:
|
132 |
-
return "webhook setup ok"
|
133 |
-
else:
|
134 |
-
return "webhook setup failed"
|
135 |
-
|
136 |
-
@app.route('/')
|
137 |
-
def index():
|
138 |
-
return '.'
|
139 |
|
140 |
|
141 |
|
|
|
12 |
from flask import render_template
|
13 |
from api_logic import api
|
14 |
|
|
|
|
|
|
|
15 |
|
16 |
|
17 |
load_dotenv()
|
|
|
99 |
|
100 |
|
101 |
|
|
|
|
|
|
|
|
|
102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
|
105 |
|