Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
7.0 kB
44
Indexable
Never
import tkinter as tk
import random



def get_greeting_response():
    greetings = [
        "Hello, how may I assist you?",
        "Hi, how can I be of service?",
        "Good day, what do you need help with?",
        "Greetings! How can I help you today?",
        "Hey there! What can I do for you?",
        "Welcome! How may I assist you?",
        "Hi there! What brings you today?",
        "Good to see you! How can I support you?",
        "Hello! How can I make your day better?",
        "Greetings! What brings you to our IT assistance today?",
        "Hey! How can I make your IT experience smoother?",
        "Hi! What IT challenges can I help you overcome?",
    ]
    return random.choice(greetings)

def get_it_response(user_message):
    if "password" in user_message.lower():
        return "Sure, I can help you reset your password. Please follow the company's password reset procedure."
    elif "printer" in user_message.lower():
        return "Having trouble with the printer? Let's troubleshoot the issue. Check if it's turned on and connected properly."
    elif "mouse" in user_message.lower():
        return "Is your mouse not working properly? Let's figure out what's going on. Try replacing the batteries or reconnecting it."
    elif "wifi" in user_message.lower() or "internet" in user_message.lower():
        return "Experiencing issues with the Wi-Fi or internet connection? Ensure you are connected to the right network and try restarting your router."
    elif "email" in user_message.lower():
        return "If you're having problems with your email, make sure you're using the correct credentials. If the issue persists, contact the IT department for assistance."
    elif "software" in user_message.lower():
        return "Issues with a specific software? Ensure it's updated to the latest version. If problems persist, contact IT support for further assistance."
    elif "security" in user_message.lower():
        return "Concerns about security? Make sure your antivirus is up to date, and avoid clicking on suspicious links. Report any security issues to the IT security team."
    elif "VPN" or "vpn" in user_message.upper():
        return "Need help with the VPN? Check your credentials and ensure you have a stable internet connection. Contact IT support if you continue to face issues."
    elif "hardware" in user_message.lower():
        return "Experiencing hardware issues? Ensure all cables are connected securely and try restarting your computer. If problems persist, contact IT support."
    elif "access" in user_message.lower():
        return "If you're having trouble accessing a specific system or application, make sure your permissions are correctly set. Contact IT support if you need further assistance."
    elif "backup" or "backed up" in user_message.lower():
        return "Concerns about data backup? Ensure your data is regularly backed up to prevent loss. If you need help with the backup process, contact IT support for guidance."
    elif "update" in user_message.lower():
        return "For updating software or systems, always check for the latest updates. If you encounter issues during the update process, contact IT support for assistance."
    else:
        return "I'm sorry, I may not have the information you're looking for. Please contact your IT support for assistance."

def get_end_response():
    endings = [
        "Thank you for using our IT assistance service. Have a great day!",
        "If you have any more questions, feel free to ask. Have a productive day!",
        "If there's anything else you need help with, just let me know. Have a wonderful day!",
        "Your satisfaction is our priority. If you need further assistance, don't hesitate to reach out. Have a fantastic day!",
        "We appreciate your trust in our IT support. Wishing you a smooth and trouble-free experience ahead. Have a great day!",
        "It was a pleasure assisting you. Should you encounter any more issues, we're here to help. Have an excellent day!",
        "Thank you for choosing us for your IT needs. If there's anything else we can do, feel free to ask. Have a splendid day!",
        "Your success is important to us. If there's anything hindering it, let us know. Have a successful and enjoyable day!",
        "We're here 24/7 for all your IT queries. Don't hesitate to contact us anytime. Wishing you a wonderful day!",
        "Your satisfaction is our motivation. If there's anything else you'd like to discuss, feel free to reach out. Have a fantastic day!",
    ]
    return random.choice(endings)

def send_message(event=None):
    user_message = user_input.get()
    if user_message:
        chat_log.config(state=tk.NORMAL)
        chat_log.insert(tk.END, "You: " + user_message + "\n", "user_message")
        chat_log.config(state=tk.DISABLED)

        # Check for specific responses
        if "hello" in user_message.lower() or "hi" in user_message.lower():
            bot_response = get_greeting_response()
        elif any(keyword in user_message.lower() for keyword in ["password", "printer", "mouse", "email", "wifi", "software", "security", "VPN", "vpn", "hardware", "backup", "backed up", "access", "update"]):
            bot_response = get_it_response(user_message)
        elif "bye" in user_message.lower() or "thank you" in user_message.lower():
            bot_response = get_end_response()
        else:
            bot_response = "I'm sorry, I may not have the information you're looking for. Please contact your IT support for assistance."

        chat_log.config(state=tk.NORMAL)
        chat_log.insert(tk.END, "Helper Bot: " + bot_response + "\n", "bot_message")
        chat_log.config(state=tk.DISABLED)
        # Add your logic to send the user's message
        user_input_text = user_input.get()
        # You can print or process the user_input_text as needed
        print(f"User Message: {user_input_text}")
        # Clear the user input field
        user_input.delete(0, tk.END)

# GUI Setup
root = tk.Tk()
root.title("IT Helper Bot")

# Create a chat log display with a stylish font and a light background
chat_log = tk.Text(root, state=tk.DISABLED, font=("Arial", 12), bg="#f0f0f0", height=10, width=40)
chat_log.tag_configure("user_message", foreground="blue")
chat_log.tag_configure("bot_message", foreground="green")
chat_log.pack(padx=10, pady=10, expand=True, fill=tk.BOTH)

# Create a user input field with a unique color
user_input = tk.Entry(root, font=("Arial", 12), bg="#e0e0e0")
user_input.pack(padx=10, pady=(0, 10), expand=True, fill=tk.BOTH)

# Create a more appealing send button with a vibrant color
send_button = tk.Button(root, text="Send", command=send_message, font=("Arial", 12), bg="#4CAF50", fg="white", relief=tk.RAISED)
send_button.pack(padx=10, pady=(0, 10), ipadx=10, ipady=5, expand=True, fill=tk.BOTH)

# Bind the Return key to the send_message function
user_input.bind("<Return>", send_message)

# Run the GUI application
root.mainloop()

Leave a Comment