-
Notifications
You must be signed in to change notification settings - Fork 12
/
pic_inline_check.py
43 lines (36 loc) · 1.46 KB
/
pic_inline_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
import os
import time
from telethon import TelegramClient, events, sync
import tg_code
def tg_qd(tg_bot,tg_command):
client.send_message(tg_bot, tg_command) # 第一项是机器人ID,第二项是发送的文字
time.sleep(2) # 延时5秒,等待机器人回应(一般是秒回应,但也有发生阻塞的可能)
messages = client.get_messages(tg_bot)
time.sleep(2)
messages[0].download_media(file="1.jpg")#下载验证码图片
time.sleep(2)
the_code = tg_code.truecaptcha()
res = messages[0].click(text=the_code)#点击返回验证码
time.sleep(1)
if str(res) == "None":#如果不存在这个验证码,就点第一个
messages[0].click(0)
time.sleep(5)
messages = client.get_messages(tg_bot)
return messages[0].message
api_id = [0123456, 6543210] #输入api_id,一个账号一项
api_hash = ['0123456789abcdef0123456789abcdef', 'abcdef0123456789abcdef0123456789'] #输入api_hash,一个账号一项
session_name = api_id[:]
bots_commands=["@JMSIPTV_bot","/checkin","成功"]
for num in range(len(api_id)):
session_name[num] = "id_" + str(session_name[num])
client = TelegramClient(session_name[num], api_id[num], api_hash[num])
client.start()
the_result=tg_qd(bots_commands[0],bots_commands[1])
i=0
while bots_commands[2] not in the_result:
i+=1
the_result=tg_qd(bots_commands[0],bots_commands[1])
if i > 5:#最多循环次数
break
os._exit(0)