-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.py
53 lines (35 loc) · 1.18 KB
/
index.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
from tieba import Tieba
from config import config
from push import PushSender, parse
def parse_message(message, push_type):
if push_type == "pushplus":
return parse(message, template="html")
else:
return parse(message, template="markdown")
def pushMessage(message, config):
if isinstance(config, list):
for item in config:
t = item.get("type")
p = PushSender(t, item.get("key"))
p.send(parse_message(message, t), title="贴吧签到")
else:
t = config.get("type")
p = PushSender(config.get("type"), config.get("key"))
p.send(parse_message(message, t), title="贴吧签到")
def main(*args):
accounts = config.get("multi")
push_together = config.get("push")
messages = []
for item in accounts:
obj = Tieba(**item)
res = obj.start()
push = item.get("push")
if push is None:
if push_together is not None:
messages.extend(res)
else:
pushMessage(res, push)
if len(messages) != 0 and push_together is not None:
pushMessage(messages, push_together)
if __name__ == "__main__":
main()