def blacklist(message):
    if message.from_user and message.from_user.is_self:
        message.continue_propagation()

    if not sql:
        message.continue_propagation()

    name = message.text
    if not name:
        message.continue_propagation()

    snips = None
    try:
        snips = sql.get_chat_blacklist(message.chat.id)
    except BaseException:
        message.continue_propagation()

    msg_removed = False
    for snip in snips:
        regex1 = r'( |^|[^\w])'
        regex2 = r'( |$|[^\w])'
        pattern = f"{regex1}{escape(snip)}{regex2}"
        if search(pattern, name, flags=IGNORECASE):
            try:
                message.delete()
                msg_removed = True
            except Exception as e:
                reply(message, f'`{get_translation("blacklistPermission")}`')
                sql.rm_from_blacklist(message.chat.id, snip.lower())
            break

    if not msg_removed:
        message.continue_propagation()
Esempio n. 2
0
def type_afk_is_not_true(message):
    if TEMP_SETTINGS['IS_AFK']:
        TEMP_SETTINGS['IS_AFK'] = False
        reply(message, f'**{get_translation("afkEnd")}**')
        sleep(2)
        send_log(
            get_translation(
                'afkMessages',
                [
                    '`',
                    '**',
                    str(len(TEMP_SETTINGS['AFK_USERS'])),
                    str(TEMP_SETTINGS['COUNT_MSG']),
                ],
            ))
        for i in TEMP_SETTINGS['AFK_USERS']:
            name = app.get_chat(i)
            name0 = str(name.first_name)
            send_log(
                get_translation(
                    'afkMentionUsers',
                    [
                        '**', name0,
                        str(i), '`',
                        str(TEMP_SETTINGS['AFK_USERS'][i])
                    ],
                ))
        TEMP_SETTINGS['COUNT_MSG'] = 0
        TEMP_SETTINGS['AFK_USERS'] = {}
        if 'AFK_REASON' in TEMP_SETTINGS:
            del TEMP_SETTINGS['AFK_REASON']
    raise ContinuePropagation
Esempio n. 3
0
def permitpm(client, message):
    if message.from_user and message.from_user.is_self:
        message.continue_propagation()

    if not PM_AUTO_BAN:
        message.continue_propagation()
    else:
        if auto_accept(client, message):
            return

        self_user = me[0]
        if message.chat.id not in [self_user.id, 777000]:
            try:
                from sedenecem.sql.pm_permit_sql import is_approved
            except BaseException:
                pass

            apprv = is_approved(message.chat.id)
            notifsoff = is_muted(-1)

            if not apprv and message.text != UNAPPROVED_MSG:
                if message.chat.id in PM_LAST_MSG:
                    prevmsg = PM_LAST_MSG[message.chat.id]
                    if message.text != prevmsg:
                        for message in _find_unapproved_msg(
                                client, message.chat.id):
                            message.delete()
                        if PM_COUNT[message.chat.id] < (PM_MSG_COUNT - 1):
                            ret = reply(message, UNAPPROVED_MSG)
                            PM_LAST_MSG[message.chat.id] = ret.text
                else:
                    ret = reply(message, UNAPPROVED_MSG)
                    if ret.text:
                        PM_LAST_MSG[message.chat.id] = ret.text

                if notifsoff:
                    client.read_history(message.chat.id)

                if message.chat.id not in PM_COUNT:
                    PM_COUNT[message.chat.id] = 1
                else:
                    PM_COUNT[message.chat.id] = PM_COUNT[message.chat.id] + 1

                if PM_COUNT[message.chat.id] > (PM_MSG_COUNT - 1):
                    reply(message, f'`{get_translation("pmpermitBlock")}`')

                    try:
                        del PM_COUNT[message.chat.id]
                        del PM_LAST_MSG[message.chat.id]
                    except BaseException:
                        pass

                    client.block_user(message.chat.id)

                    send_log(
                        get_translation(
                            'pmpermitLog',
                            [message.chat.first_name, message.chat.id]))

    message.continue_propagation()
def echo(message):
    args = extract_args(message)
    if len(args) > 0:
        message.delete()
        reply(message, args)
    else:
        edit(message, f'`{get_translation("echoHelp")}`')
