'pyTelegramBotAPI always returning the same function

I'm building a Telegram bot using pyTelegramBotAPI and I'm facing a problem that it's always returning the second function even when I send a text that doesn't exist. My code is:

import os
import telebot
import requests

from eletronic.light import turnofflight, turnonlight


bot = telebot.TeleBot(os.getenv('BOT_TOKEN'))


@bot.message_handler(commands=["hello"])
def greeting(message):
    bot.reply_to(message, "Hello")

@bot.message_handler(func=lambda temp: temp.text is not None and 'weather' or 'Weather' in temp.text)
def verify_weather(message):
    blumenau = requests.get('https://wttr.in/Blumenau?format=3')
    bot.reply_to(message, 'text'+blumenau.text)


@bot.message_handler(func=lambda on: on.text is not None and 'on' or 'On' in on.text)
def botturnonlight(message):
    turnonlight()
    bot.reply_to(message, "text")


@bot.message_handler(func=lambda off: off.text is not None and 'off' or 'Off' in off.text)
def botturnofflight(message):
    turnofflight()
    bot.reply_to(message, "text")


def verify(message):
    return True


@bot.message_handler(func=verify)
def answer(message):
    text = """
        Text"""
    bot.reply_to(message.chat.id, text)

bot.infinity_polling()

That's probably something pretty simple there that I can't see what is it. Could someone help?

Thanks!!



Solution 1:[1]

This code be fixed removing the is not None from the bot's decorator in each function like:

@bot.message_handler(func=lambda on: on.text == 'on' or 'On' in on.text)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Arthur Ávila