ck_wzyd   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 36
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A WZYD.__init__() 0 2 1
A WZYD.sign() 0 10 3
A WZYD.main() 0 13 3
1
# -*- coding: utf-8 -*-
2
"""
3
cron: 00 8 * * *
4
new Env('王者营地');
5
"""
6
7
from urllib.parse import parse_qsl
8
9
import requests
10
11
from notify_mtr import send
12
from utils import get_data
13
14
15
class WZYD:
16
    def __init__(self, check_items):
17
        self.check_items = check_items
18
19
    @staticmethod
20
    def sign(data):
21
        res = requests.post(
22
            url="https://ssl.kohsocialapp.qq.com:10001/play/h5sign", data=data
23
        ).json()
24
        try:
25
            msg = "签到成功" if res["result"] == 0 else res["returnMsg"]
26
        except Exception:
27
            msg = "请求失败,请检查接口"
28
        return msg
29
30
    def main(self):
31
        msg_all = ""
32
        for check_item in self.check_items:
33
            data = dict(parse_qsl(check_item.get("data")))
34
            try:
35
                user_id = data.get("userId", "")
36
            except Exception as e:
37
                print(f"获取用户信息失败: {e}")
38
                user_id = "未获取到用户信息"
39
            sign_msg = self.sign(data)
40
            msg = f"帐号信息: {user_id}\n签到信息: {sign_msg}"
41
            msg_all += msg + "\n\n"
42
        return msg_all
43
44
45
if __name__ == "__main__":
46
    _data = get_data()
47
    _check_items = _data.get("WZYD", [])
48
    result = WZYD(check_items=_check_items).main()
49
    send("王者营地", result)
50