老婆醬(聊天機(jī)器人),來自大神編寫的一個Python代碼,代號“老婆醬”,會稱呼你為老公,并且還會以甜蜜的語氣向你問好,可以根據(jù)需求給她更換不同的頭像,小編試了下,還挺萌的,推薦給大家使用。
老婆醬功能簡介
AI智能回復(fù)助手
有求必應(yīng),有問必答
每天必有的早安和晨報功能
老婆醬軟件說明
Python代碼,需要專業(yè)編譯器編譯后安裝到QQ上使用
代碼一覽
# -*- coding: utf-8 -*-
import requests
def post_data(data):
qmsg_url = 'https://qmsg.zendee.cn/send/key' #填你的key
res = requests.post(qmsg_url, data=data).json()
print(res['reason'])
def morning():
url = 'http://api.tianapi.com/txapi/zaoan/index?key=a161e1569f43507da7fe5396f6956fe1'
res = requests.get(url).json()
content = res['newslist'][0]['content']
data = {
'msg': "早上好呀,老公大人@face=2@@face=49@@face=109@\n%s@face=175@" % content
}
post_data(data)
def weather(code):
url = 'http://t.weather.itboy.net/api/weather/city/%d' % code
res = requests.get(url, headers=headers).json()
city = res['cityInfo']['city'] # 地區(qū)
forecast = res['data']['forecast'] # 具體天氣
quality = res['data']['quality']
pm25 = res['data']['pm25']
pm10 = res['data']['pm10']
ganmao = res['data']['ganmao'] # ganmao: "各類人群可自由活動"
shidu = res['data']['shidu']
wendu = res['data']['wendu'] + '℃'
for lmaki_data, lmaki in zip(forecast, ['今天', '明天']):
ymd = lmaki_data['ymd'] # 時間
week = lmaki_data['week'] # 星期幾
sunrise = lmaki_data['sunrise'] # 日出
sunset = lmaki_data['sunset'] # 日落
high = lmaki_data['high'] # 最高溫
low = lmaki_data['low'] # 最低溫
fx = lmaki_data['fx'] # 風(fēng)向
fl = lmaki_data['fl'] # 幾級風(fēng)
type_we = lmaki_data['type'] # 天氣
notice = lmaki_data['notice'] # 提示語
total = f'@face=6@{lmaki}是{week},天氣是 {type_we} 哦,溫度為{wendu},濕度為{shidu}\npm2.5的值為{pm25},pm1.0的值是{pm10},{ganmao}\n{high},{low},{notice},吹的是{fx},風(fēng)速達(dá)到了{(lán)fl}了。\n太陽將在 {sunrise} 升起,{sunset} 落下\n天氣質(zhì)量為 {quality}@face=13@ {ymd} {city}'
data = {
'msg': total
}
post_data(data)
def main():
morning()
weather(101210805) #城市代碼
if __name__ == '__main__':
headers = {
'User - Agent': 'Mozilla / 5.0(Windows NT 10.0;WOW64) AppleWebKit / 537.36(KHTML, likeGecko) Chrome / 86.0.4240.198Safari / 537.36'
}
main()