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)
示例#2
0
        return []

    json = loads(res)

    if '_id' not in json:
        return OFRPDeviceInfo(None, None)

    url = f'https://api.orangefox.download/v3/releases/?device_id={json["_id"]}'
    res = ofrp_get(url)

    out = []

    json2 = loads(res)
    json2 = json2['data']

    stables = [x for x in json2 if x['type'] == 'stable']
    betas = [x for x in json2 if x['type'] == 'beta']

    if len(stables):
        stable = [OFRPRelease(x) for x in stables]
        out += stable

    if len(betas):
        beta = [OFRPRelease(x) for x in betas]
        out += beta

    return OFRPDeviceInfo(json, out)


HELP.update({'android': get_translation('androidInfo')})
示例#3
0
            output += f'• [{printable}]({rectrack})\n'
            if tags:
                output += f'`{tags}`\n\n'

    edit(message, output, preview=False)


def gettags(track=None, isNowPlaying=None, playing=None):
    if isNowPlaying:
        tags = playing.get_top_tags()
        arg = playing
        if not tags:
            tags = playing.artist.get_top_tags()
    else:
        tags = track.track.get_top_tags()
        arg = track.track
    if not tags:
        tags = arg.artist.get_top_tags()
    tags = ''.join([' #' + t.item.__str__() for t in tags[:5]])
    tags = sub('^ ', '', tags)
    tags = sub(' ', '_', tags)
    tags = sub('_#', ' #', tags)
    return tags


def artist_and_song(track):
    return f'{track.track}'


HELP.update({'lastfm': get_translation('lastfmInfo')})
@sedenify(pattern='^.delayspam')
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'))


HELP.update({'spammer': get_translation('spamInfo')})
示例#5
0
    except BaseException:
        edit(message, f'`{get_translation("nonSqlMode")}`')
        return

    args = extract_args(message)
    if args.startswith('#'):
        get_note(message)
    elif args.startswith('$'):
        get_snip(message)
    else:
        edit(message, f"`{get_translation('wrongCommand')}`")


def is_muted(chat_id):
    try:
        from sedenecem.sql.keep_read_sql import is_kread
    except BaseException:
        return False

    kread = is_kread()
    if kread:
        for i in kread:
            if i.groupid == str(chat_id):
                return True

    return False


HELP.update({'chat': get_translation('chatInfo')})
HELP.update({'call': get_translation('callInfo')})
        edit(message, f'`{get_translation("wrongCommand")}`')
        return
    try:
        while True:
            response = post(
                f"https://m.turkiye.gov.tr/api2.php?p=imei-sorgulama&txtImei={imei}"
            ).json()
            if not response['data']['asyncFinished']:
                continue
            result = response['data']
            break
        reply_text = f"<b>Sorgu Tarihi</b> <code>{result['sorguTarihi']}</code>\n\
<b>IMEI:</b> <code>{result['imei'][:-5] + 5*'*'}</code>\n\
<b>Durum:</b> <code>{result['durum']}</code>\n\
<b>Cihaz:</b> <code>{result['markaModel']}</code>\n\n\
<b>Powered by </b><a href='https://github.com/TeamDerUntergang/Telegram-SedenUserBot'>Seden</a>♥"

        edit(message, reply_text, parse='HTML', preview=False)
    except Exception as e:
        raise e


HELP.update({'img': get_translation('imgInfo')})
HELP.update({'imeicheck': get_translation('imeiInfo')})
HELP.update({'carbon': get_translation('carbonInfo')})
HELP.update({'goolag': get_translation('googleInfo')})
HELP.update({'duckduckgo': get_translation('ddgoInfo')})
HELP.update({'wiki': get_translation('wikiInfo')})
HELP.update({'ud': get_translation('udInfo')})
HELP.update({'translator': get_translation('translatorInfo')})
        'return Math.max(document.body.scrollHeight,'
        'document.body.offsetHeight,'
        'document.documentElement.clientHeight,'
        'document.documentElement.scrollHeight,'
        'document.documentElement.offsetHeight);'
    )
    width = driver.execute_script(
        'return Math.max(document.body.scrollWidth,'
        'document.body.offsetWidth,'
        'document.documentElement.clientWidth,'
        'document.documentElement.scrollWidth,'
        'document.documentElement.offsetWidth);'
    )
    driver.set_window_size(width + 125, height + 125)
    wait_for = int(height / 1000)
    edit(message, f'`{get_translation("ssResult", [height, width, wait_for])}`')
    sleep(wait_for)
    im_png = driver.get_screenshot_as_base64()
    driver.close()
    name = 'screenshot.png'
    with open(name, 'wb') as out:
        out.write(b64decode(im_png))
    edit(message, f'`{get_translation("ssUpload")}`')
    reply_doc(
        reply if reply else message, name, caption=input_str, delete_after_send=True
    )
    message.delete()


