from io import BytesIO
from aiogram import types
import aiohttp
from PIL import Image
async def image_link_by_file_id(file_id) -> str:
with await bot.download_file_by_id(file_id=file_id) as img:
image = Image.open (img)
output = BytesIO()
image.save(output, format='PNG')
output.seek(0)
form = aiohttp.FormData ()
form.add_field(
name='file',
value=output,
)
async with bot.session.post('https://telegra.ph/upload', data=form) as response:
html = await response.text()
img_src = await response.json()
link = 'http://telegra.ph/' + img_src[0]["src"]
return link
Request URL: https://postimages.org/json/rr
Request Method: POST
import keyboard # using module keyboard
import pyautogui as py
def bind():
py.press("w")
while True: # making a loop
try: # used try so that if user pressed other than the given key error will not be shown
if keyboard.is_pressed('a'): # if key 'q' is pressed
print('hello')
bind()
except:
pass
try: # used try so that if user pressed other than the given key error will not be shown
if keyboard.is_pressed('q'): # if key 'q' is pressed
print('You Pressed A Key!')
break # finishing the loop
except:
break # if user pressed a key other than the given key the loop will break