Показать сообщение отдельно

  #8  
Старый 06.06.2023, 15:37
СоМиК
Постоянный
Регистрация: 26.04.2020
Сообщений: 456
С нами: 3184857

Репутация: 118
По умолчанию

Цитата:
Сообщение от xionerme  

работает - не трожь!

p.s.: если тебе это глаза мозолит, то держи

Python:





Код:
from
aiogram
import
Bot
,
Dispatcher
,
types
,
executor
import
asyncio

API_TOKEN
=
'сюда токен'
bot
=
Bot
(
token
=
API_TOKEN
)
dp
=
Dispatcher
(
bot
)
async
def
open_image
(
)
:
with
open
(
'1.jpg'
,
'rb'
)
as
photo
:
return
photo
.
read
(
)
@dp.message_handler
(
commands
=
[
'start'
]
)
async
def
send_welcome
(
message
:
types
.
Message
)
:
await
message
.
reply
(
'Привет!'
)
@dp.message_handler
(
commands
=
[
'напиши'
]
)
async
def
mq
(
message
:
types
.
Message
)
:
arg
=
message
.
get_args
(
)
if
arg
==
''
:
await
message
.
reply
(
'Где аргумент?'
)
else
:
await
bot
.
send_message
(
message
.
chat
.
id
,
arg
)
@dp.message_handler
(
content_types
=
'text'
)
async
def
text
(
message
:
types
.
Message
)
:
text
=
message
.
text
if
text
==
'картинку'
:
photo_data
=
await
asyncio
.
to_thread
(
open_image
)
await
bot
.
send_photo
(
message
.
chat
.
id
,
photo
=
photo_data
,
caption
=
'вот картинка'
)
else
:
await
message
.
reply
(
'я тебя не пониманию'
)
if
__name__
==
'__main__'
:
executor
.
start_polling
(
dp
,
skip_updates
=
True
)

И что ты сделал гений?) Ты не знаешь базы. Ты называешь гайдом код с говном из трех коллбеков))) Ты блять создаешь асинх. функцию и суешь туда СИНХРОННЫЙ КОД БЛЯТЬ, OPEN СИНХРОННАЯ ФУНКЦИЯ. Удали пожалуйста, не позорься
 
Ответить с цитированием