Пример #1
0
 def log_ctcp(self, full_line, server_obj, user_obj, channel_obj):
     ctcp_command = full_line.split()[0]
     ctcp_arguments = ' '.join(full_line.split()[1:])
     if ctcp_command.lower() == "action":
         output = Commons.current_timestamp() + " "
         output += "**" + user_obj.get_name() + ' ' + ctcp_arguments + '**'
         return output
     output = Commons.current_timestamp() + " "
     output += "<" + user_obj.get_name() + ' (CTCP)> ' + full_line
     return output
Пример #2
0
 def print_ping(self, full_line, server_obj, user_obj, channel_obj):
     output = Commons.current_timestamp() + " "
     if user_obj is None:
         output += "["+server_obj.get_name() + "] PING"
     else:
         output += "["+server_obj.get_name() + "] PONG"
     return output
Пример #3
0
 def print_kick(self, full_line, server_obj, user_obj, channel_obj):
     output = Commons.current_timestamp() + " "
     output += "[" + server_obj.get_name() + "] "
     output += user_obj.get_name() + " was kicked from " + channel_obj.get_name()
     if full_line.strip() != "":
         output += " (" + full_line + ")"
     return output
Пример #4
0
 def print_quit(self, full_line, server_obj, user_obj, channel_obj):
     output = Commons.current_timestamp() + " "
     output += "[" + server_obj.get_name() + "] "
     output += user_obj.get_name() + " has quit."
     if full_line.strip() != "":
         output += " (" + full_line + ")"
     return output
Пример #5
0
 def print_message(self, full_line, server_obj, user_obj, channel_obj):
     destination_object = channel_obj
     if channel_obj is None:
         destination_object = user_obj
     output = Commons.current_timestamp() + " "
     output += "[" + server_obj.get_name() + "] "
     output += destination_object.get_name() + " "
     output += "<" + user_obj.get_name() + "> " + full_line
     return output
Пример #6
0
 def print_ctcp(self, full_line, server_obj, user_obj, channel_obj):
     # Get useful data and objects
     ctcp_command = full_line.split()[0]
     ctcp_arguments = ' '.join(full_line.split()[1:])
     destination_obj = channel_obj
     if channel_obj is None:
         destination_obj = user_obj
     # Print CTCP actions differently to other CTCP commands
     if ctcp_command.lower() == "action":
         output = Commons.current_timestamp() + " "
         output += "[" + server_obj.get_name() + "] "
         output += destination_obj.get_name() + " "
         output += "**" + user_obj.get_name() + " " + ctcp_arguments + "**"
         return output
     output = Commons.current_timestamp() + " "
     output += "[" + server_obj.get_name() + "] "
     output += destination_obj.get_name() + " "
     output += "<" + user_obj.get_name() + " (CTCP)> " + full_line
     return output
Пример #7
0
 def print_join(self, full_line, server_obj, user_obj, channel_obj):
     output = Commons.current_timestamp() + " "
     output += "[" + server_obj.get_name() + "] "
     output += user_obj.get_name() + " joined " + channel_obj.get_name()
     return output
Пример #8
0
 def print_day(self, full_line, server_obj, user_obj, channel_obj):
     output = Commons.current_timestamp() + " "
     output += "Day changed: "+datetime.datetime.now().strftime("%Y-%m-%d")
     return output
Пример #9
0
 def print_raw(self, raw_text):
     output = Commons.current_timestamp() + " " + \
              raw_text
     return output
Пример #10
0
 def print_notice(self, full_line, server_obj, user_obj, channel_obj):
     output = Commons.current_timestamp() + " "
     output += "[" + server_obj.get_name() + "] "
     output += "Notice from " + user_obj.get_name() + ": " + full_line
     return output
Пример #11
0
 def print_invite(self, full_line, server_obj, user_obj, channel_obj):
     output = Commons.current_timestamp() + " "
     output += "[" + server_obj.get_name() + "] "
     output += "Invite to " + channel_obj.get_name() + ' from ' + user_obj.get_name()
     return output
Пример #12
0
 def print_name_change(self, full_line, server_obj, user_obj, channel_obj):
     output = Commons.current_timestamp() + " "
     output += "[" + server_obj.get_name() + "] "
     output += "Nick change: " + full_line + " -> " + user_obj.get_name()
     return output
Пример #13
0
 def log_message(self, full_line, server_obj, user_obj, channel_obj):
     output = Commons.current_timestamp() + " "
     output += '<' + user_obj.get_name() + '> ' + full_line
     return output
Пример #14
0
 def test_current_timestamp(self):
     stamp = Commons.current_timestamp()
     assert len(stamp) == 10, "Timestamp is the wrong length"
     pattern = re.compile("^\[(0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]\]$")
     assert pattern.match(stamp), "Timestamp is not valid to defined format."
Пример #15
0
 def print_mode_change(self, full_line, server_obj, user_obj, channel_obj):
     output = Commons.current_timestamp() + " "
     output += "[" + server_obj.get_name() + "] "
     output += user_obj.get_name() + ' set ' + full_line + ' on ' + channel_obj.get_name()
     return output
Пример #16
0
 def test_current_timestamp_datetime_given(self):
     dtime = datetime(2019, 4, 6, 10, 15, 3)
     stamp = Commons.current_timestamp(dtime)
     assert stamp == "[10:15:03]"
Пример #17
0
 def log_leave(self, full_line, server_obj, user_obj, channel_obj):
     output = Commons.current_timestamp() + " "
     output += user_obj.get_name() + " left " + channel_obj.get_name()
     if full_line.strip() != "":
         output += " (" + full_line + ")"
     return output