@bot.callback_query_handler(func=lambda c:True)
def inlin(c):
if c.data == 'house':
myPlace = "Trëkhgorka, RU"
elif c.data == 'myplace':
myPlace = "Los Angeles, USA"
weather_message(c.message, myPlace)
len(param) = 0
, потому что readlines() не убирает символы переноса строки. Т.е. даже там, где строка пустая, она загрузится как '\n'.message.from_user.id
@bot.message_handler(commands=['help'])
def help_message(message):
bot.send_message(message.chat.id, 'Здесь наша страничка помощи')
@bot.callback_query_handler(func=lambda c:True)
def inlin(c):
if c.data == 'help':
help_message(c.message)
import time
import speech_recognition as sr
def callback(recognizer, audio):
try:
print("Google Speech Recognition thinks you said " + recognizer.recognize_google(audio))
except sr.UnknownValueError:
print("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
print("Could not request results from Google Speech Recognition service; {0}".format(e))
r = sr.Recognizer()
m = sr.Microphone()
with m as source:
r.adjust_for_ambient_noise(source) # we only need to calibrate once, before we start listening
# start listening in the background (note that we don't have to do this inside a `with` statement)
stop_listening = r.listen_in_background(m, callback)
# `stop_listening` is now a function that, when called, stops background listening
while True: time.sleep(0.1)
а в свой обработчик callback_query_handler добавляй реакцию на новые варианты, ниже уже добавленных.