def wiki(message):
    match = extract_args(message)
    if len(match) < 1:
        edit(message, f'`{get_translation("wrongCommand")}`')
        return
    set_lang(SEDEN_LANG)
    match = extract_args(message)
    try:
        summary(match)
    except DisambiguationError as error:
        edit(message, get_translation('wikiError', [error]))
        return
    except PageError as pageerror:
        edit(message, get_translation('wikiError2', [pageerror]))
        return
    result = summary(match)
    if len(result) >= 4096:
        file = open('wiki.txt', 'w+')
        file.write(result)
        file.close()
        reply_doc(message, 'wiki.txt',
                  caption=f'`{get_translation("outputTooLarge")}`')
        if path.exists('wiki.txt'):
            remove('wiki.txt')
        return
    edit(message, get_translation('sedenQuery', ['**', '`', match, result]))

    send_log(get_translation('wikiLog', ['`', match]))
Beispiel #2
0
def ocr(message):
    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)
def ocr(client, message):
    if not OCR_APIKEY:
        edit(
            message, get_translation(
                "ocrApiMissing", [
                    '**', 'OCR Space', '`']), preview=False)
        return
    match = extract_args(message)
    if len(match) < 1:
        edit(message, f'`{get_translation("wrongCommand")}`')
        return
    edit(message, f'`{get_translation("ocrReading")}`')
    if not path.isdir(DOWNLOAD_DIRECTORY):
        makedirs(DOWNLOAD_DIRECTORY)
    lang_code = extract_args(message)
    downloaded_file_name = client.download_media(
        message.reply_to_message, DOWNLOAD_DIRECTORY)
    test_file = ocr_file(filename=downloaded_file_name,
                         language=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)
def urbandictionary(message):
    match = extract_args(message)
    if len(match) < 1:
        edit(message, f'`{get_translation("wrongCommand")}`')
        return
    edit(message, f'`{get_translation("processing")}`')
    query = extract_args(message)
    try:
        define(query)
    except HTTPError:
        edit(message, get_translation('udResult', ['**', query]))
        return
    mean = define(query)
    deflen = sum(len(i) for i in mean[0]['def'])
    exalen = sum(len(i) for i in mean[0]['example'])
    meanlen = deflen + exalen
    if int(meanlen) >= 0:
        if int(meanlen) >= 4096:
            edit(message, f'`{get_translation("outputTooLarge")}`')
            file = open('urbandictionary.txt', 'w+')
            file.write('Query: ' + query + '\n\nMeaning: ' + mean[0]['def'] +
                       '\n\n' + 'Örnek: \n' + mean[0]['example'])
            file.close()
            reply_doc(message, 'urbandictionary.txt',
                      caption=f'`{get_translation("outputTooLarge")}`')
            if path.exists('urbandictionary.txt'):
                remove('urbandictionary.txt')
            message.delete()
            return
        edit(message, get_translation('sedenQueryUd', [
             '**', '`', query, mean[0]['def'], mean[0]['example']]))
    else:
        edit(message, get_translation('udNoResult', ['**', query]))
Beispiel #5
0
def device(message):
    textx = message.reply_to_message
    codename = extract_args(message)
    if codename:
        pass
    elif textx:
        codename = textx.text
    else:
        edit(message, f'`{get_translation("deviceUsage")}`')
        return
    data = loads(
        get('https://raw.githubusercontent.com/androidtrackers/'
            'certified-android-devices/master/by_device.json').text)
    results = data.get(codename)
    if results:
        reply = "{}\n".format(get_translation('deviceSearch',
                                              ['**', codename]))
        for item in results:
            reply += get_translation(
                'deviceSearchResultChild',
                ['**', item['brand'], item['name'], item['model']],
            )
    else:
        reply = get_translation('deviceError', ['`', codename])
    edit(message, reply)
Beispiel #6
0
def upload(message):
    args = extract_args(message)

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

    def progress(current, total):
        edit(
            message,
            get_translation(
                'updownUpload',
                ['`', '(½{:.2f})'.format(current * 100 / total), args]))

    if isfile(args):
        try:
            edit(message, get_translation('updownUpload', ['`', '', args]))
            reply_doc(message, args, progress=progress)
            edit(message, f'`{get_translation("uploadFinish")}`')
        except Exception as e:
            edit(message, f'`{get_translation("uploadError")}`')
            raise e

        return

    edit(message, f'`{get_translation("uploadFileError")}`')
