Profilerv0.9

A script to listen to chat messages and respond to a specific prefix

Autor
BadNintendo
Instalaciones diarias
0
Instalaciones totales
5
Calificaciones
0 0 0
Versión
0.9
Creado
15/05/2023
Actualizado
15/05/2023
Tamaño
13.7 KB
Licencia
MIT
Funciona en

**Part 1 - UserScript Metadata**

This part of the script provides information about the script itself and is used by the browser extension that runs this script, Tampermonkey, to understand when and where to execute it.

- The `@name` attribute is the name of the script.
- `@namespace` is used to avoid conflicts in names.
- `@version` represents the version of the script.
- `@description` is a brief summary of the script's purpose.
- `@author` is the name of the script's creator.
- `@match` specifies the URLs where the script will run. In this case, it's https://www.shutdown.chat/*/*, meaning it will run on all pages under this domain.
- `@grant` specifies the special API permissions the script has. The `GM_getValue`, `GM_setValue`, and `GM_listValues` permissions allow the script to persistently store and retrieve data.

**Part 2 - Core ChatBot Logic**

This JavaScript function is executed immediately upon page load. It sets up a chat bot in a chat room on the Shutdown chat website. The script begins by setting some constants and finding elements on the page that it will interact with later, such as the chat box and the chat message input field.

Then, it defines arrays for eight-ball game responses, greetings, and behavior categories. Behavior categories are divided into positive, negative, and neutral, which will be used to determine a user's behavior based on their chat messages.

**Part 3 - Message Handlers**

Several functions are defined to handle different types of chat messages:

- `handleUserJoin(node)`: This function handles a user joining the chat room by looking for a system message indicating the user has joined. If such a message is found, it sends a greeting to the new user.
- `sendChatMessage(message)`: This function sends a message to the chat room.
- `handleEightBallQuestion({ username, message })`: This function checks if a message starts with "!8ball" and, if so, generates a random eight-ball response to the question asked by the user.
- `processMessageAndGreet({ username, message })`: This function processes all messages, checks if they start with the prefix "!", and if a user types "!hello", the bot greets the user.
- `greetUserOnJoin(username)`: This function greets a user when they join the chat.
- `changeColorBasedOnProfile(username, node)`: This function changes the color of the user's name based on their behavior profile. Green for positive, red for negative, and gray for neutral.
- `updateUserProfile(username, category)`: This function updates a user's profile with the count of positive, negative, and neutral messages.
- `getBehaviorCategory(word)`: This function categorizes a word as positive, negative, or neutral based on its presence in the behavior categories.

**Part 4 - Message Observer**

A `MutationObserver` is set up to listen for new messages being added to the chat box. When a new message is added, it calls the functions defined above to process the message, greet the user if necessary, and update the user's color.

**Part 5 - 8-Ball Game**

The 8-ball game is a simple game where a user can ask a question, and the bot will reply with a random answer from the `eightBallResponses` array. The user triggers this game by sending a message that starts with "!8ball". The script then randomly selects one of the possible responses and sends it back to the chat room.


------------------------------------------------------------------------------------------------------------------------
Changes from 0.7 are below this point.
------------------------------------------------------------------------------------------------------------------------

From the beginning of this conversation, a number of enhancements and changes were made to the existing code. Here's a summary of those improvements:

1. **Improved IQ Gathering:** We discussed strategies to ensure a user's IQ score is fair by introducing more comprehensive testing, reducing bias, and accounting for cultural differences.

2. **Enhanced Magic 8-Ball Responses:** The code for a Magic 8-Ball-like response generator was expanded to offer more diverse and expressive responses, categorized by the type of question asked (yes/no, when, how, unknown).

3. **Extended Unknown Responses:** The set of responses for "unknown" type questions in the 8-ball function was expanded, giving the program more ways to express uncertainty or encourage the user to ask again.

4. **Incorporated Slang in Sentiment Analysis:** The code used to categorize user behavior as positive, negative, or neutral was updated to include a wide variety of American English slang terms. This makes the sentiment analysis more attuned to the nuances of informal language use.

5. **Case-Insensitive Slang Detection:** The function for detecting and categorizing words was adjusted to be case-insensitive, allowing it to recognize words regardless of whether they are capitalized or not.

These changes overall made the code more robust, versatile, and sensitive to the nuances of user input.