R
R
Remasten2020-05-11 12:51:27
Python
Remasten, 2020-05-11 12:51:27

How to add name=GROUP_ID variable?

Hello, I have a problem, here is a piece of code:

import telebot
import config

 
from telebot import types

bot = telebot.TeleBot(config.TOKEN)

CROUP_ID = -1001475859310

@bot.message_handler(func=lambda message: message.entities is not None and message.chat.id == GROUP_ID)
def delete_links(message):
  for entity in message.entities: 
    if entity.type in ["url", "text_link"]:
      bot.delete_message(message.chat.id, message.message_id)
    else:
      return


It gives the following error text, I understand that there is no name variable, but how to insert it then?
ERROR - TeleBot: "NameError occurred, args=("name 'GROUP_ID' is not defined",)
Traceback (most recent call last):

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2021-12-02
@dmitriy8720

import telebot
from time import time
bot = telebot.TeleBot("MOY_TOKEN")
GROUP_ID = -1digits5 # your group ID
Remove these 2 lines
import config
bot = telebot.TeleBot(config.TOKEN)
My code works fine.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question