Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: 'in <string>' requires string as left operand, not NoneType #1297

Closed
bim-ba opened this issue Sep 11, 2021 · 1 comment
Closed

Comments

@bim-ba
Copy link
Contributor

bim-ba commented Sep 11, 2021

System info

  1. What version of pyTelegramBotAPI are you using?
    4.0.0

  2. What OS are you using?
    GNU/Linux 5.14.2-arch1-2

  3. What version of python are you using?
    3.9.7


Code

import telebot

bot = telebot.TeleBot(token)

search = []

@bot.message_handler(commands='start')
def start(message):
    bot.send_message(message.chat.id, 'Just use /find command!')

@bot.message_handler(commands='find')
def find(message):
    if message.chat.id not in search:
        bot.send_message(message.chat.id, 'Finding...')
        search.append(message.chat.id)
        print(search)
    else:
        bot.send_message(message.chat.id, 'Shut up!')

@bot.message_handler(commands='stop')
def stop(message):
    if message.chat.id in search:
        bot.send_message(message.chat.id, 'Stopping...')
        search.remove(message.chat.id)
        print(search)
    else:
        bot.send_message(message.chat.id, 'You are not in search!')

bot.polling()

Screenshot

Screenshot_2021-09-11_18-10-38

@Badiboy
Copy link
Collaborator

Badiboy commented Sep 11, 2021

"commands" should be LIST

(commands=['start'])

@Badiboy Badiboy closed this as completed Sep 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants