def subscribe(user_id): if not (is_user_subscribed(user_id)): user_database.add_user(user_id) send_message(user_id, "Success! I will now send you periodic messages :)") print("User added to the database!") print("Total users in database: " , user_database.get_total_users()) else: send_message(user_id, "You are already a subscriber!") print("User already in the database!") print("Total users in database: " , user_database.get_total_users())
def get_sudo_message(message): if message == "sudo gtu": response = user_database.get_total_users() elif message == "sudo gu": response = user_database.get_users() elif message == "sudo status": response = "Hey! botvid is working great! :)" else: response = "unrecognized admin command" return response
def unsubscribe(user_id): if (not is_user_subscribed(user_id)): send_message(user_id, "Sorry! You are not a subscriber") send_message(user_id, "send me 'subscribe' to subscribe for notifications from me") else: user_database.remove_user(user_id) send_message(user_id, "I won't send you updates anymore") send_message(user_id, "Sorry to see you go :(") print("User removed from the database!") print("Total users in database: " , user_database.get_total_users())
def get_sudo_message(message): if message == "sudo gtu": # 1) "sudo gtu" -> get total numbers of users from database response = user_database.get_total_users() elif message == "sudo gu": # 2) "sudo gu" -> return list of user_ids from database response = user_database.get_users() elif message == "sudo status": # 3) "sudo status" -> Is the bot working? response = "Hey, Roshan! BOTVID-19 is working great! :)" else: response = "unrecognized admin command" return response
import sys import user_database, state_database, scrape try: command = sys.argv[1] if command != "": if command == "get_total_users()": print("Total users: ", user_database.get_total_users()) elif command == "get_users()": print("Following is the user list:") for users in user_database.get_users(): print(users) elif command == "get_update_data()": print(state_database.get_tabulated_data()) elif command == "get_all_state_data()": print(state_database.get_all_state_data()) elif command == "help": print("* get_total_users() : prints total users in the database\n") print("* get_users() : prints a list of users in the database\n") print( "* get_update_data(): prints the current data to be sent to users\n" ) print( "* get_all_state_data(): prints everything stored in state database\n" ) print("* help: prints all available commandline inputs") else: print("* Sorry, the command you asked for is not listed\n") print("* use 'help' to get a list of available commands\n") except: print("* This script is used for checking database contents\n")