Primer commit. Codigo creado en el año 2025
This commit is contained in:
28
groupid.py
Executable file
28
groupid.py
Executable file
@@ -0,0 +1,28 @@
|
||||
from dotenv import load_dotenv
|
||||
import os
|
||||
load_dotenv()
|
||||
|
||||
TOKEN=os.environ.get("TOKEN")
|
||||
|
||||
from telegram import Update
|
||||
from telegram.ext import ApplicationBuilder, MessageHandler, filters, ContextTypes
|
||||
|
||||
# Funcion simple para obtener el token de un grupo
|
||||
# Agregar el bot al grupo y enviar un mensaje. en consola se mostrara datos del mensaje, entre esos, el id del grupo
|
||||
|
||||
async def echo(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
||||
# Mostrar el mensaje recibido en la consola
|
||||
print(f"Mensaje recibido de {update.message.from_user.first_name}: {update.message.text}")
|
||||
print(update.message)
|
||||
|
||||
def main():
|
||||
application = ApplicationBuilder().token(TOKEN).build()
|
||||
|
||||
message_handler = MessageHandler(filters.TEXT & (~filters.COMMAND), echo)
|
||||
application.add_handler(message_handler)
|
||||
|
||||
# Iniciar el bot
|
||||
application.run_polling()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user