Python 3.9.2
PyTelegramBotAPI
Я должен создать приватного телеграмм бота, для определенной группы людей. В массив "users" я планирую занести пользователей, у которых есть доступ
users=['<usernames>']
@bot.message_handler(commands='Начать')
def handle_start(message):
if message.from_user.username==(users):
bot.send_message(message.from_user.id, 'Вот', reply_markup=user_markup, parse_mode='HTML')
if message.from_user.username!=(users):
bot.send_message(message.from_user.id, 'В доступе отказано', reply_markup=user_markup, parse_mode='HTML')
или я думаю
users=['<usernames>']
@bot.message_handler(commands='Начать')
def handle_start(message):
if message.from_user.username==(users):
bot.send_message(message.from_user.id, 'Вот', reply_markup=user_markup, parse_mode='HTML')
else:
bot.send_message(message.from_user.id, 'В доступе отказано', reply_markup=user_markup, parse_mode='HTML')
Но вот дебаг:
Traceback (most recent call last):
File "start.py", line 25, in <module>
bot.polling(none_stop=True, interval=0)
File "/home/mem/.local/lib/python3.8/site-packages/telebot/__init__.py", line 485, in polling
self.__threaded_polling(none_stop, interval, timeout, long_polling_timeout)
File "/home/mem/.local/lib/python3.8/site-packages/telebot/__init__.py", line 544, in __threaded_polling
raise e
File "/home/mem/.local/lib/python3.8/site-packages/telebot/__init__.py", line 506, in __threaded_polling
polling_thread.raise_exceptions()
File "/home/mem/.local/lib/python3.8/site-packages/telebot/util.py", line 87, in raise_exceptions
raise self.exception_info
File "/home/mem/.local/lib/python3.8/site-packages/telebot/util.py", line 69, in run
task(*args, **kwargs)
File "/home/mem/.local/lib/python3.8/site-packages/telebot/__init__.py", line 323, in __retrieve_updates
self.process_new_updates(updates)
File "/home/mem/.local/lib/python3.8/site-packages/telebot/__init__.py", line 384, in process_new_updates
self.process_new_messages(new_messages)
File "/home/mem/.local/lib/python3.8/site-packages/telebot/__init__.py", line 410, in process_new_messages
self._notify_command_handlers(self.message_handlers, new_messages)
File "/home/mem/.local/lib/python3.8/site-packages/telebot/__init__.py", line 2183, in _notify_command_handlers
if self._test_message_handler(message_handler, message):
File "/home/mem/.local/lib/python3.8/site-packages/telebot/__init__.py", line 2149, in _test_message_handler
if not self._test_filter(message_filter, filter_value, message):
File "/home/mem/.local/lib/python3.8/site-packages/telebot/__init__.py", line 2170, in _test_filter
return test_cases.get(message_filter, lambda msg: False)(message)
File "/home/mem/.local/lib/python3.8/site-packages/telebot/__init__.py", line 2166, in <lambda>
'commands': lambda msg: msg.content_type == 'text' and util.extract_command(msg.text) in filter_value,
TypeError: 'in <string>' requires string as left operand, not NoneType