Я недавно начал пробывать себя в сфере ботов телеге.
При запуске выдает ошибку и говорит что эта фигня виновата (ниже)
bot = telebot.TeleBot("**********************")
код ошибки:
Код:
Traceback (most recent call last):
File "D:\Python\bot.py", line 2, in
from telebot import types
File "C:\Users\Gavrik\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\types.py", line 12, in
from telebot import util
File "C:\Users\Gavrik\AppData\Local\Programs\Python\Python310\lib\site-packages\telebot\util.py", line 322, in
def user_link(user: types.User, include_id: bool=False) -> str:
AttributeError: partially initialized module 'telebot.types' has no attribute 'User' (most likely due to a circular import)
Цитата:
сам код:
Код:
import telebot
from telebot import types
bot = telebot.TeleBot("******************)", parse_mode=None)
@bot.message_handler(commands=["start"])
def start (message):
channel_link = "https://t.me/aogirilifestyle"
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
keyboard = types.KeyboardButton(text="Confirm")
markup.add(keyboard)
chat_id = message.chat.id
user = message.chat.first_name
bot.send_message(chat_id, f"Hi {user} if u want to use bot you must subscribe to the channel/n"
f"{channel_link}", reply_markup=markup)
@bot.message_handler(content_types=["text"])
def text(message):
user = message.chat.first_name
if message.chat.type == 'private':
if message.text == 'Confirm':
status = ['creator', 'administrator', 'member']
for stat in status:
if stat == bot.get_chat_member(char_id="@aogirilifestyle", user_id=message.from_user.id).status:
bot.send_message(message.chat.id, f"Open {user}")
break
else:
bot.send_message(message.chat.id, "Sub to the channel!")
bot.polling(none_stop=True)