update for new channel-helper
This commit is contained in:
@@ -4,3 +4,4 @@ USERS=9893249151
|
||||
AWS_ACCESS_KEY=AKIAUIXZQT
|
||||
AWS_SECRET_KEY=QyBnXOhmlc
|
||||
AWS_S3_BUCKET=bucket
|
||||
UPLOAD_KEY=123
|
||||
|
10
main.py
10
main.py
@@ -36,6 +36,7 @@ e621 = E621()
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
bot = Bot(token=os.environ['BOT_TOKEN'])
|
||||
dp = Dispatcher()
|
||||
upload_key = os.environ['UPLOAD_KEY']
|
||||
|
||||
ChatFilter = F.chat.id.in_(set(map(int, os.environ['USERS'].split(','))))
|
||||
|
||||
@@ -363,15 +364,10 @@ async def send_callback(cq: CallbackQuery):
|
||||
img_bytes = BytesIO()
|
||||
await bot.download(cq.message.photo[-1], img_bytes)
|
||||
img_bytes.seek(0)
|
||||
data = base64.b64encode(img_bytes.read()).decode()
|
||||
async with httpx.AsyncClient() as client:
|
||||
try:
|
||||
r = await client.post(f'https://bots.bakatrouble.me/bots_rpc/{destination}/', json={
|
||||
"method": "post_photo",
|
||||
"params": [data, True],
|
||||
"jsonrpc": "2.0",
|
||||
"id": 0,
|
||||
})
|
||||
subdomain = 'ch' + 'sfw' if destination == 'pics' else 'nsfw'
|
||||
r = await client.post(f'https://{subdomain}.bakatrouble.me/{upload_key}/', files={'upload': img_bytes})
|
||||
logging.info(r.text)
|
||||
resp = r.json()
|
||||
result = resp.get('result')
|
||||
|
Reference in New Issue
Block a user