先登录https://my.telegram.org/auth,选择API development tools
记下自己的api_id和api_hash
Yaodo·2023-04-21·342 次阅读
先登录https://my.telegram.org/auth,选择API development tools
记下自己的api_id和api_hash
我用Python写的一个小程序,用jupyter notebook一步一步写的,没有封装
from telethon import TelegramClient, events, utils import ddddocr import os # 使用ddddocr识别图片验证码 def ocr(path): model = ddddocr.DdddOcr(show_ad=False) with open(path, 'rb') as f: image = f.read() return model.classification(image) # 填入自己的api_id和api_hash api_id = ******* api_hash = '***********************************' # 自己取个名字,我这里填的是AutoCheckin client = TelegramClient('AutoCheckIn', api_id, api_hash) # 登录 await client.start() # 厂妹签到逻辑 @client.on(events.NewMessage(chats=1429576125)) async def handler(event): if ('已经' in event.message.text) or ('签到成功' in event.message.text): chat_name = utils.get_display_name(await client.get_entity(1429576125)) print('{}:\n{}'.format(chat_name,event.message.text)) elif '输入签到验证码' in event.message.text: path = await event.message.download_media() await client.send_message(1429576125, ocr(path)) os.remove(path) elif '无需清理' in event.message.text: pass else: await client.send_message(1429576125, '/cancel') # 获取对话列表 await client.get_dialogs() # 开始签到 await client.send_message(1429576125, '/checkin')
效果:
Comments | NOTHING