Passed
Push — master ( c3bfdf...75ad6c )
by Leon
02:21
created

ck_ccava.DuoKan.main()   A

Complexity

Conditions 2

Size

Total Lines 7
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
"""
3
cron: 55 18 * * *
4
new Env('CCAVA');
5
"""
6
7
import requests
8
9
from notify_mtr import send
10
from utils import get_data
11
12
13
class CCAVA:
14
    def __init__(self, check_items):
15
        self.check_items = check_items
16
17
    def sign(self, cookie):
18
        url = "https://pc.ccava.net/zb_users/plugin/mochu_us/cmd.php?act=qiandao"
19
        res = requests.get(url, headers={"Cookie": cookie})
20
        data = res.json()
21
        if "登录" in data["msg"]:
22
            msg = "cookie 失效"
23
        elif "今天" in data["msg"]:
24
            msg = f'重复签到, 剩余 {data["giod"]} 月光币'
25
        else:
26
            msg = f'签到成功, 剩余 {data["giod"]} 月光币'
27
        return msg
28
29
    def main(self):
30
        msg_all = ""
31
        for check_item in self.check_items:
32
            cookie = check_item.get("cookie")
33
            msg = self.sign(cookie)
34
            msg_all += msg + "\n\n"
35
        return msg_all
36
37
38
if __name__ == "__main__":
39
    data = get_data()
40
    _check_items = data.get("CCAVA", [])
41
    res = CCAVA(check_items=_check_items).main()
42
    send("CCAVA", res)
43