def send(): form_data = request.form print form_data send_message(form_data["email"], form_data["password"]) return render_template("page1.html", email=form_data["email"])
def main(): data = bottle_request.json get_user(TOKEN) get_message(TOKEN,API_TOKEN,data) send_message(TOKEN) save_to_excel(sheet_name) if sys.platform == 'win32': os.system('cls') elif sys.platform == 'linux': os.system('clear') print(""" Refreshing ............ ) ( ( ) ) ) ( ( _______)_ .-'---------| ( C|/\/\/\/\/| '-./\/\/\/\/| '_________' '-------' """) return response
def send_individual_message(): number = request.form['individual_message_phonenumber'] message = request.form['individual_message_text'] print(number, message) if db_operations.check_if_contact_is_registered(db, metadata, number): send_message.send_message(number, message) return "ok"
def startchat(name, age, rating): showmenu = True #to display menu while showmenu: menuchoices = "What do you want to do?\n1) Add a status update\n" \ "2) Add a friend\n" \ "3) Send a secret message\n" \ "4) Read a secret message\n" \ "5) Read chats from a user\n" \ "6) Close the application\n" result = int(raw_input(menuchoices)) #validating the menuchoice if result == 1: statusmsg = addstatus() print colored("Your Current status is: " + statusmsg, 'green') elif result == 2: # action no_of_friends = add_friend() print colored("You have %d friends " % (no_of_friends), 'green') elif (result == 3): send_message() elif (result == 4): read_message() elif result == 5: read_chat() elif result == 6: showmenu = False else: print colored("Sorry invalid option ", 'red')
def message_everyone_roles(g): """ for every player in game. DM them their roles. """ u = UserMap() # player_role(g, player_id) all_alive = [(u.get(user_id=p_id, DM=True), player_role(g, p_id)) for p_id in players_in_game(g) if is_player_alive(g, p_id)] print(all_alive) for im, role in all_alive: if role=='v': nice=" Plain Villager" elif role=='w': nice=" Werewolf. *Awoooo!*" elif role=='s': nice=" Seer." elif role=='b': nice=" Bodyguard." send_message(nice, channel=im)
def callback_vote(): check_bool, yet_to_vote = check() print('checking vote') print(check_bool, yet_to_vote) if check_bool: check_g = get_game_state() send_message(player_vote(check_g, yet_to_vote, ['vote', 'pass'])[0])
def run(parsed): recip = get_recipient_id(parsed) if recip: body = parsed.get('~message', ['']) attach = False # TODO from send_message import send_message send_message(recip, body, attach)
def start_chat(name, age, rating, status): from globals import current_status_message if not (age > 12 and age < 50) : error_message = "Invalid age. Provide correct details." print (colored(error_message,"red")) else: welcome_message = "Authentication complete. Welcome\n\n" \ "Name : " + name + "\n" \ "Age: " + str(age) + "\n" \ "Rating: " + str(rating) + "\n" \ "Proud to have you on board\n" print welcome_message show_menu = True while show_menu: menu_choices = "What do you want to do? \n\n " \ "1. Add a status update \n " \ "2. Add a friend \n " \ "3. Send a secret message \n " \ "4. Read a secret message \n " \ "5. Read Chats from a user \n " \ "6. Close Application \n\n" result = int(raw_input(menu_choices)) if (result == 1): current_status_message = add_status(current_status_message) elif (result == 2): number_of_friends = add_friend() print 'You have %d friends' % (number_of_friends) elif(result == 3): send_message() elif (result == 4): read_message() elif(result == 5): read_chat_history() elif (result == 6): show_menu = False else: print (colored("wrong choice try again.", 'green')) exit()
def run(parsed): recips = parsed.get('~_PersonalName', []) if len(recips) != 1: return recip = recips[0] body = parsed.get('~message', [''])[0] attach = 'include_files' in parsed from send_message import send_message send_message(recip, body, attach)
def start_chat(name, age, rating, status): from send_message import send_message from read_message import read_message from globals import current_status_message from globals import friends from termcolor import colored # validating users details. error_message = None # variable for storing error messages. if not (age > 12 and age < 50) : # invalid age. error_message = ("Invalid age. Provide correct details.") print (error_message,'red') else: welcome_message = "Authentication complete. Welcome\n " \ "Name : " + name + "\n" \ "Age: " + str(age) + "\n" \ "Rating: " + str(rating) + "\n" \ "Proud to have you onboard" + "\n" if (rating > 4.0): welcome_message = welcome_message + "Great work" elif (rating >= 3.0): welcome_message = welcome_message + "Average" else: welcome_message = welcome_message + "Do some work to increase your's rating" print colored(welcome_message,'green') # displaying menu for user. show_menu = True while show_menu: menu_choices = "What do you want to do? \n " \ "1. Add a status update \n " \ "2. Add a friend \n " \ "3. Send a secret message \n " \ "4. Read a secret message \n " \ "5. Read Chats from a user \n " \ "6. Close Application \n" result = int(raw_input(menu_choices)) # validating users input if (result == 1): current_status_message = add_status(current_status_message) #action statement print("Your current status is:" + current_status_message,"blue") #action elif (result == 2): number_of_friends = add_friend() print ('You have %d friends' % (number_of_friends),'blue') elif(result == 3): send_message() elif(result == 4): read_message() elif(result == 6): # close application show_menu = False else: print ("Wrong choice. Try again.",'red')
def start_chat(spy): # updated variable #concatenation of name and salutation spy.name = spy.salutation + " " + spy.name # Age cannot be less than 18 or greater than 50 if 18 < spy.age < 50: #all details from users is taken nd message is displayed of authentication complete with his/her details print(colored("Authentication complete.", 'green')) print(colored("Welcome " + str(spy.name), "green")) print(colored("Your age:" + str(spy.age), "green")) print(colored("Your rating:" + str(spy.rating), "green")) print(colored("Bravo!Proud to have you on board.", "yellow")) print(colored("THANK YOU FOR YOUR DETAILS!", 'yellow')) show_menu = True #infinite loop is used till condition is satisified while show_menu: menu_choices = "What do you want to do? \n 1. Add a status update \n" \ " 2. Add a friend \n 3. Send a secret message \n " \ "4. Read a secret message \n 5. Read Chats from a user \n" \ " 6. Close Application \n" #here are the options what we can do in our application send,read msg etc # Taking the input of the choice menu_choice = raw_input(colored(menu_choices, "blue")) if len(menu_choice) > 0: menu_choice = int(menu_choice) if menu_choice == 1: # Set your current status spy.current_status_message = add_status() elif menu_choice == 2: # Add a new friend number_of_friends = add_friend() print 'You have %d friends' % number_of_friends elif menu_choice == 3: # Send a secret message send_message() elif menu_choice == 4: # Read the secret message sent by your friend read_message() elif menu_choice == 5: # Read the chat history read_chat() elif menu_choice == 6: # Close the app exit() # When the user chooses other than the menu choices. else: print(colored("That was a wrong choice.", 'red')) exit()
def run(self): old_titles = [line.rstrip('\n') for line in self.titles_file] new_titles = self.get_new_titles_from_source() titles = self.compare_old_and_new_titles(old_titles, new_titles) if len(titles) == 0: return msg = self.compose_message(titles) send_message.send_message(msg[0], msg[1]) self.update_titles(new_titles)
def start_chat(name, age, rating, status): from globals import current_status_message # age should be greater than 12 and less than 50. if not (age > 12 and age < 50): # invalid age. error_message = "Invalid age. Provide correct details." print(colored(error_message, "red")) else: # authentication complete # show all the spy details # show a greeting message. welcome_message = "Authentication complete. Welcome\n\n" \ "Name : " + name + "\n" \ "Age: " + str(age) + "\n" \ "Rating: " + str(rating) + "\n" \ "Proud to have you on board\n" print welcome_message # displaying menu for user. show_menu = True while show_menu: menu_choices = "What do you want to do? \n\n " \ "1. Add a status update \n " \ "2. Add a friend \n " \ "3. Send a secret message \n " \ "4. Read a secret message \n " \ "5. Read Chats from a user \n " \ "6. Close Application \n\n" result = int(raw_input(menu_choices)) # validating users input if (result == 1): # set your current status current_status_message = add_status(current_status_message) elif (result == 2): # add a new friend number_of_friends = add_friend() print 'You have %d friends' % (number_of_friends) elif (result == 3): # send a secret message send_message() elif (result == 4): # read the secret message sent by friend read_message() elif (result == 5): # read the chat history read_chat_history() elif (result == 6): # close application show_menu = False # if user chooses other than menu choices. else: print(colored("wrong choice try again.", 'green')) exit()
def start_chat(name, age, rating, status): # validating users details. error_message = None # variable for storing error messages. if not (age > 12 and age < 50): # invalid age. error_message = "Invalid age. Provide correct details." print colored(error_message,'red') else: welcome_message = "Authentication complete. Welcome\n" \ "Name : " + name + "\n" \ "Age: " + str(age) + "\n" \ "Rating: " + str(rating) + "\n" if rating>4.0: welcome_message=welcome_message+"You are awesome" elif rating>3.0: welcome_message=welcome_message+"Going Good" else: welcome_message=welcome_message+"Need Lots of Efforts" print colored(welcome_message,'green') # displaying menu for user. show_menu = True while show_menu: menu_choices = "What do you want to do ? \n" \ "1.Add status \n" \ "2.Add a friend \n" \ "3.Send a secret message \n" \ "4.Read a secret message \n" \ "5.Read chats \n" \ "6.Close Application \n" result = int(raw_input(menu_choices)) # validating users input if result == 1: # action current_status_message = add_status() print colored("Your Current status is: "+current_status_message,'green') elif result == 2: # action no_of_friends = add_friend() print colored("You have %d friends " % (no_of_friends),'green') elif(result ==3): send_message() elif(result ==4): read_message() elif result==5: read_chat() elif result == 6: # close application show_menu = False else: print colored("Wrong choice. Try again.",'red')
def dat(): if GPIO.input(PIN)==1: print("水不足夠" ) send_message.send_message(time) GPIO.cleanup() return 0 else: print("Water enough") GPIO.cleanup() return 1
def alert_contacts(): if request.method == 'GET': requestedName = 'tiger' #request.args.get('name') with open(CONTACTS_FILENAME, mode='r', encoding='utf-8') as contactsFile: contacts = contactsFile.read().split('\n') print(contacts) for contact in contacts: name, contact_1, contact_2 = contact.split() print(name, requestedName) if (name.toLower() == requestedName.toLower()): send_message(name, contact_1) send_message(name, contact_2) return "Success!"
def start_chat(name, age, rating, status): from globals import current_status_message welcome_message = "Authentication complete.\n" \ "Name : " + name + "\n" \ "Age: " + str(age) + "\n" \ "Rating: " + str(rating) + "\n" \ "Online: " + str(status) + "\n" \ "" cprint(welcome_message, 'magenta', attrs=['bold', 'underline']) # displaying menu for user. show_menu = True while show_menu: menu_choices = "What do you want to do? \n " \ "1. Add a status update \n " \ "2. Add a friend \n " \ "3. Send a secret message \n " \ "4. Read a secret message \n " \ "5. Read Chats from a user \n " \ "6. Close Application \n" flag = True while flag: try: result = int(raw_input(menu_choices)) flag = False except Exception: print "Invalid choice. Try again." else: # validating users input if (result == 1): current_status_message = add_status(current_status_message) elif (result == 2): number_of_friends = add_friend() cprint('You have %d friends' % (number_of_friends), 'yellow', attrs=['dark', 'underline', 'bold']) elif (result == 3): send_message() elif (result == 4): read_message() elif (result == 5): read_chat() elif (result == 6): print "THANK YOU. VISIT AGAIN" # close application exit() else: print "wrong choice try again."
def start_chat(name,age,rating,status): from globals import current_status_message #age should be less greater than 12 and less tah 50 if not (age >12 and age <50): print "Authentication failed Please Try again Later" else: Chat_flag=True while(Chat_flag): try: #choices are being given to the user Menu_choices = "what do u want to do ?\n"\ " 1. Add a status message ?\n"\ " 2. Add a friend ?\n"\ " 3. send a Secret Message.\n"\ " 4. read a secret message. \n"\ " 5. read chats from user.\n"\ " 6. Exit Application.\n" menu_choice=int(raw_input(Menu_choices)) if(menu_choice == 1): print "u entered status message block" #this will give user the access to add a status message current_status_message=add_status(current_status_message) elif(menu_choice == 2): print "u entered add a friend block" # this will give user the access to add a friend Total_friends=add_friend() print "Total no of friends u have ryt now is %d"%(Total_friends) elif (menu_choice == 3): print "u entered send a secret msg block" # this will give user the access to send a secret encrypted message send_message() elif (menu_choice == 4): # this will give user the access to read a secret decrypted message print "u entered read a secret msg block" read_message() elif (menu_choice == 5): print "u entered read chats from user block" # this will give user the access to read the chat with older history read_chat_history() elif (menu_choice == 6): #if user want to exit the application Chat_flag=False else: print "invalid input" except Exception: #exception is also used as it is a error prone area print "value can only be integer"
def start_chat(spy_name, spy_age, spy_rating, spy_status): current_staus = None spy_name = spy.salutation + " " + spy.name if spy_age > 12 and spy_age < 50: print( colored( "Authentication complete. Welcome " + spy_name + " age: " + str(spy_age) + " and rating of: " + str(spy_rating), "blue")) show_menu = True while show_menu: menu_choice = "What do you want to do? \n 1. Add a status update \n 2. Add a friend \n 3. Send a secret message \n 4. Read a secret message \n 5. Read Chats from a user \n 6. Close Application \n" menu_choice = raw_input(menu_choice) if len(menu_choice) > 0: menu_choice = int(menu_choice) if menu_choice == 1: print( colored("So,the spy wants to add a status....", "green")) current_status_message = raw_input("Add status..") current_status_message = add_status(current_status_message) elif menu_choice == 2: print( colored("So,the spy wants to add a friend....", "green")) number_of_friends = add_friend() print "You have %d friends" % (number_of_friends) elif menu_choice == 3: print( colored("Sshh...spy wants to send a secret message", "green")) send_message() elif menu_choice == 4: print( colored("You want to read the secret message", "green")) read_message() elif menu_choice == 5: print(colored("You want to read the chats", "green")) read_chat_history() elif menu_choice == 6: print(colored("Bye spy", "green")) show_menu = False else: print "Wrong choice"
def start_chat(name, age, rating, status): from globals import current_status_message # validating users details. error_message = None if not (age > 15 and age <= 50) : # invalid age. error_message = "Invalid age. Provide correct details." print error_message else: welcome_message = "Authentication complete. Welcome\n " \ "Name : " + name + "\n" \ "Age: " + str(age) + "\n" \ "Rating: " + str(rating) + "\n" \ "Glad to have you " print welcome_message # displaying menu for user. show_menu = True while show_menu: menu_choices = "What do you want to do? \n " \ "1. Add a status update \n " \ "2. Add a friend \n " \ "3. Send a secret message \n " \ "4. Read a secret message \n " \ "5. Read a chat from a user \n " \ "6. Close application \n " result = int(raw_input(menu_choices)) #validating users input if (result == 1): current_status_message = add_status(current_status_message) elif (result == 2): number_of_friends = add_friend() elif (result == 3): send_message() elif (result == 4): read_message() elif (result == 5): read_chats() elif(result == 6): #close application show_menu = False else: print "Wrong choices. Try again."
def start_chat(name, age, rating, status): from globals import current_status_message # validating users details. error_message = None if not (age > 15 and age <= 50): # invalid age. error_message = "Invalid age. Provide correct details." print error_message else: welcome_message = "Authentication complete. Welcome\n " \ "Name : " + name + "\n" \ "Age: " + str(age) + "\n" \ "Rating: " + str(rating) + "\n" \ "Glad to have you " print welcome_message # displaying menu for user. show_menu = True while show_menu: menu_choices = "What do you want to do? \n " \ "1. Add a status update \n " \ "2. Add a friend \n " \ "3. Send a secret message \n " \ "4. Read a secret message \n " \ "5. Read a chat from a user \n " \ "6. Close application \n " result = int(raw_input(menu_choices)) #validating users input if (result == 1): current_status_message = add_status(current_status_message) elif (result == 2): number_of_friends = add_friend() elif (result == 3): send_message() elif (result == 4): read_message() elif (result == 5): read_chats() elif (result == 6): #close application show_menu = False else: print "Wrong choices. Try again."
def process_message(data, g=None): # g=None so we can tests. message = data.get('text', '') if message.startswith('!'): # trigger is "!" if not g: # if g is not set get game state. g_copy = copy.deepcopy(change_state.get_game_state()) else: g_copy = copy.deepcopy(g) command = message[1:].split(" ") # everything after ! # let the router deal with this nonsense game_response, channel = command_router(g_copy, command, data['user']) if channel: send_message(game_response, channel) else: send_message(game_response) return game_response return None
def start_chat(name, age, rating): current_status = " " print "Let's get Started!" spy.name = spy.salutation + ' ' + spy.name print " Authentication Complete . Welcome : %s Age : %d and " \ "rating of : %.2f " % (spy.name, spy.age, spy.rating) show_menu = True while show_menu: menu_choices = " What do you want to do? : \n 1. Add Status \n 2. Add a friend \n 3. Send a secret message " \ "\n 4. Read a secret message \n 5. Read Chats from user \n 6. Close Application \n " result = int(raw_input(menu_choices)) # validating user input if result == 1: # action 1 if len(current_status) > 1: current_status = add_status(current_status, status) else: status_message = None current_status = add_status(status_message, status) print " %s " % current_status elif result == 2: friends_added = add_friend() print "You have %d Friend "%(friends_added) elif result == 3: send_message() elif result == 4: read_message() elif result == 5: read_chat() elif result == 6: print "Goodbye my friend." break else: print " Wrong choice .Try again"
def start_application(): print ' Your details : - ' \ '\n Name : ' + spy.name +\ '\n Age : ' + str(spy.age) +\ '\n Rating : ' + str(spy.rating) +\ '\n Is online : ' + str(spy.is_online) raw = raw_input("Press enter to continue .........") status = True while status: print '\n\nMenu Select one of the following '\ '\n1.Add a status update' \ '\n2.Add a friend' \ '\n3.Send a Secret message' \ '\n4.Read a secret message' \ '\n5.Read chats from user' \ '\n6.Close Application' choice = raw_input('Enter your choice :- ') choice_validation = '^[1-6]$' if (re.match(choice_validation, choice) != None): choice = int(choice) if choice == 1: #add a status section spy_status() elif choice == 2: #add a friend add_friend() elif choice == 3: #Send a secret message send_message() elif choice == 4: #Read a secret message read_message() elif choice == 5: #Read chat form use read_all() elif choice == 6: #close the application status = False else: print Fore.RED + 'You have entered a wrong choice \n' raw = raw_input("Press any key to continue ..........")
def message_everyone_roles(game_state): """Ping players with their roles.""" user_map = UserMap() role_message_mapping = { 'v': " Vanilla Villa\nhttps://media.giphy.com/media/26ufgQWWT3BUtSRq0/giphy.gif", 'w': " Werewolf\nhttps://media.giphy.com/media/VTGEse4Pt422I/giphy.gif", 's': " Seer\nhttps://media.giphy.com/media/bpIWfYfOiHR3G/giphy.gif", 'a': " Angel\nhttps://media.giphy.com/media/xbbq3NUIOtTVu/giphy.gif" } def _player_tuple(player_id, game_state): return (user_map.get(user_id=player_id, DM=True), status.player_role(game_state, player_id)) all_alive = [_player_tuple(player_id, game_state) for player_id in status.players_in_game(game_state) if status.is_player_alive(game_state, player_id)] for im, role in all_alive: dm_message = role_message_mapping[role] send_message(dm_message, channel=im)
def start_game(game_state, user_id, *kwargs): """Start the game and set game status to `RUNNING`.""" result, message = mod_valid_action(user_id, 'start', game_state) if not result: return message, None send_message("@channel: Game is starting...") players = status.players_in_game(game_state) num_werewolves = status.alive_for_werewolf(game_state) p1_str = "_There are *%d* players in the game._\n" % len(players) p2_str = "_There are *%d* werewolves in the game._\n" % len(num_werewolves) p3_str = "https://media.giphy.com/media/3o72FkgwrI7P4G1amI/giphy.gif" send_message(p1_str + p2_str + p3_str) game_state = update_game_state(game_state, 'status', status='RUNNING') new_game = assign_roles(game_state) message_everyone_roles(new_game) return start_day_round(new_game), None
def start_chat(name, age, rating, spy_is_online): from globals import current_status_messages error_message = None if not (age > 12 and age < 50): error_message = "Invalid age. provide correct details" print error_message else: welcome_message = "Authentication complete. Welcome" print welcome_message show_menu = True while show_menu: menu_choices = "what choice do you want ? \n " \ "1. Add a status update \n " \ "2. Add a friend \n " \ "3. Send a secret message \n " \ "4. Read a secret message \n " \ "5. Read chat from a user \n " \ "6. Close Application \n " result = int(input(menu_choices)) #validating user input if (result == 1): current_status_messages = add_status(current_status_messages) elif (result == 2): number_of_friend = add_friend() print "You have %d friends" % (number_of_friend) elif (result == 3): send_message() elif (result == 4): read_message() elif (result == 5): read_chat_history() elif (result == 6): show_menu = False else: cprint('Wrong choice entered please try again *_* ', 'red', attrs=['bold'])
def process_message(data, game_state=None): """Process messages from players and from the game actions.""" message = data.get('text', '') if message.startswith('!'): if not game_state: game_state_copy = copy.deepcopy(change_state.get_game_state()) else: game_state_copy = copy.deepcopy(game_state) game_action = message[1:].split(" ") game_response, channel = command_router(game_state_copy, game_action, data['user']) if channel: send_message(game_response, channel) else: send_message(game_response) return game_response return None
def start_chat(name, age, rating, status): error_message = None # variabmainle for storing error messages. welcome_massage = "Authentication complete. welcome\n" \ "Name : %s" %spy.name + "\n" \ "Age: %d" %spy.age + "\n" \ "Rating %f: " %spy.rating + "\n" \ "Proud to have you onboard" # displaying menu for user. show_menu = True while show_menu: menu_choices = "What do you want to do? \n " \ "1. Add a status update \n " \ "2. Add a friend \n " \ "3. Send a secret message \n " \ "4. Read a secret message \n " \ "5. Read Chats from a user \n " \ "6. Close Application \n" result = int(raw_input(menu_choices)) # validating users input if (result == 1): current_status_message = None print current_status_message current_status_message = add_status(current_status_message) elif (result == 2): number_of_friends = add_friend() print 'You have %d friends' % (number_of_friends) elif (result == 3): send_message() elif (result == 4): read_message() elif (result == 5): read_chat_history() elif (result == 6): # close application show_menu = False else: print "wrong choice try again."
def send_notifications(): #try sending success mail try: send_email(key,email_subject,email_msg) except Exception as e: print "Email not sent" print str(e) message_sent = False #try sending success message try: send_message(MESSAGE) message_sent = True except Exception as e: print str(e) if message_sent == True: #try updating bms_sent try: update_bms_sent() except Exception as e: print str(e)
def start_game(g, user_id, *args): """ Check if enough players. (optional) Pick config setup that works w/ num of players. Outut to channel (@channel) game is starting. Assign Roles. Message Users their roles. STATUS -> "RUNNING" """ # can only start a game # if enough players # if g['STATUS'] == 'WAITING_FOR_JOIN' result, message = mod_valid_action(user_id, 'start', g) if not result: # cant start print(result, message) return message, None # tell everyone the game is starting send_message("@channel: Game is starting...") """ message everyone details of game. """ players = players_in_game(g) num_werewolves = 1 # only one for now. p1_str = "_There are *%d* players in the game._\n" % len(players) p2_str = "There are *%d* werewolves in the game._" % num_werewolves send_message(p1_str + p2_str) g = update_game_state(g, 'status', status='RUNNING') # Go through and assign everyone in the game roles. new_g = assign_roles(g) # updated state w/ roles message_everyone_roles(new_g) # go to night round. return start_day_round(new_g), None # idk when this will return.
def seer_peek_player(game_state, user_id, *args): """Seer can peek a players role during the night.""" user_map = UserMap() arg_list = args[0] if len(arg_list) < 1: return "Have to pick a target.", None elif len(arg_list) > 2: return "Not a valid command.", None else: target_name = arg_list[1] target_id = user_map.get(name=target_name) result, message = is_valid_action(user_id, 'peek', game_state, target_name=target_name) if not result: return message, None else: player_channel = user_map.get(user_id=user_id, DM=True) send_message(message, channel=player_channel) return "", None
def main(): """控制程序""" #创建套接字 create_socket() #创建子线程对象 nostop_recv = threading.Thread(target=recv_msg.receive_message) #运行子线程 nostop_recv.start() while True: choice = my_choice() #发送上线消息 if choice == "1": send_online_msg.send_onlinemsg() #发送离线消息 if choice == "2": send_offline_msg.send_offlinemsg() #发送信息 if choice == "3": send_message.send_message() #退出 if choice == "4": break #关闭套接字 close_socket()
def choices(): from globals import current_status_message loop = True while loop: cprint ("You Can Do following Things\n" \ "What do you want to do? \n " \ "1. Add a status update \n " \ "2. Add a friend \n " \ "3. Send a secret message \n " \ "4. Read a secret message \n " \ "5. Read Chats from a user \n " \ "6. Close Application \n", "cyan") try: choice = int(raw_input()) if choice == 1: current_status_message = status(current_status_message) elif choice == 2: total = add_friend() c = "Total Friend's = " + str(total) cprint(c, "magenta") elif choice == 3: send_message() elif choice == 4: read_message() elif choice == 5: read_chat() elif choice == 6: cprint("Thank You\nGood Bye!!!!!!!!!!!!!!", "red") exit() else: cprint("Wrong Choice", "red", attrs=["bold"]) loop = False except ValueError: cprint("Choose from the above please", "green", attrs=["bold"])
def dispatch_message(): channel_name = request.form.get('channel_name') admin_key = request.form.get('admin_key') title = request.form.get('title') body = request.form.get('message') if not channel_name: return to_error_json("channel_name is required") elif not title: return to_error_json("title is required") elif not body: return to_error_json("message is required") if Channel.query.filter(Channel.name == channel_name).first() is None: return to_error_json("Channel {} does not exist".format(channel_name)) if Channel.query.filter(Channel.admin_key == admin_key).first() is None: return to_error_json("Admin Key does not match any channel") message = Message(channel_name=channel_name, title=title, message=body) db.session.add(message) db.session.commit() send_message(message=message, channel_name=channel_name, admin_key=admin_key) return jsonify(message.dict())