def delayspam(message):
    # Copyright (c) @ReversedPosix | 2020-2021
    delayspam = extract_args(message)
    arr = delayspam.split()
    if len(arr) < 3 or not arr[0].isdigit() or not arr[1].isdigit():
        edit(message, f'`{get_translation("spamWrong")}`')
        return
    delay = int(arr[0])
    count = int(arr[1])
    spam_message = delayspam.replace(arr[0], '', 1)
    spam_message = spam_message.replace(arr[1], '', 1).strip()
    message.delete()

    if not spam_allowed():
        return

    delaySpamEvent = Event()
    for i in range(0, count):
        if i != 0:
            delaySpamEvent.wait(delay)
        reply(message, spam_message)
        limit = increment_spam_count()
        if not limit:
            break

    send_log(get_translation('delayspamLog'))
def report_admin(client, message):
    msg = '@admin'
    chat = message.chat.id
    for member in client.get_chat_members(chat, filter='administrators'):
        msg += f'[\u2063](tg://user?id={member.user.id})'
    re_msg = message.reply_to_message
    reply(re_msg if re_msg else message, msg)
    message.delete()
def admin(client, message):
    mesaj = '@admin'
    chat = message.chat
    for member in client.iter_chat_members(chat.id, filter='administrators'):
        mesaj += f'[\u2063](tg://user?id={member.user.id})'
    yanit = message.reply_to_message
    reply(yanit if yanit else message, mesaj, fix_markdown=True)
    message.delete()
def tagall(client, message):
    msg = '@tag'
    chat = message.chat.id
    length = 0
    for member in client.get_chat_members(chat):
        if length < 4092:
            msg += f'[\u2063](tg://user?id={member.user.id})'
            length += 1
    reply(message, msg, delete_orig=True)
def tagall(client, message):
    mesaj = '@tag'
    chat = message.chat
    uzunluk = 0
    for member in client.iter_chat_members(chat.id):
        if uzunluk < 4092:
            mesaj += f'[\u2063](tg://user?id={member.user.id})'
            uzunluk += 1
    reply(message, mesaj, fix_markdown=True)
    message.delete()
def seden(message):
    seden = extract_args(message).lower()
    cmds = OrderedDict(sorted(HELP.items()))
    if len(seden) > 0:
        if seden in cmds:
            edit(message, str(cmds[seden]))
        else:
            edit(message, f'**{get_translation("sedenUsage")}**')
    else:
        edit(message, get_translation('sedenUsage2', ['**', '`']))
        metin = f'{get_translation("sedenShowLoadedModules", ["**", "`", len(cmds)])}\n'
        for item in cmds:
            metin += f'• `{item}`\n'
        reply(message, metin)
Esempio n. 11
0
def user(message):
    try:
        session = ACC_LYDIA[message.chat.id & message.from_user.id]
        msg = message.text
        message.reply_chat_action('typing')
        text_rep = session.think_thought(msg)
        wait_time = 0
        for i in range(len(text_rep)):
            wait_time = wait_time + 0.1
        sleep(wait_time)
        reply(message, text_rep)
    except BaseException:
        pass

    message.continue_propagation()
def purge(client, message):
    msg = message.reply_to_message
    if msg:
        itermsg = list(range(msg.id, message.id))
    else:
        edit(message, f'`{get_translation("purgeUsage")}`')
        return

    count = 0

    for i in itermsg:
        try:
            count = count + 1
            client.delete_messages(chat_id=message.chat.id,
                                   message_ids=i,
                                   revoke=True)
        except FloodWait as e:
            sleep(e.x)
        except Exception as e:
            edit(message, get_translation('purgeError', ['`', '**', e]))
            return

    done = reply(message,
                 get_translation('purgeResult',
                                 ['**', '`', str(count)]))
    send_log(get_translation('purgeLog', ['**', '`', str(count)]))
    sleep(2)
    message.delete()
    done.delete()