HELP.update({'ss': get_translation('ssInfo')})
            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()


@sedenify(pattern='^.del$', compat=False, admin=True)
def delete(client, message):
    msg_src = message.reply_to_message
    if msg_src:
        if msg_src.from_user.id:
            try:
                client.delete_messages(message.chat.id, msg_src.id)
                message.delete()
                send_log(f'`{get_translation("delResultLog")}`')
            except BaseException:
                send_log(f'`{get_translation("delErrorLog")}`')
    else:
        edit(message, f'`{get_translation("wrongCommand")}`')


HELP.update({'purge': get_translation('purgeInfo')})
HELP.update({'purgeme': get_translation('purgemeInfo')})
HELP.update({'del': get_translation('delInfo')})
示例#9
0
        pass

    for best_guess in soup.findAll('div', attrs={'class': 'r5a77d'}):
        results['best_guess'] = best_guess.get_text()

    return results


def scam(results, lim):

    single = opener.open(results['similar_images']).read()
    decoded = single.decode('utf-8')

    imglinks = []
    counter = 0

    pattern = r'^,\[\"(.*[.png|.jpg|.jpeg])\",[0-9]+,[0-9]+\]$'
    oboi = findall(pattern, decoded, I | M)

    for imglink in oboi:
        counter += 1
        if not counter >= int(lim):
            imglinks.append(imglink)
        else:
            break

    return imglinks


HELP.update({'reverse': get_translation('reverseInfo')})
示例#10
0
        else:
            return edit(message, caption)


def LastSeen(bot, status):
    if bot:
        return 'BOT'
    elif status == 'online':
        return get_translation('statusOnline')
    elif status == 'recently':
        return get_translation('statusRecently')
    elif status == 'within_week':
        return get_translation('statusWeek')
    elif status == 'within_month':
        return get_translation('statusMonth')
    elif status == 'long_time_ago':
        return get_translation('statusLong')


def SudoCheck(user_id):
    if user_id in BRAIN:
        return get_translation('sudoCheck')


def BlacklistCheck(user_id):
    if user_id in BLACKLIST:
        return get_translation('blacklistCheck')


HELP.update({'whois': get_translation('whoisInfo')})
        out = ''
        for i in repos:
            out += f'{i}\n'
        return out

    edit(
        message,
        f'**{get_translation("gitUserInfo", [login])}**\n\n' +
        format_info(get_translation("gitUser"), user_id) +
        format_info(get_translation("gitAccount"), acc_type) +
        format_info(get_translation("gitName"), name) +
        format_info(get_translation("gitCompany"), company) +
        format_info(get_translation("gitWebsite"), blog) +
        format_info(get_translation("gitLocation"), location) +
        format_info(get_translation("gitMail"), email) +
        format_info(get_translation("gitBio"), bio) +
        format_info(get_translation("gitTwitter"), twitter) +
        format_info(get_translation("gitTotalRepo"), repo_count) +
        format_info(get_translation("gitTotalGist"), gist_count) +
        ((format_info(get_translation("gitFollowers"), followers) +
          format_info(get_translation("gitFollowing"), following))
         if acc_type == 'User' else '') +
        format_info(get_translation("gitCreationDate"), created) +
        format_info(get_translation("gitDateOfUpdate"), updated) +
        f'\n{get_translation("gitRepoList")}\n{get_repos()}',
        preview=False,
    )