Beispiel #7
0
def username(client, message):
    newusername = extract_args(message)
    try:
        client.send(account.UpdateUsername(username=newusername))
        edit(message, f'`{USERNAME_SUCCESS}`')
    except UsernameOccupied:
        edit(message, f'`{USERNAME_TAKEN}`')
Beispiel #8
0
def havadurumu(message):
    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
def lang(message):
    arr = extract_args(message).split(' ', 1)

    if len(arr) != 2:
        edit(message, f'`{get_translation("wrongCommand")}`')
        return

    util = arr[0].lower()
    arg = arr[1].lower()
    if util == 'trt':
        scraper = get_translation('scraper1')
        global TRT_LANG
        if arg in LANGUAGES:
            TRT_LANG = arg
            LANG = LANGUAGES[arg]
        else:
            edit(message, get_translation('scraperTrt', ['`', LANGUAGES]))
            return
    elif util == 'tts':
        scraper = get_translation('scraper2')
        global TTS_LANG
        if arg in tts_langs():
            TTS_LANG = arg
            LANG = tts_langs()[arg]
        else:
            edit(message, get_translation('scraperTts', ['`', tts_langs()]))
            return
    edit(message, get_translation('scraperResult',
                                  ['`', scraper, LANG.title()]))

    send_log(get_translation('scraperLog', ['`', scraper, LANG.title()]))
def ddgo(message):
    query = extract_args(message)
    if len(query) < 1:
        edit(message, f'`{get_translation("wrongCommand")}`')
        return
    req = get(
        f'https://duckduckgo.com/lite?q={query}',
        headers={
            'User-Agent':
            'Mozilla/5.0 (X11; Linux x86_64)'
            'AppleWebKit/537.36 (KHTML, like Gecko)'
            'Chrome/81.0.4044.138 Safari/537.36',
            'Content-Type':
            'text/html',
        },
    )
    soup = BeautifulSoup(req.text, 'html.parser')
    res1 = soup.findAll('table', {'border': 0})
    res1 = res1[-1].findAll('tr')

    match = do_ddsearch(res1)
    edit(
        message,
        get_translation('googleResult', ['**', '`', query, match]),
        preview=False,
    )
    send_log(get_translation('ddgoLog', [query]))
Beispiel #11
0
def copypasta(message):
    textx = message.reply_to_message
    copypasta = extract_args(message)

    if len(copypasta) > 0:
        pass
    elif textx:
        copypasta = textx.text
    else:
        edit(message, f'`{get_translation("cpUsage")}`')
        return

    reply_text = choice(EMOJIS)
    b_char = choice(copypasta).lower()
    for owo in copypasta:
        if owo == ' ':
            reply_text += choice(EMOJIS)
        elif owo in EMOJIS:
            reply_text += owo
            reply_text += choice(EMOJIS)
        elif owo.lower() == b_char:
            reply_text += '🅱️'
        else:
            if bool(getrandbits(1)):
                reply_text += owo.upper()
            else:
                reply_text += owo.lower()
    reply_text += choice(EMOJIS)
    edit(message, reply_text)
Beispiel #12
0
def copypasta(message):
    textx = message.reply_to_message
    copypasta = extract_args(message)

    if len(copypasta) > 0:
        pass
    elif textx:
        copypasta = textx.text
    else:
        edit(message, '`😂Bana💯BIR✌️mE🅱️In👐Ver👏`')
        return

    reply_text = choice(EMOJIS)
    b_char = choice(copypasta).lower()
    for owo in copypasta:
        if owo == " ":
            reply_text += choice(EMOJIS)
        elif owo in EMOJIS:
            reply_text += owo
            reply_text += choice(EMOJIS)
        elif owo.lower() == b_char:
            reply_text += "🅱️"
        else:
            if bool(getrandbits(1)):
                reply_text += owo.upper()
            else:
                reply_text += owo.lower()
    reply_text += choice(EMOJIS)
    edit(message, reply_text)
