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)
class hi():
def __init__(self):
self.msg = ''
def hello(self):
self.msg = str("Hello")
return self
def world(self):
self.msg += " World!"
return self
def __str__(self):
return self.msg
caller = hi()
print(caller.hello())
print(caller.hello().world())
print(caller.hello().world().world())
Hello
Hello World!
Hello World! World!
код для удаления определенного сообщения в канале, ранее отправленного ботом, если каждое направленное сообщение от бота будет иметь свой id.
def delete_handler(message):
def delete_handler(message):
bot.delete_message(message.chat.id, message.message_id - 1)
Я в общем виде привел, если где-то понадобится значения использовать.