HELP.update({'git': get_translation('gitInfo')})
示例#12
0
        f'**{get_translation("covidData")}**\n' +
        f'\n**{get_translation("covidDate")}** {result["tarih"]}\n' +
        f'\n**{get_translation("covidTotal")}**\n' +
        f'**{get_translation("covidTests")}** `{del_dots(result["toplam_test"])}`\n'
        +
        f'**{get_translation("covidCases")}** `{del_dots(result["toplam_hasta"])}`\n'
        +
        f'**{get_translation("covidDeaths")}** `{del_dots(result["toplam_vefat"])}`\n'
        +
        f'**{get_translation("covidSeriouslyill")}** `{del_dots(result["agir_hasta_sayisi"])}`\n'
        +
        f'**{get_translation("covidPneumonia")}** `%{result["hastalarda_zaturre_oran"]}`\n'
        +
        f'**{get_translation("covidHealed")}** `{del_dots(result["toplam_iyilesen"])}`\n'
        + f'\n**{get_translation("covidToday")}**\n' +
        f'**{get_translation("covidTests")}** `{del_dots(result["gunluk_test"])}`\n'
        +
        f'**{get_translation("covidCases")}** `{del_dots(result["gunluk_vaka"])}`\n'
        +
        f'**{get_translation("covidPatients")}** `{del_dots(result["gunluk_hasta"])}`\n'
        +
        f'**{get_translation("covidDeaths")}** `{del_dots(result["gunluk_vefat"])}`\n'
        +
        f'**{get_translation("covidHealed")}** `{del_dots(result["gunluk_iyilesen"])}`'
    )

    edit(message, sonuclar)


HELP.update({'covid19': get_translation('covidInfo')})
示例#13
0
            media_list = None
            with open(downloaded_file_name, 'rb') as file:
                media_list = file.readlines()
            qrmsg = ''
            for media in media_list:
                qrmsg += media.decode('UTF-8') + '\r\n'
            remove(downloaded_file_name)
        else:
            qrmsg = reply
    else:
        qrmsg = input_str

    try:
        qr = QRCode(version=1,
                    error_correction=constants.ERROR_CORRECT_L,
                    box_size=10,
                    border=4)
        qr.add_data(qrmsg)
        qr.make(fit=True)
        img = qr.make_image(fill_color='black', back_color='white')
        img.save('img_file.webp', 'PNG')
        reply_doc(message, 'img_file.webp', delete_after_send=True)
    except Exception as e:
        edit(message, str(e))
        return
    message.delete()


HELP.update({'qrcode': get_translation('makeqrInfo')})
HELP.update({'barcode': get_translation('barcodeInfo')})
示例#14
0
                ['**', '`',
                 str(reply_msg.from_user.id),
                 str(message.chat.id)]))
    except Exception:
        edit(message, f'`{get_translation("lydiaError3")}`')


@sedenify(incoming=True,
          outgoing=False,
          disable_edited=True,
          disable_notify=True)
def user(message):
    user_text = message.text
    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()


HELP.update({'lydia': get_translation('lydiaInfo')})
示例#15
0
                can_send_stickers=sticker,
                can_send_animations=gif,
                can_send_games=gamee,
                can_use_inline_bots=ainline,
                can_add_web_page_previews=webprev,
                can_send_polls=gpoll,
                can_change_info=changeinfo,
                can_invite_users=adduser,
                can_pin_messages=cpin,
            ),
        )
        edit(
            message,
            get_translation(
                'locksUnlockSuccess' if unlock else 'locksLockSuccess',
                ['`', kullanim]),
        )
    except BaseException as e:
        edit(message, get_translation('lockPerm', ['`', '**', str(e)]))
        return


def get_on_none(item, defval):
    if item is None:
        return defval

    return item


HELP.update({'locks': get_translation('lockInfo')})
示例#16
0
            'quiet': True,
            'logtostderr': False,
        }
        with YoutubeDL(ydl_opts) as ydl:
            try:
                video_info = ydl.extract_info(url, False)
                title = video_info['title']
                uploader = video_info['uploader']
                duration = int(video_info['duration'])
            except KeyError:
                uploader = get_translation('notFound')
                duration = None
            except BaseException as e:
                return edit(message, get_translation('banError', ['`', '**', e]))

            edit(message, get_translation('downloadYTAudio', ['**', title, '`']))

            ydl.download([url])
        edit(message, f'`{get_translation("uploadMedia")}`')
        reply_audio(
            message,
            f'{title}.mp3',
            caption=f"**{get_translation('videoUploader')}** `{uploader}`",
            duration=duration,
            delete_orig=True,
            delete_file=True,
        )


