api_motto   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A Motto.main() 0 11 2
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