You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have two commands in admin_panel.py: /add_chat and /add_channel. I just can't figure out one thing - why /add_channel is being processed, but /add_chat doesn't want to work.
`
from aiogram import Bot, Router, F
from aiogram.types import Message
from aiogram.filters import Command
from config import TOKEN, ADMIN_IDS
from db_manager import db
bot = Bot(token=TOKEN)
admin_router = Router()
@admin_router.message(Command(commands=["add_chat"]), F.chat.type == "private", F.from_user.id.in_(ADMIN_IDS))
async def add_chat(message: Message):
args = message.text.split()[1:]
if not args:
await message.answer("Use the command in the format: /add_chat ")
return
chat_link = args[0]
if chat_link.startswith("https://t.me/"):
chat_username = chat_link.split('/')[-1]
try:
chat = await bot.get_chat(chat_username)
db.add_chat(chat_link, "@" + chat.username, chat.id)
await message.answer(f"Chat {chat_link} added with ID {chat.id}")
except Exception as e:
await message.answer(f"Error adding chat: {e}")
else:
await message.answer("An incorrect chat link was provided.")
@admin_router.message(Command(commands=["add_channel"]), F.chat.type == "private", F.from_user.id.in_(ADMIN_IDS))
async def add_channel(message: Message):
args = message.text.split()[1:]
if len(args) < 2:
await message.answer("Use the command in the format: /add_channel ")
return
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have two commands in admin_panel.py: /add_chat and /add_channel. I just can't figure out one thing - why /add_channel is being processed, but /add_chat doesn't want to work.
`
from aiogram import Bot, Router, F
from aiogram.types import Message
from aiogram.filters import Command
from config import TOKEN, ADMIN_IDS
from db_manager import db
bot = Bot(token=TOKEN)
admin_router = Router()
@admin_router.message(Command(commands=["add_chat"]), F.chat.type == "private", F.from_user.id.in_(ADMIN_IDS))
async def add_chat(message: Message):
args = message.text.split()[1:]
if not args:
await message.answer("Use the command in the format: /add_chat ")
return
@admin_router.message(Command(commands=["add_channel"]), F.chat.type == "private", F.from_user.id.in_(ADMIN_IDS))
async def add_channel(message: Message):
args = message.text.split()[1:]
if len(args) < 2:
await message.answer("Use the command in the format: /add_channel ")
return
`
I can share the entire code if needed.
Beta Was this translation helpful? Give feedback.
All reactions