HELP.update({'youtubedl': get_translation('youtubedlInfo')})
示例#17
0
    heroku = from_key(HEROKU_KEY)
    heroku_app = None
    heroku_applications = heroku.apps()
    if not HEROKU_APPNAME:
        edit(
            message,
            f'`{get_translation("updateHerokuVariables", ["HEROKU_APPNAME "])}`',
        )

    for app in heroku_applications:
        if app.name == HEROKU_APPNAME:
            heroku_app = app
            break

    if heroku_app is None:
        edit(
            message,
            f'`{get_translation("updateHerokuVariables", ["HEROKU_APPNAME "])}`',
        )
        return

    filename = 'seden_heroku_log.txt'

    with open(filename, 'w+') as log:
        log.write(heroku_app.get_log())

    reply_doc(message, filename, delete_after_send=True, delete_orig=True)


HELP.update({'heroku': get_translation('herokuInfo')})
示例#18
0
def get_note(message):
    try:
        try:
            from sedenecem.sql.notes_sql import get_note
        except BaseException:
            edit(message, f'`{get_translation("nonSqlMode")}`')
            return

        notename = extract_args(message).split()[0][1:]
        note = get_note(message.chat.id, notename)

        if note:
            if note.f_mesg_id:
                msg_o = get_messages(LOG_ID, msg_ids=int(note.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("noteResult")}`')
            elif note.reply and len(note.reply) > 0:
                edit(message, note.reply)
            else:
                edit(message, f'`{get_translation("noteError2")}`')
        else:
            edit(message, f'`{get_translation("noteNoFound")}`')
    except BaseException:
        pass


HELP.update({'notes': get_translation('notesInfo')})
示例#19
0
            'https://androidfilehost.com/libs/otf/mirrors.otf.php',
            headers=headers,
            data=data,
            cookies=res.cookies)
        mirrors = req.json()['MIRRORS']
    except (JSONDecodeError, TypeError):
        reply += error
    if not mirrors or len(mirrors) < 1:
        reply += error
        return reply
    for item in mirrors:
        name = item['name']
        dl_url = item['url']
        reply += f'[{name}]({dl_url})\n'
    return reply


def useragent():
    req = get('https://user-agents.net/random')
    soup = BeautifulSoup(req.text, 'html.parser')
    agent = soup.find('article')
    if agent:
        agent = agent.find('li')
        if agent:
            return agent.find('a').text.replace('"', '')

    return 'Googlebot/2.1 (+http://www.google.com/bot.html)'


HELP.update({'direct': get_translation('directInfo')})
示例#20
0
        f'**[Pack](https://t.me/addstickers/{reply_chat.sticker_set_name})**'
        if reply_chat.sticker_set_name else f'`{get_translation("notSet")}`')
    members = reply_chat.members_count
    description = (f'\n{reply_chat.description}'
                   if reply_chat.description else get_translation('notSet'))

    caption = get_translation(
        'groupinfoResult',
        [
            '**',
            '`',
            title,
            chat_id,
            dc_id,
            group_type,
            members,
            online,
            sticker_pack,
            username,
            description,
        ],
    )
    if photo and media_perm:
        reply_img(reply or message, photo, caption=caption, delete_file=True)
        message.delete()
    else:
        edit(message, caption, preview=False)


HELP.update({'info': get_translation('groupInfo')})
示例#21
0
@sedenify(pattern='^.listgmute$')
def gmutelist(message):
    users = sql2.gmuted_users()
    if not users:
        return edit(message, f'`{get_translation("listEmpty")}`')
    gmute_list = f'**{get_translation("gmutedUsers")}**\n'
    count = 0
    for i in users:
        count += 1
        gmute_list += f'**{count} -** `{i.sender}`\n'
    return edit(message, gmute_list)


