Skip to content
View lambrightn17's full-sized avatar

Block or report lambrightn17

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
lambrightn17/README.md
  • 👋 Hi, I’m @lambrightn17
  • 👀 I’m interested in ...
  • 🌱 I’m currently learning ...
  • 💞️ I’m looking to collaborate on ...
  • 📫 How to reach me ...
  • 😄 Pronouns: ...
  • ⚡ Fun fact: ...

from telegram.ext import Updater, MessageHandler, Filters from collections import Counter import re

Replace with your actual Telegram bot token

TOKEN = '6873450444:AAFKVZWGLsgXg6ZhKrGNWHb4zml6sr7pD0E'

def count_words(text): # Clean text by removing special characters and converting to lowercase cleaned_text = re.sub(r'[^\w\s]', '', text.lower()) # Split text into words and count frequency using Counter word_counts = Counter(cleaned_text.split()) return word_counts

def handle_message(update, context): message = update.message.text word_counts = count_words(message) sorted_word_counts = sorted(word_counts.items(), key=lambda x: x[1], reverse=True)

# Prepare response
response = "Word frequencies:\n"
for word, count in sorted_word_counts[:20]:  # Show top 20 words
    response += f"{word}: {count}\n"

# Send response back to the user
context.bot.send_message(chat_id=update.effective_chat.id, text=response)

def main(): updater = Updater(token=TOKEN, use_context=True) dispatcher = updater.dispatcher

# Handle incoming messages
message_handler = MessageHandler(Filters.text & (~Filters.command), handle_message)
dispatcher.add_handler(message_handler)

# Start the Bot
updater.start_polling()
updater.idle()

if name == 'main': main()

Pinned Loading

  1. go-telegram-bot-api/telegram-bot-api go-telegram-bot-api/telegram-bot-api Public

    Golang bindings for the Telegram Bot API

    Go 5.9k 909