Spaces:
Runtime error
Runtime error
aheskandani
commited on
Commit
•
352eac8
1
Parent(s):
ba887e5
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from telegram.ext.filters import Filters
|
2 |
+
from telegram.ext.messagehandler import MessageHandler
|
3 |
+
from telegram import Update, ParseMode
|
4 |
+
from telegram.ext import (Updater,
|
5 |
+
PicklePersistence,
|
6 |
+
CommandHandler,
|
7 |
+
CallbackQueryHandler,
|
8 |
+
CallbackContext,
|
9 |
+
ConversationHandler)
|
10 |
+
from telegram import InlineKeyboardButton, InlineKeyboardMarkup, ForceReply, ReplyKeyboardMarkup
|
11 |
+
import urllib.request
|
12 |
+
from bs4 import BeautifulSoup
|
13 |
+
|
14 |
+
bot_token = '5415345086:AAFYZJfXygvUzfQARjoADv5eBtcB8qIWp9M'
|
15 |
+
admin = 37087739
|
16 |
+
|
17 |
+
def start(update: Update, context: CallbackContext):
|
18 |
+
text = ('Hello!')
|
19 |
+
update.message.reply_text(text)
|
20 |
+
|
21 |
+
def send_captcha(update: Update, context: CallbackContext):
|
22 |
+
''' Entry point of conversation this gives buttons to user'''
|
23 |
+
chat_id = update.effective_chat.id
|
24 |
+
url =https://pooya.um.ac.ir/gateway/SecurityImage/ShowSecurityImage.php?rand=1485178863&rand2=S3VNRFk3Q1h3dHFNQTlURVN4R0IvSE8zYUpPTlN4RzljYmxNdWg2WWpqOD0=0='
|
25 |
+
urllib.request.urlretrieve(url, 'captcha.png')
|
26 |
+
print('Downloaded!')
|
27 |
+
context.bot.send_photo(chat_id, photo=open('captcha.png', 'rb'))
|
28 |
+
|
29 |
+
if __name__ == '__main__':
|
30 |
+
updater = Updater(token=bot_token)
|
31 |
+
updater.dispatcher.add_handler(CommandHandler('start', start))
|
32 |
+
updater.dispatcher.add_handler(CommandHandler('img', send_captcha))
|
33 |
+
updater.start_polling()
|
34 |
+
print('Bot started ..........')
|
35 |
+
updater.idle()
|