예제 #1
0
def classify(msg):
    msg = msg.lower().strip()
    if msg == "help":
        return "Je sais répondre aux salutations basiques ainsi que vous donner la météo :)"
    if msg in salutations:
        return "Bonjour ! Comment est votre blanquette ?"
    if msg.find("bitcoin") == 0:
        try:
            currency = msg.split()[1]
            return bitcoin(currency)
        except:
            return "Tktbitcoin"
    if msg.find("euros") == 0:
        try:
            currency = msg.split()[1]
            return bitcoin(currency, invert=True)
        except:
            return "Tktbitcoin"
    if msg.find("weather") == 0:
        try:
            city = msg.split()[1]
            return weather(city)
        except:
            return "Je ne connais pas cette ville, désolé"
    return "Pardon, je n'ai pas compris"
예제 #2
0
def do(user,message):
	if isweather(message.lower()):
		return weather(readcity(user),readlang(user))
	elif isnews(message.lower()):
		return news(user)
	elif isnote(message.lower()):
		return(note(user,message))
	else:
		return(idontknown(user))
예제 #3
0
 def handle_message(self, message):
     if message == "天气" or message == "weather":
         we = weather()
         info = we.get_today_info()
         return info
     elif message.startswith("http"):
         email = HandleEmail("smtp.139.com")
         email.email_me()
     else:
         tr = transport()
         content = tr.transport_word(message)
         return content
예제 #4
0
def classify(msg):
    msg = msg.strip()

    if (msg == "help"):
        return "commonly used commands: \n1.Greeting: Hi\n\n2.google <word> (for google search).\n3.weather city_name "
    if (msg in greeting):
        return "Hello! Whats up?"
    if (msg.find("google") == 0):
        return "Feature for google search will be added soon."
    if (msg.find("weather") == 0):
        try:
            city = msg.split()[1]
            return weather(city)
        except:
            return "please enter valid city name"
    return "sorry! I didn't get that"
예제 #5
0
def classify(msg):
    msg = msg.lower().strip()

    if (msg == "help"):
        return "commonly used commands: \n1.Greeting: Hi\n2.weather city_name "
    if (msg in welcome):
        return "Hello! Whats up?"
    # if (msg.find("google")==0):
    # 	query = msg.split()[1]
    # 	return search(query, num=10)
    if (msg.find("weather") == 0):
        try:
            city = msg.split()[1]
            return weather(city)
        except:
            return "please enter a valid city name"
    return "Sorry! I didn't get that"
예제 #6
0
def classify(msg):
    msg = msg.lower().strip()

    if (msg == "help"):
        return "commonly used commands: \n1.Greeting: Hi\n\n2.google <word> (for google search).\n3.weather city_name "
    if (msg in greeting):
        return "Hello! Whats up?"
    if (msg.find("google") == 0):
        #try:
        query = msg.split()[1]
        return search(query, num=10)
    #except:
    #return "invalid search query"
    if (msg.find("weather") == 0):
        try:
            city = msg.split()[1]
            return weather(city)
        except:
            return "please enter valid city name"
    return "sorry! I didn't get that"
예제 #7
0
파일: myPost.py 프로젝트: phulei/chirico
#!/usr/bin/env python
import urllib
import urllib2
from weather import *

url = 'http://weather.cwxstat.org/post'
req = urllib2.Request(url)
r = urllib2.urlopen(req)
lastWeather = str(r.read())

a = weather(lastWeather)

url = 'http://weather.cwxstat.org/post'
values = {'Temp': '71.2', 'Hum': '41', 'Time': '3:23', 'Notes': 'null'}
values['List'] = str(a)
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
r = urllib2.urlopen(req)
a = r.read()
print a
예제 #8
0
from weather import *

answer = input(
    "Is sunny outside? (Y/N) ")  # prompt user to answer if it is sunny
weather(answer)
예제 #9
0
def temp():
    return weather()
예제 #10
0
    GPIO.output(22, GPIO.LOW)
    print('left')


def stop():
    GPIO.output(17, GPIO.LOW)
    GPIO.output(25, GPIO.LOW)
    GPIO.output(10, GPIO.LOW)
    GPIO.output(18, GPIO.LOW)
    print('stop')


motor_init()
stop()
count = 0
x = weather()
servoinit()
print(x)
if (x == False):
    print(
        'will not water as it rained yesterday or it may rain today or tomorrow'
    )
else:
    x = 0
    while True:
        avgDistance = 0
        for i in range(2):
            GPIO.output(TRIG, False)  #Set TRIG as LOW
            time.sleep(0.1)  #Delay
            GPIO.output(TRIG, True)  #Set TRIG as HIGH
            time.sleep(0.00001)  #Delay of 0.00001 seconds
예제 #11
0
#!/usr/bin/env python
import urllib
import urllib2
from weather import *


url='http://weather.cwxstat.org/post'
req = urllib2.Request(url)
r = urllib2.urlopen(req)
lastWeather = str(r.read())

a=weather(lastWeather)

url='http://weather.cwxstat.org/post'
values={'Temp':'71.2','Hum':'41','Time':'3:23','Notes':'null'}
values['List']=str(a)
data = urllib.urlencode(values)
req = urllib2.Request(url,data)
r = urllib2.urlopen(req)
a = r.read()
print a