Ver código fonte

Update carbon.py (#281)

No need for close().
handle error.
ÁÑÑÍHÌLÅTØR SPÄRK 1 ano atrás
pai
commit
ef44450c94
1 arquivos alterados com 9 adições e 6 exclusões
  1. 9 6
      wbb/modules/carbon.py

+ 9 - 6
wbb/modules/carbon.py

@@ -40,9 +40,12 @@ async def carbon_func(_, message):
         return await message.reply_text(
             "Reply to a text message to make carbon."
         )
-    m = await message.reply_text("Preparing Carbon")
-    carbon = await make_carbon(message.reply_to_message.text)
-    await m.edit("Uploading")
-    await app.send_document(message.chat.id, carbon)
-    await m.delete()
-    carbon.close()
+    status = await message.reply_text("Preparing Carbon…")
+    try:
+        carbon = await make_carbon(message.reply_to_message.text)
+        await status.edit("Uploading…")
+        await app.send_document(message.chat.id, carbon)
+    except Exception as e:
+        await status.edit(f"❌ Failed: {e}")
+    else:
+        await status.delete()