ChatBotv0.1

A script to listen to chat messages and respond to a specific prefix but i like to call it Behavioral Profiler If the profiling is done for the purposes of psychological research or therapy, the person might be a "Psychologist" or "Psychotherapist", specifically one specializing in personality or behavioral psychology.

2023-05-15 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

लेखक
BadNintendo
रेटिंग
0 0 0
आवृत्ती
0.1
बनवली
2023-05-15
अपडेट केली
2023-05-15
आकार
7.92 KB
License
MIT
यांवर लागू होते:

The bot is designed to function within a chatroom, specifically within a website matching the pattern `https://www.shutdown.chat/*/*`. It's built as a Tampermonkey userscript, which means it's a JavaScript-based script that runs in your browser when you visit certain websites, enhancing or altering the functionality of those sites.

The primary functions of this bot are:

1. **Greeting users**: When a new user joins the chatroom, the bot sends them a greeting. This functionality can be turned on or off with the `enableGreet` boolean variable. The greetings are randomized from a predefined list.

2. **Command handling**: The bot listens for messages that start with a predefined prefix (in this case, '!'). If it encounters such a message, it treats it as a command and tries to process it. Currently, the only implemented command is '!8ball', which simulates the behavior of a magic 8-ball toy, providing a random response to a question. More commands can be added as needed. This functionality can be turned on or off with the `enableCommands` boolean variable.

3. **User sentiment analysis**: The bot analyses each message from a user and categorizes it as either 'positive', 'negative', or 'neutral'. It does this by splitting the message into individual words and checking each word against a predefined list of words for each category. For each message, the category with the most words is chosen as the category of the message. This information is stored in a user profile for each user, which keeps a count of the number of messages from that user in each category.

The bot uses MutationObserver API to listen for new messages and user join events. When it detects a new message, it processes it according to the functionalities described above.

The bot logs errors to the console when it can't find the chatbox, input area, or send button on the page, and it logs the responses of the '!8ball' command if it is used by the bot itself.

The bot uses a few other utility functions, such as `sendChatMessage` for sending messages to the chatroom, `handleUserJoin` for detecting when a new user joins the chatroom, `getMessageInfo` for extracting the username and message from a new message node, and `updateUserProfile` for updating a user's profile with the category of a new message.

Remember to use the browser's developer tools (usually by pressing F12 and going to the 'Console' tab) to view these console log messages.