Exemplo n.º 1
0
 def handle_command (self, names, file_dict):
     arg_match = one_arg.match (self.args)
     if arg_match:
         new_name = arg_match.group (1)
         name_list = [name.name for name in names.values ()]
         if new_name in name_list:
             self.handle_wrong_args (file_dict)
             return
         nickname_list = [name.nickname for name in names.values ()]
         if new_name in nickname_list:
             self.handle_wrong_args (file_dict)
             return
         if len(new_name) > MAX_NAME_LENGTH:
             self.handle_wrong_args (file_dict)
             return
         old_name = names[self.name].name
         names[self.name].rename (new_name)
         for n in names:
             if n != self.name:
                 file_dict[n].write ("{}{} changed their name to {}\n{}".format 
                     (prefix, old_name, new_name, suffix))
         file_dict[self.name].write ("{}You have changed your name to {}\n{}"
                 .format(prefix, new_name, suffix))
     else:
         self.handle_wrong_args (file_dict)
Exemplo n.º 2
0
 def handle_command (self, names, file_dict):
     arg_match = one_arg.match (self.args)
     if arg_match:
         new_name = arg_match.group (1)
         name_dict = {value.name : name for name, value in names.items ()}
         if new_name not in name_dict:
             self.handle_wrong_args (file_dict)
             return
         name = name_dict[new_name]
         self.output_status_info (file_dict, name, names)
     else:
         self.handle_wrong_args (file_dict)
Exemplo n.º 3
0
 def handle_input (self, line_num, names, names_dict):
     arg_match = one_arg.match (self.args)
     if arg_match:
         new_name = arg_match.group (1)
         name_dict = {value.name : name for name, value in names.items ()}
         if new_name not in name_dict:
             self.handle_wrong_input (line_num, names, names_dict)
             return
         names_dict[self.name].append ("{}\n".format (3))
         for n in names:
             names_dict[n].append ("S {}\n".format (line_num))
     else:
         self.handle_wrong_input (line_num, names, names_dict)
Exemplo n.º 4
0
 def handle_input (self, line_num, names, names_dict):
     arg_match = one_arg.match (self.args)
     if arg_match:
         old_name = arg_match.group (1)
         name_dict = {value.name : name for name, value in names.items ()}
         if old_name not in name_dict:
             self.handle_wrong_input (line_num, names, names_dict)
             return
         names[name_dict[old_name]].clear_nickname ()
         for n in names:
             names_dict[n].append ("1\n")
     else:
         self.handle_wrong_input (line_num, names, names_dict)
Exemplo n.º 5
0
 def handle_input (self, line_num, names, names_dict):
     arg_match = one_arg.match (self.args)
     if arg_match:
         name = arg_match.group (1)
         name_dict = {value.name : name for name, value in names.items ()}
         if name not in name_dict:
             self.handle_wrong_input (line_num, names, names_dict)
         elif name == names[self.name].name:
             self.handle_wrong_input (line_num, names, names_dict)
         else:
             names[self.name].unmute (name_dict[name])
             self.handle_wrong_input (line_num, names, names_dict)
     else:
         self.handle_wrong_input (line_num, names, names_dict)
Exemplo n.º 6
0
 def handle_command (self, names, file_dict):
     arg_match = one_arg.match (self.args)
     if arg_match:
         name = arg_match.group (1)
         name_dict = {value.name : name for name, value in names.items ()}
         if name not in name_dict:
             self.handle_wrong_args (file_dict)
         elif name == names[self.name].name:
             self.handle_wrong_args (file_dict)
         else:
             names[self.name].unmute (name_dict[name])
             file_dict[self.name].write ("{}User {} is no longer muted\n{}"
                     .format(prefix, name, suffix))
     else:
         self.handle_wrong_args (file_dict)
Exemplo n.º 7
0
 def handle_command (self, names, file_dict):
     arg_match = one_arg.match (self.args)
     if arg_match:
         old_name = arg_match.group (1)
         name_dict = {value.name : name for name, value in names.items ()}
         if old_name not in name_dict:
             self.handle_wrong_args (file_dict)
             return
         names[name_dict[old_name]].clear_nickname ()
         if old_name == names[self.name].name:
             file_dict[self.name].write ("{}You have cleared your nickname\n{}".format (prefix, suffix))
         else:
             file_dict[self.name].write ("{}You have cleared {}'s nickname\n{}".format (prefix, old_name, suffix))
         for n in names:
             if n != self.name:
                 file_dict[n].write ("{}{} has cleared {}'s nickname\n{}".format
                         (prefix, names[self.name].name, old_name, suffix))
     else:
         self.handle_wrong_args (file_dict)
Exemplo n.º 8
0
 def handle_input (self, line_num, names, names_dict):
     arg_match = one_arg.match (self.args)
     if arg_match:
         new_name = arg_match.group (1)
         name_list = [name.name for name in names.values ()]
         if new_name in name_list:
             self.handle_wrong_input (line_num, names, names_dict)
             return
         nickname_list = [name.nickname for name in names.values ()]
         if new_name in nickname_list:
             self.handle_wrong_input (line_num, names, names_dict)
             return
         if len(new_name) > MAX_NAME_LENGTH:
             self.handle_wrong_input (line_num, names, names_dict)
             return
         names[self.name].rename (new_name)
         for n in names:
             names_dict[n].append ("1\n")
     else:
         self.handle_wrong_input (line_num, names, names_dict)