29 lines
893 B
Python
Executable File
29 lines
893 B
Python
Executable File
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()
|