Update app.py
Browse files
app.py
CHANGED
|
@@ -1,16 +1,35 @@
|
|
| 1 |
-
|
| 2 |
-
!pip install numpy==1.19.3
|
| 3 |
-
!pip install pandas==1.1.3
|
| 4 |
|
|
|
|
|
|
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
@bot.message_handler(commands=['start'])
|
| 13 |
-
def welcome_message(message):
|
| 14 |
-
bot.reply_to(message, "مرحباً بك في البوت!")
|
| 15 |
-
|
| 16 |
-
bot.polling()
|
|
|
|
| 1 |
+
import requests
|
|
|
|
|
|
|
| 2 |
|
| 3 |
+
# Replace 'YOUR_BOT_TOKEN' with your actual bot token
|
| 4 |
+
bot_token = '6990801595:AAE79xNVO1D_0SeWZlzYLE57Suwfp9GyKT8'
|
| 5 |
|
| 6 |
+
def send_message(chat_id, text):
|
| 7 |
+
url = f'https://api.telegram.org/bot{bot_token}/sendMessage'
|
| 8 |
+
params = {'chat_id': chat_id, 'text': text}
|
| 9 |
+
response = requests.get(url, params=params)
|
| 10 |
+
return response.json()
|
| 11 |
|
| 12 |
+
def handle_message(message):
|
| 13 |
+
chat_id = message['chat']['id']
|
| 14 |
+
text = message['text']
|
| 15 |
+
|
| 16 |
+
if text == '/start':
|
| 17 |
+
send_message(chat_id, 'Hi')
|
| 18 |
+
|
| 19 |
+
def main():
|
| 20 |
+
offset = None
|
| 21 |
+
|
| 22 |
+
while True:
|
| 23 |
+
url = f'https://api.telegram.org/bot{bot_token}/getUpdates'
|
| 24 |
+
params = {'offset': offset}
|
| 25 |
+
response = requests.get(url, params=params)
|
| 26 |
+
data = response.json()
|
| 27 |
+
|
| 28 |
+
if data['ok']:
|
| 29 |
+
for update in data['result']:
|
| 30 |
+
offset = update['update_id'] + 1
|
| 31 |
+
if 'message' in update:
|
| 32 |
+
handle_message(update['message'])
|
| 33 |
|
| 34 |
+
if __name__ == '__main__':
|
| 35 |
+
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|