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