-
Notifications
You must be signed in to change notification settings - Fork 11
/
Chat.py
42 lines (34 loc) · 990 Bytes
/
Chat.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
import Tuling
import Weather
import time
import re
import os
import threading
import Music
def play(url):
os.system('mplayer "%s"' % url)
def has_music(text):
thre=threading.Thread();
if text[0].__eq__("点") and text[1].__eq__("歌"):
url = Music.get_musicurl(text[2:])
thre=threading.Thread(target=play,args=[url])
thre.start()
return url
elif text.__contains__("停止"):
os.system('killall -9 mplayer' )
else:
return has_weather(text)
def has_weather(text):
if text.__contains__("本地天气"):
return Weather.main()
else:
return no_music_distance(text)
def no_music_distance(text):
if '功能' in text:
return Tuling.GONGNENG
#elif '时间' in text or '几点' in text:
#return "现在是北京时间{}".format(time.strftime("%Y-%m-%d %H:%M:%S"))
else:
reply = Tuling.get_response(text)
return reply