示例#1
0
async def add_bot(bot_token):
    try:
        await bot.start(bot_token)
        bot.me = await bot.get_me()
        bot.uid = telethon.utils.get_peer_id(bot.me)
    except Exception as e:
        LOGS.error(f"STRING_SESSION - {str(e)}")
        sys.exit()
示例#2
0
async def add_bot(bot_token):
    try:
        await bot.start(bot_token)
        bot.me = await bot.get_me()
        bot.uid = telethon.utils.get_peer_id(bot.me)
    except Exception as e:
        LOGS.error("{} -".format(Xe) + f"{str(e)}")
        sys.exit()
示例#3
0
async def take_screen_shot(video_file: str, duration: int, path: str = '') -> Optional[str]:
    """ take a screenshot """
    LOGS.info('[[[Extracting a frame from %s ||| Video duration => %s]]]', video_file, duration)
    ttl = duration // 2
    thumb_image_path = path or os.path.join("./temp/", f"{basename(video_file)}.jpg")
    command = f"ffmpeg -ss {ttl} -i '{video_file}' -vframes 1 '{thumb_image_path}'"
    err = (await runcmd(command))[1]
    if err:
        LOGS.error(err)
    return thumb_image_path if os.path.exists(thumb_image_path) else None
示例#4
0
async def autopilot():
    LOGS.info("TUNGGU SEBENTAR. SEDANG MEMBUAT GROUP LOG USERBOT UNTUK ANDA")
    desc = "Group Log untuk Man-UserBot.\n\nHARAP JANGAN KELUAR DARI GROUP INI.\n\n✨ Powered By ~ @Lunatic0de ✨"
    try:
        grup = await bot(
            CreateChannelRequest(title="Log UserBot",
                                 about=desc,
                                 megagroup=True))
        grup_id = grup.chats[0].id
    except Exception as e:
        LOGS.error(str(e))
        LOGS.warning(
            "var BOTLOG_CHATID kamu belum di isi. Buatlah grup telegram dan masukan bot @MissRose_bot lalu ketik /id Masukan id grup nya di var BOTLOG_CHATID"
        )
    if not str(grup_id).startswith("-100"):
        grup_id = int(f"-100{str(grup_id)}")
    heroku_var["BOTLOG_CHATID"] = grup_id
示例#5
0
def __list_all_modules():
    import glob
    from os.path import basename, dirname, isfile

    mod_paths = glob.glob(dirname(__file__) + "/*.py")
    all_modules = [
        basename(f)[:-3] for f in mod_paths
        if isfile(f) and f.endswith(".py") and not f.endswith("__init__.py")
    ]
    if LOAD or NO_LOAD:
        to_load = LOAD
        if to_load:
            if not all(
                    any(mod == module_name for module_name in all_modules)
                    for mod in to_load):
                LOGS.error("Nama Modules yang anda masukan salah.")
                sys.exit(1)
        else:
            to_load = all_modules
        if NO_LOAD:
            LOGS.info("Modules No Load : {}".format(NO_LOAD))
            return [item for item in to_load if item not in NO_LOAD]
        return to_load
    return all_modules
示例#6
0
    bot.tgbot = None
    try:
        if Config.TG_BOT_USERNAME is not None:
            LOGS.info("Initiating Inline Bot")
            # ForTheGreatrerGood of beautification
            bot.tgbot = TelegramClient(
                "TG_BOT_TOKEN", api_id=Config.APP_ID,
                api_hash=Config.API_HASH).start(bot_token=Config.TG_BOT_TOKEN)
            LOGS.info("Initialisation finished with no errors")
            LOGS.info("Starting Userbot")
            bot.loop.run_until_complete(add_bot(Config.TG_BOT_USERNAME))
            LOGS.info("Startup Completed")
        else:
            bot.start()
    except Exception as e:
        LOGS.error(f"TG_BOT_TOKEN - {str(e)}")
        sys.exit()

path = "userbot/plugins/*.py"
files = glob.glob(path)
for name in files:
    with open(name) as f:
        path1 = Path(f.name)
        shortname = path1.stem
        try:
            if shortname.replace(".py", "") not in Config.NO_LOAD:
                load_module(shortname.replace(".py", ""))
            else:
                os.remove(Path(f"userbot/plugins/{shortname}.py"))
        except Exception as e:
            os.remove(Path(f"userbot/plugins/{shortname}.py"))
示例#7
0
if len(sys.argv) not in (1, 3, 4):
    bot.disconnect()
else:
    bot.tgbot = None
    try:
        if TBOT is not None:
            print(Mesg[0])
            bot.tgbot = TC(Xtbot, api_id=A, api_hash=H).start(bot_token=B)
            print(Mesg[1])
            print(Mesg[2])
            bot.loop.run_until_complete(add_bot(TBOT))
            print(Mesg[3])
        else:
            bot.start()
    except Exception as e:
        LOGS.error("{} -".format(Xt) + f"{str(e)}")
        sys.exit()


# For all plugins
print(Start)
print(StartLoaded)
Kim = glob.glob(Plg)
for name in Kim:
    with open(name) as k:
        Kim1 = P(k.name)
        shortname = Kim1.stem
        try:
            if shortname.replace(".py", "") not in N:
                load_module(shortname.replace(".py", ""))
            else:
示例#8
0
 async def wrapper(event):
     chat = event.chat
     if admins_only:
         if event.is_private:
             return await edit_delete(
                 event,
                 "**Perintah ini hanya bisa digunakan di grup.**", 10)
         if not (chat.admin_rights or chat.creator):
             return await edit_delete(
                 event, f"**Maaf anda bukan admin di {chat.title}**",
                 10)
     if group_only and not event.is_group:
         return await edit_delete(
             event, "**Perintah ini hanya bisa digunakan di grup.**",
             10)
     if private_only and not event.is_private:
         return await edit_delete(
             event,
             "**Perintah ini hanya bisa digunakan di private chat.**",
             10)
     try:
         await func(event)
     # Credits: @mrismanaziz
     # FROM Man-Userbot <https://github.com/mrismanaziz/Man-Userbot>
     # t.me/SharingUserbot & t.me/Lunatic0de
     except MessageNotModifiedError as er:
         LOGS.error(er)
     except MessageIdInvalidError as er:
         LOGS.error(er)
     except BotInlineDisabledError:
         await edit_delete(
             event, "**Silahkan aktifkan mode Inline untuk bot**", 10)
     except ChatSendStickersForbiddenError:
         await edit_delete(
             event, "**Tidak dapat mengirim stiker di obrolan ini**",
             10)
     except BotResponseTimeoutError:
         await edit_delete(
             event, "**The bot didnt answer to your query in time**")
     except ChatSendMediaForbiddenError:
         await edit_delete(
             event, "**Tidak dapat mengirim media dalam obrolan ini**",
             10)
     except AlreadyInConversationError:
         await edit_delete(
             event,
             "**Percakapan sudah terjadi dengan obrolan yang diberikan. coba lagi setelah beberapa waktu.**",
         )
     except ChatSendInlineForbiddenError:
         await edit_delete(
             event,
             "**Tidak dapat mengirim pesan inline dalam obrolan ini.**",
             10,
         )
     except FloodWaitError as e:
         LOGS.error(
             f"Telah Terjadi flood wait error tunggu {e.seconds} detik dan coba lagi"
         )
         await event.delete()
         await asyncio.sleep(e.seconds + 5)
     except events.StopPropagation:
         raise events.StopPropagation
     except KeyboardInterrupt:
         pass
     except BaseException as e:
         LOGS.exception(e)