Answer the question
In order to leave comments, you need to log in
How to send a short username to Vkbottle? And how to send attachments in messages?
I used the users.get() method and it should store information about the user (first name, last name, ad name, short name, etc.) I need to send a short user name, but when I try to do this, I get None, and if I want output just id, then everything will turn out well, but it turns out not clickable, I need clickable
Ie, either I need to make a clickable id, or a short name
And another question, when a bot is sent a message with an error and plus any attachment (photo, audio, document), then it sends only one text, but no photo, documents. How can I fix this?
Here is my code
from vkbottle.bot import Bot, Message
from vkbottle import Keyboard, KeyboardButtonColor, \
Text, OpenLink, Location, EMPTY_KEYBOARD
from vkbottle_types import BaseStateGroup
from vkbottle import CtxStorage
bot = Bot(token="")
ctx = CtxStorage()
class RegData(BaseStateGroup):
OSHY = 0
@bot.on.message(lev="Ошибка")
async def oshi_handler(message: Message):
keyboard = Keyboard(one_time=True).add(Text("Назад в меню", {"cmd": "menu"}))
await message.answer("❌ Это форма для отправки ошибок, багов, проблем, предложений и тд.\n\n\
❗ Подробно опиши ошибку, с которой ты столкнулся.\n\
Лучше чтобы был скрин", keyboard=keyboard)
await bot.state_dispenser.set(message.peer_id, RegData.OSHY)
return "Что то там...1"
@bot.on.message(state=RegData.OSHY)
async def oshi_handler(message: Message):
userq = await bot.api.users.get(message.from_id)
ctx.set("oshy", message.text)
txtq = ctx.get("oshy")
await bot.api.messages.send(peer_id=291080599, message=f"Новая ошибка от {userq[0].first_name} {userq[0].last_name} Vkid: {userq[0].id}: \n{txtq}", random_id=0) #вот тут domain должен вывести короткое имя, но выводит None, а если я пишу id то все работает
return "Спасибо за обнаружение ошибки.."
@bot.on.message()
async def MessagesLongpollParams(message: Message):
keyboard = Keyboard(one_time=True)
keyboard.add(Text("Меню", {"cmd": "menu"}), color=KeyboardButtonColor.NEGATIVE)
await message.answer("Я тебя не понимаю.\n\n Перейди в меню и выбери из пунктов, что ты хочешь узнать.", keyboard=keyboard)
bot.run_forever()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question