api_motto.Motto.main()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
# -*- coding: utf-8 -*-
2
"""
3
cron: 30 7 * * *
4
new Env('每日一句');
5
"""
6
7
import requests
8
9
from notify_mtr import send
10
from utils import get_data
11
12
13
class Motto:
14
    @staticmethod
15
    def main():
16
        """从词霸中获取每日一句,带英文
17
18
        :return: str
19
        """
20
        response = requests.get("http://open.iciba.com/dsapi")
21
        if response.status_code != 200:
22
            return ""
23
        res = response.json()
24
        return f'{res["content"]}\n{res["note"]}\n'
25
26
27
if __name__ == "__main__":
28
    _data = get_data()
29
    motto = _data.get("MOTTO")
30
    if motto:
31
        result = Motto().main()
32
        send("每日一句", result)
33