@sedenify(incoming=True, outgoing=False, compat=False)
def gmute_check(client, message):
    if sql2.is_gmuted(message.from_user.id):
        sleep(0.1)
        message.delete()

        try:
            user_id = message.from_user.id
            chat_id = message.chat.id
            client.restrict_chat_member(chat_id, user_id, ChatPermissions())
        except BaseException:
            pass

    message.continue_propagation()


HELP.update({'globals': get_translation('globalsInfo')})
示例#22
0
                                              ['**', ms]),
                      delete_orig=True)
    except Exception as exc:
        edit(
            message,
            get_translation('speedtestResultText', [
                '**', ms,
                convert_from_bytes(download_speed),
                convert_from_bytes(upload_speed), ping_time, i_s_p,
                i_s_p_rating, f'ERROR: {str(exc)}'
            ]))


def convert_from_bytes(size):
    power = 2**10
    _ = 0
    units = {
        0: '',
        1: 'kilobytes',
        2: 'megabytes',
        3: 'gigabytes',
        4: 'terabytes'
    }
    while size > power:
        size /= power
        _ += 1
    return f'{round(size, 2)} {units[_]}'


HELP.update({'speedtest': get_translation('speedtestInfo')})
示例#23
0
        dogbin = dogbin[len(format_view):]
    elif dogbin.startswith(format_normal):
        dogbin = dogbin[len(format_normal):]
    elif dogbin.startswith('del.dog/'):
        dogbin = dogbin[len('del.dog/'):]
    else:
        edit(message, f'`{get_translation("dogbinUrlError")}`')
        return

    resp = get(f'{DOGBIN_URL}raw/{dogbin}')

    try:
        resp.raise_for_status()
    except exceptions.HTTPError as HTTPErr:
        edit(message, get_translation('dogbinError', [str(HTTPErr)]))
        return
    except exceptions.Timeout as TimeoutErr:
        edit(message, get_translation('dogbinTimeOut', [str(TimeoutErr)]))
        return
    except exceptions.TooManyRedirects as RedirectsErr:
        edit(message,
             get_translation('dogbinTooManyRedirects', [str(RedirectsErr)]))
        return

    reply_text = get_translation('dogbinResult', ['`', resp.text])

    edit(message, reply_text)


HELP.update({'dogbin': get_translation('dogbinInfo')})
    temp_num = uniform(0.1, 0.4) if fry else 0.75
    img = Image.blend(img, overlay, temp_num)

    temp_num = randint(5, 300) if fry else 100
    img = ImageEnhance.Sharpness(img).enhance(temp_num)

    return img


def check_media(reply_message):
    data = False

    if reply_message and reply_message.media:
        if reply_message.photo:
            data = True
        elif reply_message.sticker and not reply_message.sticker.is_animated:
            data = True
        elif reply_message.document:
            name = reply_message.document.file_name
            if (
                name
                and '.' in name
                and name[name.find('.') + 1 :] in ['png', 'jpg', 'jpeg', 'webp']
            ):
                data = True

    return data


HELP.update({'deepfry': get_translation('deepfryInfo')})
示例#25
0
    args = extract_args(message)

    if len(args) < 1:
        CITY = DEFCITY
        if not CITY:
            edit(message, f'`{get_translation("weatherErrorCity")}`')
            return
    else:
        CITY = args

    if ',' in CITY:
        CITY = CITY[:CITY.find(',')].strip()

    try:
        req = get(f'http://wttr.in/{CITY}?mqT0',
                  headers={
                      'User-Agent': 'curl/7.66.0',
                      'Accept-Language': SEDEN_LANG
                  })
        data = req.text
        if '===' in data:
            raise Exception
        data = data.replace('`', '‛')
        edit(message, f'`{data}`')
    except Exception as e:
        edit(message, f'`{get_translation("weatherErrorServer")}`')
        raise e


HELP.update({'weather': get_translation('infoWeather')})
示例#26
0
        edit(message, f'`{get_translation("lyricsError2")}`')
        return

    edit(message, get_translation('lyricsSearch', ['`', artist, song]))

    try:
        songs = genius.search_song(song, artist)
    except TypeError:
        songs = None

    if not songs:
        edit(message, get_translation('lyricsNotFound', ['**', artist, song]))
        return
    if len(songs.lyrics) > 4096:
        edit(message, f'`{get_translation("lyricsOutput")}`')
        with open('lyrics.txt', 'w+') as f:
            f.write(
                get_translation('lyricsQuery',
                                ['', '', artist, song, songs.lyrics]))
        reply_doc(message, 'lyrics.txt', delete_after_send=True)
    else:
        edit(
            message,
            get_translation('lyricsQuery',
                            ['**', '`', artist, song, songs.lyrics]),
        )
    return


