import re
# Используем регулярное выражение, чтобы найти user_id в ссылке
match = re.search(r'tg://user\?id=(\d+)', mention)
# Если ссылка была найдена
if match:
# Извлекаем user_id из ссылки
user_id = int(match.group(1))
print(user_id) @dp.message_handler(), который позволяет обрабатывать сообщения в цикле. Например, так:from aiogram import Dispatcher, types
@dp.message_handler()
async def handle_message(message: types.Message):
# Здесь можете проверить, что пользователь является админом
if user_is_admin(message.from_user.id):
# Сохраняем сообщение в переменную
message_text = message.text
# Отправляем сообщение в канал
await bot.send_message(channel_id, message_text)handle_message() функция будет вызываться каждый раз, когда пользователь отправит сообщение боту. Внутри функции вы можете проверить, что пользователь является админом, и сохранить сообщение в переменную message_text. pip install okpyimport okpyclient = okpy.Client()
client.auth('login', 'password')import okpy
# авторизуемся в Одноклассниках
client = okpy.Client()
client.auth('login', 'password')
# отправляем сообщение в чат
client.messages.send('chat_id', 'Привет, я бот!') pip install telethonfrom telethon import TelegramClient
from telethon.tl.functions.channels import InviteToChannelRequestclient = TelegramClient('session_name', api_id, api_hash)client.start()channel = client.get_entity('channel_name')result = client(InviteToChannelRequest(channel=channel))invite_link = result.link
print(invite_link) import re
from aiogram import Bot, Dispatcher, types
# Инициализируем бота и диспетчер
bot = Bot(token='your_bot_token')
dp = Dispatcher(bot)
@dp.message_handler()
async def handle_message(message: types.Message):
# Извлекаем упоминание из сообщения
mention = re.search(r'@(\w+)', message.text)
if mention:
# Получаем id пользователя через resolve_peer
user_id = await bot.resolve_peer(mention.group(1))
# Теперь можем использовать user_id для выполнения нужных действий
await message.reply(f'User ID: {user_id}')from pyrogram.raw.functions.account import ReportPeer
from pyrogram.raw.types import *
# Edited. Forgot to replace types2 classes you've putted in your code
def get_report_reason(text):
if text == "Report for child abuse.":
return InputReportReasonChildAbuse()
elif text == "Report for impersonation.":
return InputReportReasonFake()
elif text == "Report for copyrighted content.":
return InputReportReasonCopyright()
elif text == "Report an irrelevant geogroup.":
return InputReportReasonGeoIrrelevant()
elif text == "Other.":
return InputReportReasonOther()
peer = app.resolve_peer("@test")
peer_id = peer["channel_id"]
access_hash = peer["access_hash"]
# Also you have to determine here what type of peer is that.
# Lets take channel.
channel = InputPeerChannel(channel_id=peer_id, access_hash=access_hash)
reason = get_report_reason(report_reason)
report_peer = ReportPeer(
peer=channel,
reason=reason,
message="text"
)
report = app.send(report_peer) keyboard.pycallback_data url:Звук в лучшем качестве.', callback_data=f'best_audio|{url}')bot.send_message(...) и bot.delete_message(...) используйте message.answer(...) и message.delete() Немного не правильно составлен код.
Нужно использовать next_step для перехода в другую функцию. И там уже обрабатываешь то что ввел юзер.