PDA

Просмотр полной версии : Помогите пж телебот


Sasha_Romanov
11.11.2022, 21:07
Начал писать бота для телеги, вылезла это ошибка:

Traceback (most recent call last):

File "main.py", line 3, in

from telebot import types

ImportError: cannot import name 'types' from 'telebot' (/home/runner/telebot/venv/lib/python3.8/site-packages/telebot/__init__.py)

А сам код для бота вот:

import telebot

import requests

from telebot import types

bot = telebot.TeleBot("5468636017:AAE03qPOxTkGhTuIyP2NBOlNbdomFMFM-g4")

@bot.message_handler(commands=["start",])

def start(message):

bot.send_message(message.chat.id,f"hi")

@bot.message_handler(commands=['help'])

def button_message(message):

markup=types.ReplyKeyboardMarkup(resize_keyboard=T rue)

item1=types.KeyboardButton("Мой вк")

markup.add(item1)

bot.send_message(message.chat.id,'Выберите что вам надо',reply_markup=markup)

@bot.message_handler(content_types='text')

def message_reply(message):

if message.text=="Мой вк":

bot.send_message(message.chat.id,"https://vk.com/trumtrum2")

bot.infinity_polling()

Писал на этом сайте https://replit.com/@sanyaaaaaa/telebot#main.py

laiser
13.11.2022, 12:13
Дубликат темы: https://www.blast.hk/threads/157364/ (https://forum.antichat.xyz/threads/1457364/)

Можешь попробовать:

pip uninstall telebot

pip uninstall pyTelegramBotAPI

pip install git+https://github.com/eternnoir/pyTelegramBotAPI.git

vladsharik
14.11.2022, 13:51
pip install PyTelegramBotAPI, а лучше переходи на aiogram, он лучше в разы