Replace hastbin with deldog (#1377)

Hopefully it's dead less often.
This commit is contained in:
Qwerty-Space 2020-01-22 11:29:04 +00:00 committed by Lonami
parent 02bdf7d27c
commit 82943bd464

View File

@ -290,10 +290,10 @@ async def handler(event):
if aiohttp: if aiohttp:
@bot.on(events.NewMessage(pattern='(?i)#[hp]aste(bin)?', forwards=False)) @bot.on(events.NewMessage(pattern='(?i)#([hp]aste|dog|inu)(bin)?', forwards=False))
async def handler(event): async def handler(event):
""" """
#haste: Replaces the message you reply to with a hastebin link. #haste: Replaces the message you reply to with a dogbin link.
""" """
await event.delete() await event.delete()
if not event.reply_to_msg_id: if not event.reply_to_msg_id:
@ -324,10 +324,10 @@ if aiohttp:
text = '' text = ''
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.post('https://hastebin.com/documents', async with session.post('https://del.dog/documents',
data=code.encode('utf-8')) as resp: data=code.encode('utf-8')) as resp:
if resp.status >= 300: if resp.status >= 300:
await sent.edit("Hastebin seems to be down… ( ^^')") await sent.edit("Dogbin seems to be down… ( ^^')")
return return
haste = (await resp.json())['key'] haste = (await resp.json())['key']
@ -335,7 +335,7 @@ if aiohttp:
await asyncio.wait([ await asyncio.wait([
msg.delete(), msg.delete(),
sent.edit(f'<a href="tg://user?id={msg.sender_id}">{name}</a> ' sent.edit(f'<a href="tg://user?id={msg.sender_id}">{name}</a> '
f'said: {text} hastebin.com/{haste}.py' f'said: {text} del.dog/{haste}.py'
.replace(' ', ' '), parse_mode='html') .replace(' ', ' '), parse_mode='html')
]) ])