0% found this document useful (0 votes)
8 views1 page

Urlb

This document contains a Python script for a Telegram bot that processes messages from a specific user. It cleans the received text by removing URLs and replies with the cleaned text if the user ID matches the allowed user. If the user ID does not match, it sends a message indicating that they are not allowed to use the bot.

Uploaded by

bilal.cabir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Urlb

This document contains a Python script for a Telegram bot that processes messages from a specific user. It cleans the received text by removing URLs and replies with the cleaned text if the user ID matches the allowed user. If the user ID does not match, it sends a message indicating that they are not allowed to use the bot.

Uploaded by

bilal.cabir
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

from telegram import Update

from telegram.ext import Application, MessageHandler, filters, CallbackContext


import re

TOKEN = "7656995629:AAEpmVZ-ncvwenvm4IBsQczHz9MiMWxDtX8"
ALLOWED_USER_ID = 7286193428

def clean_log(text):
clean_text = re.sub(r'https?://\S+', '', text).strip()
return clean_text

async def message_received(update: Update, context: CallbackContext) -> None:


user_id = update.message.from_user.id
if user_id == ALLOWED_USER_ID:
received_text = update.message.text
clean_text = clean_log(received_text)
await update.message.reply_text(clean_text)
else:
await update.message.reply_text("You are not allowed to use this bot.")

def main():
app = Application.builder().token(TOKEN).build()
app.add_handler(MessageHandler(filters.TEXT & ~filters.COMMAND,
message_received))
app.run_polling()

if __name__ == '__main__':
main()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy