PYTHON 51
Responses.py (https://github.com/indently/discord_tutorial_2024/) By AndrzejL on 26th June 2024 01:56:22 AM
  1. from random import choice, randint
  2.  
  3.  
  4. def get_response(user_input: str) -> str:
  5.     lowered: str = user_input.lower()
  6.  
  7.     if lowered == '':
  8.         return 'Well, you\'re awfully silent...'
  9.     elif 'hello' in lowered:
  10.         return 'Hello there!'
  11.     elif 'how are you' in lowered:
  12.         return 'Good, thanks!'
  13.     elif 'bye' in lowered:
  14.         return 'See you!'
  15.     elif 'roll dice' in lowered:
  16.         return f'You rolled: {randint(1, 6)}'
  17.     else:
  18.         return choice(['I do not understand...',
  19.                        'What are you talking about?',
  20.                        'Do you mind rephrasing that?'])

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.