def pip3(message):
    pipmodule = extract_args(message)
    if len(pipmodule) > 0:
        edit(message, f'`{get_translation("pipSearch")}`')
        pipsorgu = f"pip3 search {pipmodule}"
        from subprocess import PIPE, Popen
        islem = Popen(pipsorgu.split(),
                      stdout=PIPE,
                      stderr=PIPE,
                      universal_newlines=True)
        sonuc, _ = islem.communicate()

        if sonuc:
            if len(sonuc) > 4096:
                edit(message, f'`{get_translation("outputTooLarge")}`')
                file = open('pip3.txt', 'w+')
                file.write(sonuc)
                file.close()
                reply_doc(message, 'pip3.txt')
                remove('pip3.txt')
                return
            edit(message,
                 get_translation('sedenQuery', ['**', '`', pipsorgu, sonuc]))
        else:
            edit(
                message,
                get_translation(
                    'sedenQuery',
                    ['**', '`', pipsorgu,
                     get_translation('sedenZeroResults')]))
    else:
        edit(message, f'`{get_translation("pipHelp")}`')
def echo(message):
    args = extract_args(message)
    if len(args) > 0:
        message.delete()
        reply(message, args)
    else:
        edit(message, f'`{get_translation("echoHelp")}`')
Beispiel #15
0
def getsticker(message):
    args = extract_args(message)
    reply = message.reply_to_message
    if not reply or not reply.sticker:
        edit(message, f'`{get_translation("replySticker")}`')
        return

    video = False
    photo = False

    if reply.sticker and reply.sticker.is_animated or reply.sticker.is_video:
        video = download_media_wc(reply)
    else:
        photo = download_media_wc(reply, f'{get_download_dir()}/sticker.png')
        image = Image.open(photo)
        photo = f'{get_download_dir()}/sticker.png'
        image.save(photo)

    reply_doc(
        reply,
        video or photo,
        caption=f'**Sticker ID:** `{reply.sticker.file_id}'
        f'`\n**Emoji**: `{reply.sticker.emoji or get_translation("notSet")}`'
        if args == '-v' else '',
        delete_after_send=True,
    )
    message.delete()
def autopic(client, message):
    args = extract_args(message)
    autopic = KEY_AUTOPP in TEMP_SETTINGS
    if args == 'disable':
        if autopic:
            del TEMP_SETTINGS[KEY_AUTOPP]
            edit(message, f'`{get_translation("autoppDisabled")}`')
            return
        else:
            edit(message, f'`{get_translation("autoppDisabledAlready")}`')
            return
    elif autopic:
        edit(message, f'`{get_translation("autoppEnabledAlready")}`')
        return

    TEMP_SETTINGS[KEY_AUTOPP] = True

    edit(message, f'`{get_translation("autoppProcess")}`')

    FONT_FILE = 'sedenecem/fonts/GoogleSans.ttf'

    downloaded_file_name = 'oldpp.png'
    photo = 'newpp.png'

    if path.exists(downloaded_file_name):
        LOGS.info(get_translation('autoppLog'))
    else:
        if AUTO_PP and len(AUTO_PP) > 0:
            with open(downloaded_file_name, 'wb') as load:
                load.write(get(AUTO_PP).content)
        else:
            try:
                profile_photo = client.get_profile_photos('me', limit=1)
                downloaded_file_name = download_media_wc(
                    profile_photo[0], downloaded_file_name)
            except BaseException:
                edit(message, f'`{get_translation("autoppConfig")}`')
                return

    edit(message, f'`{get_translation("autoppResult")}`')

    while KEY_AUTOPP in TEMP_SETTINGS:
        try:
            current_time = datetime.now().strftime('%H:%M')
            img = Image.open(downloaded_file_name)
            drawn_text = ImageDraw.Draw(img)
            fnt = ImageFont.truetype(FONT_FILE, 70)
            size = drawn_text.multiline_textsize(current_time, font=fnt)
            drawn_text.text(
                ((img.width - size[0]) / 2, (img.height - size[1])),
                current_time,
                font=fnt,
                fill=(255, 255, 255),
            )
            img.save(photo)
            client.set_profile_photo(photo=photo)
            remove(photo)
            sleep(60)
        except BaseException:
            return