HELP.update({'lyrics': get_translation('lyricsInfo')})
示例#27
0
    edit(message, f'`{get_translation("pmBlocked")}`')

    try:
        from sedenecem.sql.pm_permit_sql import dissprove
        dissprove(uid)
    except BaseException:
        pass

    send_log(get_translation('pmBlockedLog', [name0, uid]))


@sedenify(pattern='^.unblock$', compat=False)
def unblockpm(client, message):
    if message.reply_to_message:
        reply = message.reply_to_message
        replied_user = reply.from_user
        if replied_user.is_self:
            edit(message, f'`{get_translation("cannotUnblockMyself")}`')
            return
        name0 = str(replied_user.first_name)
        uid = replied_user.id
        client.unblock_user(uid)
        edit(message, f'`{get_translation("pmUnblocked")}`')

        send_log(get_translation('pmUnblockedLog', [name0, replied_user.id]))
    else:
        edit(message, f'`{get_translation("pmUnblockedUsage")}`')


HELP.update({'profile': get_translation('profileInfo')})
示例#28
0

@sedenify(pattern='^.shg$')
def shg(message):
    edit(message, choice(SHGS))


@sedenify(pattern='^.run$')
def run(message):
    edit(message, choice(RUNS))


@sedenify(pattern='^.xda$')
def xda(message):
    """
    Copyright (c) @NaytSeyd, Quotes taken
    from friendly-telegram (https://gitlab.com/friendly-telegram) | 2020"""
    edit(message, choice(XDA_STRINGS))


@sedenify(pattern='^.f (.*)')
def payf(message):
    paytext = extract_args(message)
    pay = (f'{paytext * 8}\n{paytext * 8}\n{paytext * 2}\n{paytext * 2}'
           f'\n{paytext * 2}\n{paytext * 6}\n{paytext * 6}\n{paytext * 2}'
           f'\n{paytext * 2}\n{paytext * 2}\n{paytext * 2}\n{paytext * 2}')
    edit(message, pay)


HELP.update({'memes': get_translation('memesInfo')})
示例#29
0
    if not OCR_APIKEY:
        return edit(
            message, get_translation(
                'ocrApiMissing', [
                    '**', 'OCR Space', '`']), preview=False)

    match = extract_args(message)
    reply = message.reply_to_message

    if len(match) < 1:
        return edit(message, f'`{get_translation("wrongCommand")}`')

    if not reply.media:
        return edit(message, f'`{get_translation("wrongCommand")}`')

    edit(message, f'`{get_translation("ocrReading")}`')
    lang_code = extract_args(message)
    downloaded_file_name = download_media_wc(reply, sticker_orig=True)
    test_file = ocr_file(downloaded_file_name, lang_code)

    try:
        ParsedText = test_file['ParsedResults'][0]['ParsedText']
    except BaseException:
        edit(message, f'`{get_translation("ocrError")}`')
    else:
        edit(message, get_translation('ocrResult', ['`', ParsedText]))
    remove(downloaded_file_name)


HELP.update({'ocr': get_translation('ocrInfo')})
示例#30
0
def get_snip(message):
    try:
        try:
            from sedenecem.sql.snips_sql import get_snip
        except BaseException:
            edit(message, f'`{get_translation("nonSqlMode")}`')
            return

        snipname = extract_args(message).split()[0][1:]
        snip = get_snip(snipname)

        if snip:
            if snip.f_mesg_id:
                msg_o = get_messages(LOG_ID, msg_ids=int(snip.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("snipResult")}`')
            elif snip.reply and len(snip.reply) > 0:
                edit(message, snip.reply)
            else:
                edit(message, f'`{get_translation("snipError2")}`')
        else:
            edit(message, f'`{get_translation("snipNotFound")}`')
    except BaseException:
        pass


HELP.update({'snips': get_translation('snipInfo')})