def seden(message):
    seden = extract_args(message).lower()
    cmds = OrderedDict(sorted(KOMUT.items()))
    if len(seden) > 0:
        if seden in cmds:
            edit(message, str(cmds[seden]))
        else:
            edit(message, f'**{get_translation("sedenUsage")}**')
    else:
        edit(message, get_translation("sedenUsage2", ['**', '`']))
        metin = "{}\n".format(
            get_translation('sedenShowLoadedModules',
                            ['**', 'Seden UserBot', CHANNEL]))
        for item in cmds:
            metin += f'• `{item}`\n'
        reply(message, metin, preview=False)
def tspam(message):
    tspam = extract_args(message)
    if len(tspam) < 1:
        edit(message, f'`{get_translation("spamWrong")}`')
        return
    message.delete()

    if not spam_allowed():
        return

    for text in tspam.replace(' ', ''):
        reply(message, text)
        count = increment_spam_count()
        if not count:
            break

    send_log(get_translation('tspamLog'))
Esempio n. 15
0
def afk_on_pm(message):
    if PM_AUTO_BAN:
        try:
            from sedenecem.sql.pm_permit_sql import is_approved

            apprv = is_approved(message.from_user.id)
        except BaseException:
            apprv = True
    else:
        apprv = True
    if apprv and TEMP_SETTINGS['IS_AFK']:
        me = TEMP_SETTINGS['ME']
        if message.from_user.id not in TEMP_SETTINGS['AFK_USERS']:
            if 'AFK_REASON' in TEMP_SETTINGS:
                reply(
                    message,
                    get_translation(
                        "afkMessage2",
                        [
                            '**', me.first_name, me.id, '`',
                            TEMP_SETTINGS['AFK_REASON']
                        ],
                    ),
                )
            else:
                reply(message, f"```{choice(AFKSTR)}```")
            TEMP_SETTINGS['AFK_USERS'].update({message.from_user.id: 1})
            TEMP_SETTINGS['COUNT_MSG'] = TEMP_SETTINGS['COUNT_MSG'] + 1
        else:
            if TEMP_SETTINGS['AFK_USERS'][message.from_user.id] % randint(
                    1, 2) == 0:
                if 'AFK_REASON' in TEMP_SETTINGS:
                    reply(
                        message,
                        get_translation(
                            "afkMessage2",
                            [
                                '**',
                                me.first_name,
                                me.id,
                                '`',
                                TEMP_SETTINGS['AFK_REASON'],
                            ],
                        ),
                    )
                else:
                    reply(message, f"```{choice(AFKSTR)}```")
                TEMP_SETTINGS['AFK_USERS'][message.from_user.id] = (
                    TEMP_SETTINGS['AFK_USERS'][message.from_user.id] + 1)
                TEMP_SETTINGS['COUNT_MSG'] = TEMP_SETTINGS['COUNT_MSG'] + 1
            else:
                TEMP_SETTINGS['AFK_USERS'][message.from_user.id] = (
                    TEMP_SETTINGS['AFK_USERS'][message.from_user.id] + 1)
                TEMP_SETTINGS['COUNT_MSG'] = TEMP_SETTINGS['COUNT_MSG'] + 1
    raise ContinuePropagation
def mention_afk(msg):
    me = TEMP_SETTINGS['ME']
    mentioned = msg.mentioned
    rep_m = msg.reply_to_message
    if mentioned or rep_m and rep_m.from_user and rep_m.from_user.id == me.id:
        if TEMP_SETTINGS['IS_AFK']:
            if msg.from_user.id not in TEMP_SETTINGS['AFK_USERS']:
                if 'AFK_REASON' in TEMP_SETTINGS:
                    reply(
                        msg,
                        get_translation(
                            "afkMessage2",
                            [
                                '**',
                                me.first_name,
                                me.id,
                                '`',
                                TEMP_SETTINGS['AFK_REASON'],
                            ],
                        ),
                    )
                else:
                    reply(msg, f"```{choice(AFKSTR)}```")
                TEMP_SETTINGS['AFK_USERS'].update({msg.from_user.id: 1})
                TEMP_SETTINGS['COUNT_MSG'] = TEMP_SETTINGS['COUNT_MSG'] + 1
            else:
                if TEMP_SETTINGS['AFK_USERS'][msg.from_user.id] % randint(1, 2) == 0:
                    if 'AFK_REASON' in TEMP_SETTINGS:
                        reply(
                            msg,
                            get_translation(
                                "afkMessage2",
                                [
                                    '**',
                                    me.first_name,
                                    me.id,
                                    '`',
                                    TEMP_SETTINGS['AFK_REASON'],
                                ],
                            ),
                        )
                    else:
                        reply(msg, f"```{choice(AFKSTR)}```")
                    TEMP_SETTINGS['AFK_USERS'][msg.from_user.id] = (
                        TEMP_SETTINGS['AFK_USERS'][msg.from_user.id] + 1
                    )
                    TEMP_SETTINGS['COUNT_MSG'] = TEMP_SETTINGS['COUNT_MSG'] + 1
                else:
                    TEMP_SETTINGS['AFK_USERS'][msg.from_user.id] = (
                        TEMP_SETTINGS['AFK_USERS'][msg.from_user.id] + 1
                    )
                    TEMP_SETTINGS['COUNT_MSG'] = TEMP_SETTINGS['COUNT_MSG'] + 1
    raise ContinuePropagation
