Sichanov

chat_logger

Oct 24th, 2021
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. chat_history = []
  2.  
  3. command = input().split()
  4.  
  5. while not command[0] == 'end':
  6.     action = command[0]
  7.     if action == 'Chat':
  8.         chat_history.append(command[1])
  9.     elif action == 'Delete':
  10.         message = command[1]
  11.         if message in chat_history:
  12.             chat_history.remove(message)
  13.     elif action == 'Edit':
  14.         message = command[1]
  15.         edited_version = command[2]
  16.         if message in chat_history:
  17.             chat_history[chat_history.index(message)] = edited_version
  18.     elif action == 'Pin':
  19.         message = command[1]
  20.         if message in chat_history:
  21.             chat_history.append(chat_history.pop(chat_history.index(message)))
  22.     elif action == 'Spam':
  23.         messages = command
  24.         for i in range(len(command)):
  25.             if not messages[i] == 'Spam':
  26.                 chat_history.append(messages[i])
  27.     command = input().split()
  28.  
  29. print('\n'.join(chat_history))
Advertisement
Add Comment
Please, Sign In to add comment