Beispiel #17
0
def username(client, message):
    newusername = extract_args(message)
    try:
        client.send(functions.account.UpdateUsername(username=newusername))
        edit(message, USERNAME_SUCCESS)
    except UsernameOccupied:
        edit(message, USERNAME_TAKEN)
def barcode(message):
    input_str = extract_args(message)
    usage = get_translation('barcodeUsage', ['**', '`'])
    reply = message.reply_to_message
    if len(input_str) < 1 and not reply:
        edit(message, usage)
        return
    edit(message, f'`{get_translation("processing")}`')
    if reply:
        if reply.media:
            downloaded_file_name = download_media_wc(reply)
            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

    bar_code_type = 'code128'
    try:
        bar_code_mode_f = get(bar_code_type, qrmsg, writer=ImageWriter())
        filename = bar_code_mode_f.save(bar_code_type)
        reply_doc(message, filename, delete_after_send=True)
    except Exception as e:
        edit(message, str(e))
        return
    message.delete()
Beispiel #19
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
Beispiel #20
0
def payf(message):
    paytext = extract_args(message)
    pay = "{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}".format(
        paytext * 8, paytext * 8, paytext * 2, paytext * 2, paytext * 2,
        paytext * 6, paytext * 6, paytext * 2, paytext * 2, paytext * 2,
        paytext * 2, paytext * 2)
    edit(message, pay)
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
Beispiel #22
0
def add_filter(message):
    try:
        from sedenecem.sql.filters_sql import add_filter
    except BaseException:
        edit(message, f'`{get_translation("nonSqlMode")}`')
        return
    args = extract_args(message, markdown=True).split(' ', 1)
    if len(args) < 1 or len(args[0]) < 1:
        edit(message, f'`{get_translation("wrongCommand")}`')
        return
    keyword = args[0]
    string = args[1] if len(args) > 1 else ''
    msg = message.reply_to_message
    msg_id = None

    if len(string) < 1:
        if msg:
            if msg.text:
                string = msg.text.markdown
            else:
                string = None
                msg_o = forward(msg, LOG_ID)
                if not msg_o:
                    edit(message, f'`{get_translation("filterError")}`')
                    return
                msg_id = msg_o.message_id
                send_log(get_translation('filterLog', ['`', message.chat.id, keyword]))
        else:
            edit(message, f'`{get_translation("wrongCommand")}`')

    if add_filter(str(message.chat.id), keyword, string, msg_id):
        edit(message, get_translation('filterAdded', ['**', '`', keyword]))
    else:
        edit(message, get_translation('filterUpdated', ['**', '`', keyword]))
def wiki(message):
    args = extract_args(message)
    if len(args) < 1:
        edit(message, f'`{get_translation("wrongCommand")}`')
        return
    set_lang(SEDEN_LANG)
    try:
        summary(args)
    except DisambiguationError as error:
        edit(message, get_translation('wikiError', [error]))
        return
    except PageError as pageerror:
        edit(message, get_translation('wikiError2', [pageerror]))
        return
    result = summary(args)
    if len(result) >= 4096:
        file = open('wiki.txt', 'w+')
        file.write(result)
        file.close()
        reply_doc(
            message,
            'wiki.txt',
            caption=f'`{get_translation("outputTooLarge")}`',
            delete_after_send=True,
        )
    edit(message, get_translation('sedenQuery', ['**', '`', args, result]))

    send_log(get_translation('wikiLog', ['`', args]))