Esempio n. 17
0
def filter_incoming(message):
    if message.from_user and message.from_user.is_self:
        message.continue_propagation()

    name = message.text
    if not name:
        message.continue_propagation()

    try:
        from sedenecem.sql.filters_sql import get_filters
    except BaseException:
        message.continue_propagation()

    try:
        filters = get_filters(message.chat.id)
    except BaseException:
        message.continue_propagation()

    if not filters:
        message.continue_propagation()

    for trigger in filters:
        pro = fullmatch(trigger.keyword, name, flags=IGNORECASE)
        if pro:
            if trigger.f_mesg_id:
                msg_o = get_messages(LOG_ID, msg_ids=int(trigger.f_mesg_id))
                if msg_o and len(msg_o) > 0 and not msg_o[-1].empty:
                    msg = msg_o[-1]
                    reply_msg(message, msg)
                else:
                    edit(message, f'`{get_translation("filterResult")}`')
            elif trigger.reply:
                reply(message, trigger.reply)
            else:
                edit(message, f'`{get_translation("wrongFilter")}`')

    message.continue_propagation()
def spam(message):
    spam = extract_args(message)
    if len(spam) < 1:
        edit(message, f'`{get_translation("spamWrong")}`')
        return
    arr = spam.split()
    if not arr[0].isdigit():
        edit(message, f'`{get_translation("spamWrong")}`')
        return

    message.delete()

    if not spam_allowed():
        return

    count = int(arr[0])
    text = spam.replace(arr[0], '', 1).strip()
    for i in range(0, count):
        reply(message, text)
        limit = increment_spam_count()
        if not limit:
            break

    send_log(get_translation('spamLog'))
Esempio n. 19
0
def spam(message):
    spam = extract_args(message)
    if len(spam) < 1:
        edit(message, f'`{get_translation("spamWrong")}`')
        return
    arr = spam.split()
    if not arr[0].isdigit():
        edit(message, f'`{get_translation("spamWrong")}`')
        return

    message.delete()

    if not spam_allowed():
        return

    miktar = int(arr[0])
    metin = spam.replace(arr[0], '', 1).strip()
    for i in range(0, miktar):
        reply(message, metin)
        count = increment_spam_count()
        if not count:
            break

    send_log(f'{get_translation("spamLog")}')
Esempio n. 20
0
def purgeme(client, message):
    count = extract_args(message)
    if not count.isdigit():
        return edit(message, f'`{get_translation("purgemeUsage")}`')
    i = 1

    itermsg = client.get_history(message.chat.id)
    for message in itermsg:
        if i > int(count) + 1:
            break
        i = i + 1
        message.delete()

    smsg = reply(message, get_translation('purgeResult', ['**', '`', str(count)]))
    send_log(get_translation('purgeLog', ['**', '`', str(count)]))
    sleep(2)
    i = 1
    smsg.delete()
