Exemplo n.º 1
0
async def menu(message: types.Message):
    global user, userid, profile
    row = db.execute_one_query(
        conn, f'SELECT * FROM users WHERE user_id = "{message.from_user.id}"')
    msg = message.text
    if '/s/' in msg:
        await message.reply(key[row[1]][12])
    elif 'instagram.com/p/' in msg:
        SHORTCODE = msg.split('/p/')[1].split('/?')[0]
        post = Post.from_shortcode(L.context, SHORTCODE)
        if post.owner_profile.is_private == True:
            await message.reply(key[row[1]][1])
        else:
            await post_downloader(message, post=post)
    elif 'instagram.com/' in msg:
        user = msg.split('.com/')[1][0:-1]
        if '?' in msg: user = msg.split('.com/')[1].split('?')[0]
        profile = Profile.from_username(L.context, user)
        userid = profile.userid
        print(userid)
        if profile.is_private == True:
            await message.reply(key[row[1]][1])
        else:
            await post_downloader(message, posts=1)
    else:
        try:
            msg = msg.replace('@', '')
            profile = Profile.from_username(L.context, msg)
            userid = profile.userid
            if profile.is_private == True:
                await message.reply(key[row[1]][1])
            else:
                await post_downloader(message, posts=1)
        except:
            await message.reply(key[row[1]][2])
Exemplo n.º 2
0
def post_markup(id, post):
    row = db.execute_one_query(conn,
                               f'SELECT * FROM users WHERE user_id = "{id}"')
    post_info = types.InlineKeyboardMarkup(row_width=3)
    post_info.add(
        types.InlineKeyboardButton(text=f'{post.likes}❤', callback_data=f"p"),
        types.InlineKeyboardButton(text=f'{post.comments}💬',
                                   callback_data=f"p"),
        types.InlineKeyboardButton(text=key[row[1]][11],
                                   url=f"instagram.com/p/{post.shortcode}/"))
    return post_info
Exemplo n.º 3
0
async def post_downloader(message, post=0, posts=0):
    row = db.execute_one_query(
        conn, f'SELECT * FROM users WHERE user_id = "{message.from_user.id}"')
    if posts == 0:
        post_info = post_markup(message.from_user.id, post)
        if post.typename == 'GraphImage':
            await types.ChatActions.upload_photo()
            await bot.send_photo(message.chat.id,
                                 post.url,
                                 caption=post.caption,
                                 reply_markup=post_info)
        elif post.typename == 'GraphVideo':
            await types.ChatActions.upload_video()
            await bot.send_video(message.chat.id,
                                 post.video_url,
                                 caption=post.caption,
                                 reply_markup=post_info)
        elif post.typename == 'GraphSidecar':
            media = types.MediaGroup()
            for edge_number, sidecar_node in enumerate(
                    post.get_sidecar_nodes(), start=1):
                if sidecar_node.is_video:
                    await types.ChatActions.upload_video()
                    media.attach_video(sidecar_node.video_url)
                else:
                    await types.ChatActions.upload_photo()
                    media.attach_photo(sidecar_node.display_url)
            msg = await bot.send_media_group(message.chat.id, media)
            await msg[0].reply(post.caption, reply_markup=post_info)
    else:
        if profile.has_public_story: story = key[row[1]][3]
        else: story = key[row[1]][4]
        if profile.has_highlight_reels: high = key[row[1]][5]
        else: high = key[row[1]][6]
        info = types.InlineKeyboardMarkup(row_width=2)
        a = types.InlineKeyboardButton(
            text=f'{key[row[1]][7]} {profile.mediacount}',
            callback_data=f"posts-{profile.username}-0")
        b = types.InlineKeyboardButton(
            text=f'{key[row[1]][8]} {profile.followees}', callback_data='x')
        c = types.InlineKeyboardButton(
            text=f'{key[row[1]][9]} {profile.followers}', callback_data="x")
        d = types.InlineKeyboardButton(
            text=story, callback_data=f"stories-{profile.userid}-0")
        e = types.InlineKeyboardButton(
            text=high, callback_data=f"highlights-{profile.userid}-0")
        info.add(b, c, e, d, a)
        await bot.send_photo(
            message.chat.id,
            profile.profile_pic_url,
            caption=
            f'instagram.com/{profile.username}/\nBio:\n{profile.biography}',
            reply_markup=info)
Exemplo n.º 4
0
async def start(message: types.Message):
    row = db.execute_one_query(
        conn, f'SELECT * FROM users WHERE user_id = "{message.from_user.id}"')
    if row == None:
        db.execute_query(
            conn, F'INSERT INTO users VALUES ("{message.from_user.id}","en")')
    lang = types.InlineKeyboardMarkup(row_width=2).add(
        types.InlineKeyboardButton(text=f'Русский', callback_data="ru"),
        types.InlineKeyboardButton(text=f'English', callback_data='en'))
    await bot.send_message(message.chat.id,
                           'Hello, choose language :)',
                           reply_markup=lang)
Exemplo n.º 5
0
async def info_highlights(id):
    row = db.execute_one_query(conn,
                               f'SELECT * FROM users WHERE user_id = "{id}"')
    text = key[row[1]][10]
    hl_info = types.InlineKeyboardMarkup(row_width=3)
    i = 1
    for highlight in L.get_highlights(userid):
        hl_info.add(
            types.InlineKeyboardButton(
                text=f'{highlight.title[:15]} ({highlight.itemcount})\n',
                callback_data=f"highlight-{userid}-{i}"))
        i += 1
    await bot.send_message(id, text, reply_markup=hl_info)