G
G
gostbeat2021-01-15 23:21:56
Python
gostbeat, 2021-01-15 23:21:56

How to check if a user sent a TELEBOT link?

How to check if a user sent a link to a bot?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
MinTnt, 2021-01-16
@MinTnt

First option
if message.text.split('http://', ​​maxsplit = 1)[0] == '': #do
something.
Like, if at the beginning of the line something like "http" "https", do something, but this is not for all cases ...
The second option.
import requests
if requests.get(message.text).status_code == 200:

A
alekssamos, 2021-01-16
@alekssamos

3. It may not be in the text of the message, but in the "entities" of the "message" object.message.entities[0].url

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question