Esempio n. 21
0
def mention_afk(mention):
    me = mel[0]
    if mention.mentioned or mention.reply_to_message and mention.reply_to_message.from_user and mention.reply_to_message.from_user.id == me.id:
        if TEMP_SETTINGS['IS_AFK']:
            if mention.from_user.id not in TEMP_SETTINGS['AFK_USERS']:
                if 'AFK_REASON' in TEMP_SETTINGS:
                    reply(
                        mention, get_translation(
                            "afkMessage2", [
                                '**', me.first_name, me.id,
                                '`', TEMP_SETTINGS['AFK_REASON']]))
                else:
                    reply(mention, f"```{choice(AFKSTR)}```")
                TEMP_SETTINGS['AFK_USERS'].update({mention.from_user.id: 1})
                TEMP_SETTINGS['COUNT_MSG'] = TEMP_SETTINGS['COUNT_MSG'] + 1
            else:
                if TEMP_SETTINGS['AFK_USERS'][
                        mention.from_user.id] % randint(
                        2, 4) == 0:
                    if 'AFK_REASON' in TEMP_SETTINGS:
                        reply(
                            mention, get_translation(
                                "afkMessage2", [
                                    '**', me.first_name, me.id,
                                    '`', TEMP_SETTINGS['AFK_REASON']]))
                    else:
                        reply(mention, f"```{choice(AFKSTR)}```")
                    TEMP_SETTINGS['AFK_USERS'][
                        mention.from_user.id] = TEMP_SETTINGS['AFK_USERS'][
                        mention.from_user.id] + 1
                    TEMP_SETTINGS['COUNT_MSG'] = TEMP_SETTINGS['COUNT_MSG'] + 1
                else:
                    TEMP_SETTINGS['AFK_USERS'][
                        mention.from_user.id] = TEMP_SETTINGS['AFK_USERS'][
                        mention.from_user.id] + 1
                    TEMP_SETTINGS['COUNT_MSG'] = TEMP_SETTINGS['COUNT_MSG'] + 1
    raise ContinuePropagation
Esempio n. 22
0
def upstream(ups):
    edit(ups, f'`{get_translation("updateCheck")}`')
    conf = extract_args(ups)
    off_repo = REPO_URL
    force_update = False

    try:
        txt = f'`{get_translation("updateFailed")}`\n\n'
        txt += f'**{get_translation("updateLog")}**\n'
        repo = Repo()
    except NoSuchPathError as error:
        edit(ups, get_translation('updateFolderError', [txt, '`', error]))
        repo.__del__()
        return
    except GitCommandError as error:
        edit(ups, get_translation('updateFolderError', [txt, '`', error]))
        repo.__del__()
        return
    except InvalidGitRepositoryError as error:
        if conf != 'now':
            edit(ups, get_translation('updateGitNotFound', [error]))
            return
        repo = Repo.init()
        origin = repo.create_remote('upstream', off_repo)
        origin.fetch()
        force_update = True
        repo.create_head('seden', origin.refs.seden)
        repo.heads.seden.set_tracking_branch(origin.refs.seden)
        repo.heads.seden.checkout(True)

    ac_br = repo.active_branch.name
    if ac_br != 'seden':
        edit(ups, get_translation('updateFolderError', ['**', ac_br]))
        repo.__del__()
        return

    try:
        repo.create_remote('upstream', off_repo)
    except BaseException:
        pass

    ups_rem = repo.remote('upstream')
    ups_rem.fetch(ac_br)

    changelog = gen_chlog(repo, f'HEAD..upstream/{ac_br}')

    if not changelog and not force_update:
        edit(ups, get_translation('updaterUsingLatest', ['**', '`', ac_br]))
        repo.__del__()
        return

    if conf != 'now' and not force_update:
        if len(changelog) > 4096:
            edit(ups, f'`{get_translation("updateOutput")}`')
            file = open('changelog.txt', 'w+')
            file.write(changelog)
            file.close()
            reply_doc(ups, ups.chat.id, 'changelog.txt',
                      delete_after_send=True)
        else:
            edit(ups, get_translation(
                'updaterHasUpdate', ['**', '`', ac_br, changelog]))
        reply(ups, get_translation('updateNow', ['**', '`']))
        return

    if force_update:
        edit(ups, f'`{get_translation("updateForceSync")}`')
    else:
        edit(ups, f'`{get_translation("updateSedenBot")}`')

    if HEROKU_KEY:
        heroku = from_key(HEROKU_KEY)
        heroku_app = None
        heroku_applications = heroku.apps()
        if not HEROKU_APPNAME:
            edit(ups, f'`{get_translation("updateHerokuAppName")}`')
            me[1] = False
            repo.__del__()
            return
        for app in heroku_applications:
            if app.name == HEROKU_APPNAME:
                heroku_app = app
                break
        if heroku_app is None:
            edit(ups, f'`{get_translation("updateHerokuAppName", [txt])}`')
            me[1] = False
            repo.__del__()
            return
        edit(ups, f'`{get_translation("updateBotUpdating")}`')
        ups_rem.fetch(ac_br)
        repo.git.reset('--hard', 'FETCH_HEAD')
        heroku_git_url = heroku_app.git_url.replace(
            'https://', 'https://*****:*****@')
        if 'heroku' in repo.remotes:
            remote = repo.remote('heroku')
            remote.set_url(heroku_git_url)
        else:
            remote = repo.create_remote('heroku', heroku_git_url)
        try:
            remote.push(refspec='HEAD:refs/heads/master', force=True)
        except GitCommandError as error:
            edit(ups, get_translation('updaterGitError', ['`', txt, error]))
            repo.__del__()
            return
        edit(ups, f'`{get_translation("updateComplete")}`')
        try:
            heroku_app.scale_formation_process('seden', 1)
        except BaseException:
            pass
    else:
        try:
            ups_rem.pull(ac_br)
        except GitCommandError:
            repo.git.reset('--hard', 'FETCH_HEAD')
        update_requirements()
        edit(ups, f'`{get_translation("updateLocalComplate")}`')

    try:
        app.terminate()
    except Exception:
        pass

    execl(executable, executable, *argv)
