79156606

Date: 2024-11-04 18:41:33
Score: 1.5
Natty:
Report link

i am new to aiogram. I tried the following function for myself.

from aiogram import Bot, Dispatcher, types
from aiogram.filters import Filter,CommandStart
from aiogram.types import Message, User
import asyncio
API_TOKEN = "your_token"
ADMIN_CHAT_ID = "admins_id"

bot = Bot(token=API_TOKEN)
dp = Dispatcher()
from aiogram import Dispatcher, types

dp = Dispatcher()

@dp.message(CommandStart())
async def start_command(message: Message):
    await message.reply("Welcome to the bot!")
send_messages = [ ]
@dp.message()
async def message_handler(message: types.Message):
    send_messages.append(message)
    for message in send_messages:
        if message.forward_origin is not None:
            message_sender = message.from_user.username or message.from_user.full_name
            user_data = f"User: {message.forward_from.full_name} (@{message.forward_from.username}), " \
                        f"ID: {message.forward_from.id}" \
                        f"message {message}"

            await bot.send_message(ADMIN_CHAT_ID, f"Forwarded message from: {user_data}") 

async def main():
    await dp.start_polling(bot)
if __name__ == '__main__':
    asyncio.run(main())
Reasons:
  • RegEx Blacklisted phrase (1.5): i am new
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Murodjon Isroilov