[Python] 纯文本查看 复制代码 import requests
import time
# Telegram Bot的API Token
telegram_api_token = "你的TG_bot token"
# Telegram目标聊天ID(可以是私人对话或群组ID)
telegram_chat_id = "你的chat_id"
def send_message_to_telegram(message):
url = f"https://api.telegram.org/bot{telegram_api_token}/sendMessage"
data = {
"chat_id": telegram_chat_id,
"text": message,
}
requests.post(url, data=data)
def aliyun_drive_sign_in(refresh_tokens):
for refresh_token in refresh_tokens:
if refresh_token != "":
# 刷新token获取access_token
res = requests.post("https://auth.aliyundrive.com/v2/account/token",
json={
"grant_type": "refresh_token",
"refresh_token": refresh_token
})
res = res.json()
access_token = res.get('access_token')
if access_token is None:
send_message_to_telegram("refresh_token错误,请重新填写refresh_token")
else:
try:
# 进行签到
res2 = requests.post("https://member.aliyundrive.com/v1/activity/sign_in_list",
json={"_rx-s": "mobile"},
headers={"Authorization": 'Bearer ' + access_token})
res2 = res2.json()
signInCount = res2.get('result', {}).get('signInCount', 0)
# 领取奖励
res3 = requests.post("https://member.aliyundrive.com/v1/activity/sign_in_reward?_rx-s=mobile",
json={
"signInDay": signInCount
},
headers={"Authorization": 'Bearer ' + access_token})
res3 = res3.json()
reward_name = res3.get("result", {}).get("name")
reward_description = res3.get("result", {}).get("description")
# 构建签到成功和获得奖励的信息
message = f"账号:{res['user_name']},签到成功,本月累计签到{signInCount}天,获得奖励:{reward_name},{reward_description}"
send_message_to_telegram(message)
except:
send_message_to_telegram("签到或领取奖励失败")
print("\n")
# 多账号refresh_token值列表
refresh_tokens = ["token1", "token2", "token3"]
aliyun_drive_sign_in(refresh_tokens) |