Esempio n. 23
0
def permitpm(client, message):
    if not PM_AUTO_BAN:
        message.continue_propagation()
    else:
        if auto_accept(client, message) or message.from_user.is_self:
            message.continue_propagation()

        if message.chat.id != 777000:
            try:
                from sedenecem.sql.pm_permit_sql import is_approved
            except BaseException:
                pass

            apprv = is_approved(message.chat.id)
            notifsoff = is_muted(-1)

            if not apprv and message.text != UNAPPROVED_MSG:
                if message.chat.id in TEMP_SETTINGS['PM_LAST_MSG']:
                    prevmsg = TEMP_SETTINGS['PM_LAST_MSG'][message.chat.id]
                    if message.text != prevmsg:
                        for message in _find_unapproved_msg(client, message.chat.id):
                            message.delete()
                        if TEMP_SETTINGS['PM_COUNT'][message.chat.id] < (
                            PM_MSG_COUNT - 1
                        ):
                            ret = reply(message, UNAPPROVED_MSG)
                            TEMP_SETTINGS['PM_LAST_MSG'][message.chat.id] = ret.text
                else:
                    ret = reply(message, UNAPPROVED_MSG)
                    if ret.text:
                        TEMP_SETTINGS['PM_LAST_MSG'][message.chat.id] = ret.text

                if notifsoff:
                    client.read_chat_history(message.chat.id)

                if message.chat.id not in TEMP_SETTINGS['PM_COUNT']:
                    TEMP_SETTINGS['PM_COUNT'][message.chat.id] = 1
                else:
                    TEMP_SETTINGS['PM_COUNT'][message.chat.id] = (
                        TEMP_SETTINGS['PM_COUNT'][message.chat.id] + 1
                    )

                if TEMP_SETTINGS['PM_COUNT'][message.chat.id] > (PM_MSG_COUNT - 1):
                    reply(message, f'`{get_translation("pmpermitBlock")}`')

                    try:
                        del TEMP_SETTINGS['PM_COUNT'][message.chat.id]
                        del TEMP_SETTINGS['PM_LAST_MSG'][message.chat.id]
                    except BaseException:
                        pass

                    client.block_user(message.chat.id)
                    peer: InputPeerUser = client.resolve_peer(message.chat.id)
                    client.invoke(ReportSpam(peer=peer))

                    send_log(
                        get_translation(
                            'pmpermitLog', [message.chat.first_name, message.chat.id]
                        )
                    )

    message.continue_propagation()