-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathaction.py
More file actions
27 lines (21 loc) · 750 Bytes
/
action.py
File metadata and controls
27 lines (21 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# -*- coding:utf-8 -*-
import requests
# 注意:参数为固定参数
def act_weather(model, output_str, raw_input):
#TODO: Get weather by api
page = requests.get("http://wthrcdn.etouch.cn/weather_mini?city=重庆")
data = page.json()
temperature = data['data']['wendu']
notice = data['data']['ganmao']
outstrs = "地点: %s\n气温: %s\n注意: %s" % ("重庆", temperature.encode("utf-8"), notice.encode("utf-8"))
return outstrs
actions = {
"__Weather__":act_weather
}
def check_action(func):
def wrapper(*args, **kwargs):
for i in actions.keys():
if i in args[1]:
return actions.get(i)(*args, **kwargs)
return func(*args, **kwargs)
return wrapper