async def install(event): if event.fwd_from: return if event.reply_to_msg_id: try: downloaded_file_name = await event.client.download_media( # pylint:disable=E0602 await event.get_reply_message(), "userbot/plugins/" # pylint:disable=E0602 ) if "(" not in downloaded_file_name: path1 = Path(downloaded_file_name) shortname = path1.stem load_module(shortname.replace(".py", "")) await event.edit("Plugin Caricato `{}`".format( os.path.basename(downloaded_file_name))) else: os.remove(downloaded_file_name) await event.edit( f"`{DEFAULTUSER}`:**Errore! Plugin installato/pre-installato.**" ) except Exception as e: # pylint:disable=C0103,W0703 await event.edit(str(e)) os.remove(downloaded_file_name) await asyncio.sleep(DELETE_TIMEOUT) await event.delete()
async def load(event): if event.fwd_from: return shortname = event.pattern_match["shortname"] try: try: remove_plugin(shortname) except: pass load_module(shortname) await event.edit(f"**Caricato** {shortname}") except Exception as e: await event.edit(f"**Impossibile caricare {shortname} causa error.\n{str(e)}**")
if Var.HEROKU_APP_NAME and Var.HEROKU_API_KEY is not None: Heroku = heroku3.from_key(Var.HEROKU_API_KEY) app = Heroku.app(Var.HEROKU_APP_NAME) heroku_var = app.config() variable = "SUDO_USERS" if variable in heroku_var: del heroku_var[variable] else: print("Avvio Userbot completato senza errori") print("Avvio terminato") else: bot.start() import glob path = 'userbot/plugins/*.py' files = glob.glob(path) for name in files: with open(name) as f: path1 = Path(f.name) shortname = path1.stem load_module(shortname.replace(".py", "")) import userbot._core print("USERBOT-100101110 in esecuzione, test con .alive") if len(argv) not in (1, 3, 4): bot.disconnect() else: bot.run_until_disconnected()