This repository has been archived by the owner on Feb 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 29
/
task.py
88 lines (84 loc) · 2.71 KB
/
task.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import logging
from api import WeiBo
def run():
logging.getLogger().setLevel(logging.INFO)
logging.basicConfig(format="[%(levelname)s]; %(message)s")
log = []
cookie = input()
s = input()
pick = input()
sckey = input()
wb = WeiBo(cookie)
user = wb.get_profile()
log.append("#### 💫User:")
if not user['status']:
logging.warning(user['errmsg'])
return
logging.info("获取个人信息成功✔")
topic_list = wb.get_topic_list()
log.append("```")
log.append(user["user"]["user_msg"])
log.append("```")
logging.info("开始超话签到")
log.append("#### ✨CheckIn:")
log.append("```")
for topic in topic_list:
check_dict = wb.check_in(s, topic)
if check_dict["status"]:
log.append(check_dict["msg"])
logging.info(check_dict)
else:
log.append(check_dict["errmsg"])
logging.warning(check_dict["errmsg"])
break
log.append("```")
logging.info("获取每日积分")
log.append("#### 🔰DailyScore:")
log.append("```")
daily_res = wb.get_daily_score()
if daily_res['status']:
log.append(daily_res['msg'])
logging.info(daily_res['msg'])
else:
log.append(daily_res['msg'])
logging.warning(daily_res['msg'])
log.append("```")
logging.info("超话评论转发(正在执行,需要一点时间......)")
log.append("#### ✅Post:")
log.append("```")
repost = wb.repost_comment(topic_list[-1])
logging.info(repost)
log.append(repost)
log.append("```")
logging.info("指定超话打榜")
log.append("#### 💓Pick:")
log.append("```")
picks = [topic for topic in topic_list if topic["topic_title"] == pick]
if not picks:
errmsg = f"未关注【{pick}】该超话,请检查超话名字是否正确"
logging.warning(errmsg)
log.append(errmsg)
return
pick_res = wb.pick_topic(picks[0], "select66")
if pick_res['status']:
log.append(pick_res['result']['msg'])
logging.info(pick_res['result']['msg'])
else:
log.append(pick_res['errmsg'])
logging.warning(pick_res['errmsg'])
log.append("```")
logging.info("查询任务中心")
log.append("#### 🌈TaskCenter:")
log.append("```")
task_dict = wb.task_center()
if task_dict['status']:
log.append(task_dict['task_dict']['msg'])
logging.info(task_dict['task_dict']['msg'])
else:
log.append(task_dict['task_res.text'])
logging.info(task_dict['task_res.text'])
log.append("```")
print("\n".join(log))
wb.server_push(sckey, "\n".join(log))
if __name__ == '__main__':
run()