Moved to async
This commit is contained in:
@@ -7,7 +7,7 @@ from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
||||
from modules.logging import logWrite
|
||||
from modules.utils import jsonLoad, jsonSave, configGet, locale
|
||||
|
||||
def send_content(app: Client):
|
||||
async def send_content(app: Client):
|
||||
|
||||
# Send post to channel
|
||||
try:
|
||||
@@ -45,7 +45,7 @@ def send_content(app: Client):
|
||||
else:
|
||||
logWrite(locale("post_empty", "console", locale=configGet("locale")))
|
||||
if configGet("error", "reports"):
|
||||
app.send_message(configGet("admin"), locale("post_empty", "message", locale=configGet("locale")))
|
||||
await app.send_message(configGet("admin"), locale("post_empty", "message", locale=configGet("locale")))
|
||||
return
|
||||
|
||||
if candidate_file in index["captions"]:
|
||||
@@ -65,21 +65,21 @@ def send_content(app: Client):
|
||||
|
||||
if configGet("enabled", "caption"):
|
||||
if configGet("link", "caption") != None:
|
||||
sent = app.send_photo(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting"))
|
||||
sent = await app.send_photo(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting"))
|
||||
else:
|
||||
sent = app.send_photo(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting"))
|
||||
sent = await app.send_photo(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting"))
|
||||
else:
|
||||
sent = app.send_photo(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting"))
|
||||
sent = await app.send_photo(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting"))
|
||||
|
||||
elif ext_type == "video":
|
||||
|
||||
if configGet("enabled", "caption"):
|
||||
if configGet("link", "caption") != None:
|
||||
sent = app.send_video(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting"))
|
||||
sent = await app.send_video(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting"))
|
||||
else:
|
||||
sent = app.send_video(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting"))
|
||||
sent = await app.send_video(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting"))
|
||||
else:
|
||||
sent = app.send_video(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting"))
|
||||
sent = await app.send_video(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting"))
|
||||
|
||||
else:
|
||||
return
|
||||
@@ -95,14 +95,14 @@ def send_content(app: Client):
|
||||
logWrite(locale("post_sent", "console", locale=configGet("locale")).format(candidate, ext_type, str(configGet("channel", "posting")), caption.replace("\n", "%n"), str(configGet("silent", "posting"))))
|
||||
|
||||
if configGet("sent", "reports"):
|
||||
app.send_message(configGet("admin"), f"Posted `{candidate_file}`", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([
|
||||
await app.send_message(configGet("admin"), f"Posted `{candidate_file}`", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([
|
||||
[InlineKeyboardButton(locale("post_view", "button", locale=configGet("locale")), url=sent.link)]
|
||||
]))
|
||||
|
||||
except Exception as exp:
|
||||
logWrite(locale("post_exception", "console", locale=configGet("locale")).format(str(exp), format_exc()))
|
||||
if configGet("error", "reports"):
|
||||
app.send_message(configGet("admin"), locale("post_exception", "message", locale=configGet("locale")).format(exp, format_exc()))
|
||||
await app.send_message(configGet("admin"), locale("post_exception", "message", locale=configGet("locale")).format(exp, format_exc()))
|
||||
pass
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user