Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from Instagram.classes import accounts
- from Instagram.classes.engagement_tools.followliker import Followliker
- from flask import Flask, render_template, request
- command_dictionary = {"get account info": lambda username: accounts.get_account_info(username),
- "add account": lambda username, password: accounts.add_account(username, password),
- "add": lambda: print('Available commands: \n'.join(["> {0}\n".format(command) for command in command_dictionary if "add" in command])),
- "remove account": lambda username, password: accounts.remove_account(username, password),
- "remove": lambda: print('Available commands: \n'.join(["> {0}\n".format(command) for command in command_dictionary if "remove" in command])),
- }
- def execute(usr_input):
- """ Finds and executes the appropriate command from the command dictionary based on user input """
- for entry in sorted(command_dictionary, key=len, reverse=True):
- split_entry = entry.split()
- split_input = usr_input.split()
- usr_commands = split_input[:len(split_entry)]
- if usr_commands == split_entry:
- """ user input has the correct operators for the entry function """
- entry_function_args = command_dictionary[entry].__code__.co_varnames
- usr_function_args = split_input[len(split_entry):]
- if len(usr_function_args) == len(entry_function_args):
- """ user input has the correct number of arguments for the entry function """
- command_dictionary[entry](*usr_function_args)
- break
- else:
- print("Incorrect arg format, function '", entry, "' takes args:", entry_function_args)
- break
- else:
- print("No command could be extracted from:", split_input)
- account = accounts.Account("SquatCatalog", "Kek666420")
- fl = Followliker(account)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement