Example #1
0
def main():
    while True:
        print '\n'
        print 'Hey! Welcome to instaBot!'
        print 'Here are your menu options:'
        print "a.Get your own details\n"
        print "b.Get details of a user by username\n"

        choice = raw_input("Enter you choice: ")
        if choice == "a":
            self_info()
        elif choice == "b":
            insta_username = raw_input("Enter the username of the user: "******"c":
            insta_username = raw_input("Enter the username of the user: "******"j":
            exit()
        else:
            print "wrong choice"
Example #2
0
def reply_afk(update: Update, context: CallbackContext):
    bot = context.bot
    message = update.effective_message
    userc = update.effective_user
    userc_id = userc.id
    if message.entities and message.parse_entities(
        [MessageEntity.TEXT_MENTION, MessageEntity.MENTION]
    ):
        entities = message.parse_entities(
            [MessageEntity.TEXT_MENTION, MessageEntity.MENTION]
        )

        chk_users = []
        for ent in entities:
            if ent.type == MessageEntity.TEXT_MENTION:
                user_id = ent.user.id
                fst_name = ent.user.first_name

                if user_id in chk_users:
                    return
                chk_users.append(user_id)

            if ent.type != MessageEntity.MENTION:
                return

            user_id = get_user_id(message.text[ent.offset : ent.offset + ent.length])
            if not user_id:
                # Should never happen, since for a user to become AFK they must have spoken. Maybe changed username?
                return

            if user_id in chk_users:
                return
            chk_users.append(user_id)

            try:
                chat = bot.get_chat(user_id)
            except BadRequest:
                print("Error: Could not fetch userid {} for AFK module".format(user_id))
                return
            fst_name = chat.first_name

            check_afk(update, context, user_id, fst_name, userc_id)

    elif message.reply_to_message:
        user_id = message.reply_to_message.from_user.id
        fst_name = message.reply_to_message.from_user.first_name
        check_afk(update, context, user_id, fst_name, userc_id)
Example #3
0
def get_user_info(insta_username):
    user_id = get_user_id(insta_username)
    if user_id == None:
        print('User does not exist!')
        exit()

    request_url = BASE_URL + 'users/%s?access_token=%s' % (
        user_id, APP_ACCESS_TOKEN
    )  #url of user along with  usr id and your access token
    print('GET request url : %s' % (request_url))
    user_info = requests.get(
        request_url).json()  #fetch data from content of url query

    #check what is the result of query
    if user_info['meta']['code'] == 200:
        if len(user_info['data']):

            #fetch from json format and store in variable
            user = '******' % (user_info['data']['username'])
            id = 'ID: %s' % (user_info['data']['id'])
            follower = 'No.of followers: %s' % (
                user_info['data']['counts']['followed_by'])
            following = 'No. of people you are following: %s' % (
                user_info['data']['counts']['follows'])
            no_of_post = 'No. of posts: %s' % (
                user_info['data']['counts']['media'])

            #user information store in list
            info_list = [user, id, follower, following, no_of_post]
            for x in range(len(info_list)):
                print(info_list[x], end="   ")
                time.sleep(.700)  #wait .700 microsecond then loop again

        else:
            print('There is no data for this user!')
    else:
        print('Status code other than 200 received!')
Example #4
0
from get_user_id import *
get_user_id(raw_input("enter username:>"))
 def test_get_user_id(self):
     salt = "saltx".encode()
     salt_hex = salt.hex()
     with set_environment(CSCI_SALT=salt_hex):
         self.assertEqual(get_user_id("rpc0"), "eb740031")
         self.assertEqual(get_user_id("gorlins"), "a7ea3c11")