Beispiel #24
0
def ss(message):
    input_str = extract_args(message)
    link_match = match(r'\bhttp(.*)?://.*\.\S+', input_str)
    if link_match:
        link = link_match.group()
    else:
        edit(message, f'`{get_translation("ssUsage")}`')
        return
    edit(message, f'`{get_translation("processing")}`')
    driver = get_webdriver()
    driver.get(link)
    height = driver.execute_script(
        "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()
    message_id = message.message_id
    if message.reply_to_message:
        message_id = message.reply_to_message
    name = 'screenshot.png'
    with open(name, 'wb') as out:
        out.write(b64decode(im_png))
    edit(message, f'`{get_translation("ssUpload")}`')
    reply_doc(message, name, caption=input_str, delete_after_send=True)
def imeichecker(message):
    argv = extract_args(message)
    imei = argv.split(' ', 1)[0]
    edit(message, f'`{get_translation("processing")}`')
    print(len(imei))
    if len(imei) != 15:
        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
def online(client, message):
    args = extract_args(message)
    offline = ALWAYS_ONLINE in TEMP_SETTINGS
    if args == 'disable':
        if offline:
            del TEMP_SETTINGS[ALWAYS_ONLINE]
            edit(message, f'`{get_translation("alwaysOnlineOff")}`')
            return
        else:
            edit(message, f'`{get_translation("alwaysOnlineOff2")}`')
            return
    elif offline:
        edit(message, f'`{get_translation("alwaysOnline2")}`')
        return

    TEMP_SETTINGS[ALWAYS_ONLINE] = True

    edit(message, f'`{get_translation("alwaysOnline")}`')

    while ALWAYS_ONLINE in TEMP_SETTINGS:
        try:
            client.send(account.UpdateStatus(offline=False))
            sleep(5)
        except BaseException:
            return
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'))
Beispiel #28
0
def phh(message):
    get_phh = get(
        'https://api.github.com/repos/phhusson/treble_experimentations/releases/latest'
    ).json()
    search = extract_args(message)
    releases = '{}\n'.format(
        get_translation(
            'androidPhhHeader',
            ['`', "{} ".format(search) if len(search) > 0 else ""]))
    count = 0
    for i in range(len(get_phh)):
        try:
            name = get_phh['assets'][i]['name']
            if not name.endswith('img.xz'):
                continue
            elif search not in name:
                continue
            count += 1
            url = get_phh['assets'][i]['browser_download_url']
            releases += f'[{name}]({url})\n'
        except IndexError:
            continue

    if count < 1:
        releases = get_translation('phhError', ['`', '**', search])
    edit(message, releases, preview=False)
def save_note(message):
    try:
        from sedenecem.sql.notes_sql import add_note
    except AttributeError:
        edit(message, f'`{get_translation("nonSqlMode")}`')
        return
    args = extract_args(message, markdown=True).split(' ', 1)
    if len(args) < 1 or len(args[0]) < 1:
        edit(message, f'`{get_translation("wrongCommand")}`')
        return
    keyword = args[0]
    string = args[1] if len(args) > 1 else ''
    msg = message.reply_to_message
    msg_id = None

    if len(string) < 1:
        if msg:
            if msg.text:
                string = msg.text.markdown
            else:
                string = None
                msg_o = forward(msg, LOG_ID)
                if not msg_o:
                    edit(message, f'`{get_translation("noteError")}`')
                    return
                msg_id = msg_o.id
                send_log(get_translation('notesLog', ['`', message.chat.id, keyword]))
        else:
            edit(message, f'`{get_translation("wrongCommand")}`')

    if add_note(str(message.chat.id), keyword, string, msg_id) is False:
        edit(message, get_translation('notesUpdated', ['`', keyword]))
    else:
        edit(message, get_translation('notesAdded', ['`', keyword]))
Beispiel #30
0
def shippingTrack(message):
    edit(message, f"`{get_translation('processing')}`")
    trackId = extract_args(message)
    comp = parse_cmd(message.text)
    if not trackId or len(trackId.split(' ')) > 1:
        edit(message, f"`{get_translation('wrongCommand')}`")
        return
    match comp.replace('ç', 'c').replace('ü', 'u'):
        case 'yurtici':
            kargo_data = getShipEntity(company='yurtici', trackId=trackId)
        case 'aras':
            kargo_data = getShipEntity(company='aras', trackId=trackId)
        case 'ptt':
            kargo_data = getShipEntity(company='ptt', trackId=trackId)
        case 'mng':
            kargo_data = getShipEntity(company='mng', trackId=trackId)
        case 'ups':
            kargo_data = getShipEntity(company='ups', trackId=trackId)
        case 'surat':
            kargo_data = getShipEntity(company='surat', trackId=trackId)
        case 'trendyol':
            kargo_data = getShipEntity(company='trendyolexpress', trackId=trackId)
        case 'hepsijet':
            kargo_data = getShipEntity(company='hepsijet', trackId=trackId)
    if kargo_data:
        text = parseShipEntity(kargo_data)
        edit(message, text, parse=enums.ParseMode.HTML)
        return
    edit(message, f"`{get_translation('shippingNoResult')}`")