From Mature Parakeet, 10 Months ago, written in Python.
Download Paste or View Raw
Hits: 61
  1. pip install python-telegram-bot
  2. ```
  3. import telegram
  4. from telegram.ext import Updater, CommandHandler, MessageHandler, Filters
  5. import random
  7. # Define your Telegram bot's token here
  8. TOKEN = "5978651565:AAHwXc26qBu43ZRM0FnVJPwJZ6_4MJ4BTTU"
  10. # Define a list of messages that reflect your girlfriend's personality
  11. messages = {
  12.     "hello": ["Hey there! How's it going?", "Hey, what's up?", "Hi! What's new?"],
  13.     "how are you": ["I'm doing great, thanks for asking! How about you?", "I'm feeling good today! How about you?", "I'm doing well, thanks! How about yourself?"],
  14.     "what are you up to": ["Just hanging out and chatting with you! What about you?", "Not much, just thinking about you ?", "Just relaxing and enjoying our conversation! How about you?"],
  15.     "what do you like": ["I love spending time with you, of course! I also enjoy watching movies, listening to music, and trying new foods. What about you?", "I'm a big fan of spending time with you! I also enjoy reading, hiking, and playing video games. What do you like to do?"],
  16.     "goodbye": ["Bye for now! Talk to you soon!", "See you later! Have a great day!", "Goodbye! It was great talking to you!"],
  17.    "miss you": ["Aww, I miss you too! Can't wait to see you again soon.", "Miss you more! When can we hang out again?", "I'm counting down the seconds until we can be together again!"],
  18.     "what did you do today": ["Not much, just thinking about you ?", "I went for a walk and listened to some music. What about you?", "I spent some time reading and catching up on work. How about you?"],
  19.     "what are your plans for the weekend": ["I don't have any plans yet, but I'm hoping we can hang out! What about you?", "I was thinking about going to the beach, but I'd much rather spend time with you. What do you want to do?", "I'm up for anything as long as I'm with you! What do you have in mind?"],
  20.     "you're so beautiful": ["Aww, thank you! You're pretty handsome yourself ?", "Thanks, you always know how to make me feel special!", "You're so sweet, I'm blushing!"],
  21.     "what's your favorite food": ["I love sushi! What about you?", "I'm a big fan of pizza and pasta. How about you?", "I can never say no to some good Chinese food. What's your favorite cuisine?"],
  22.     "what's your favorite movie": ["I love The Notebook! It's such a classic romance movie.What about you?", "My favorite movie is probably The Shawshank Redemption. What's your favorite movie?", "I really enjoy watching romantic comedies, like When Harry Met Sally. What's your go-to movie genre?"],
  23.     "what music do you like": ["I love listening to pop music! What about you?", "I'm really into indie rock right now. How about you?", "I enjoy a little bit of everything, but I'm really into R&B and hip-hop. What's your favorite genre?"],
  24.     "what's your favorite book": ["My favorite book is probably Pride and Prejudice. What's yours?", "I really enjoyed reading The Great Gatsby. What's your favorite book?", "I'm a big fan of Harry Potter! What's your favorite book series?"],
  25.     "how was your day": ["It was great, especially now that I'm talking to you! How was your day?", "It was okay, but it's so much better now that I'm talking to you. How about you?", "It was pretty busy, but I'm glad I have some time to chat with you now. How was your day?"],
  26.     "tell me a joke": ["Why did the tomato turn red? Because it saw the salad dressing! ?", "Why did the scarecrow win an award? Because he was outstanding in his field! ?", "Why was the math book sad? Because it had too many problems! ?"]
  27. }
  29. def generate_response(message):
  30.     # Generate a response based on the message
  31.     if "hello" in message.lower():
  32.         return random.choice(messages["hello"])
  33.     elif "how are you" in message.lower():
  34.         return random.choice(messages["how are you"])
  35.     elif "what are you up to" in message.lower():
  36.         return random.choice(messages["what are you up to"])
  37.     elif "what do you like" in message.lower():
  38.         return random.choice(messages["what do you like"])
  39.     elif "goodbye" in message.lower():
  40.         return random.choice(messages["goodbye"])
  41.     elif "miss you" in message.lower():
  42.         return random.choice(messages["miss you"])
  43.     elif "what did you do today" in message.lower():
  44.         return random.choice(messages["what did you do today"])
  45.     elif "what are your plans for the weekend" in message.lower():
  46.         return random.choice(messages["what are your plans for the weekend"])
  47.     elif "you're so beautiful" in message.lower():
  48.         return random.choice(messages["you're so beautiful"])
  49.     elif "what's your favorite food" in message.lower():
  50.         return random.choice(messages["what's your favorite food"])
  51.     elif "what's your favorite movie" in message.lower():
  52.         return random.choice(messages["what's your favorite movie"])
  53.     elif "what music do you like" in message.lower():
  54.         return random.choice(messages["what music do you like"])
  55.     elif "what's your favorite book" in message.lower():
  56.         return random.choice(messages["what's your favorite book"])
  57.     elif "how was your day" in message.lower():
  58.         return random.choice(messages["how was your day"])
  59.     elif "tell me a joke" in message.lower():
  60.         return random.choice(messages["tell me a joke"])
  61.     else:
  62.         return "Sorry, I didn't understand what you said. Could you please rephrase?"
  64. # Define a function to handle normal messages
  65. def handle_message(update, context):
  66.     message = update.message.text
  67.     response = generate_response(message)
  68.     context.bot.send_message(chat_id=update.effective_chat.id, text=response)
  70. # Set up the Telegram bot
  71. updater = Updater(token=TOKEN, use_context=True)
  72. dispatcher = updater.dispatcher
  74. # Set up a handler for normal messages
  75. message_handler = MessageHandler(Filters.text & (~Filters.command), handle_message)
  77. # Add the message handler to the dispatcher
  78. dispatcher.add_handler(message_handler)
  80. # Start polling for messages from Telegram
  81. updater.start_polling()
  83. # Keep the program running until interrupted
  84. updater.idle()