The avatar for our bot
This is how Harmony gets a user's consent to have someone support them
Telling it I have a class then launching Minecraft causes it to send a message pointing that out
The /positivity function crawls through an entire server's history, and calculates positivity.
Harmony lets your support person know when you've played more video games than you should, or when you've gone too long without talking.
If a user sends a particularly negative message, it'll let their support person know, so they can maybe check in and see if they're okay.
The core concept for Harmony was born out of a lot of the struggles we are facing today. With the pandemic keeping us at home so much, it has become easy to isolate ourselves from each other and get lost in the solace of video games. Also, society has started just to grow more and more bitter at the state of current events. These emotions are hard to deal with on your own, and it is not easy to start a conversation about our struggles or to admit we need help. But we at Harmony are optimistic that our program can be a powerful tool to help people assist each other with their mental health and form closer relationships with friends by creating an accountability bot.
What it does
To sign-up for Harmony all the user must do is type in the channel the following commands.
/support @user [hour limit for video games] [day limit for message]
/support user#0000 [hour limit for video games] [day limit for message]
/support <user.id> (if you have discord developer mode enabled) [hour limit for video games] [ day limit for message ]
This system will dm the desired user with a message about the program and give them to option to accept or decline your invitation to be accountability partners. This program can help each user in several ways.
Using the first optional argument of the command (default value 40 hours), Harmony will keep track of how long each user plays games and if it goes over the designated weekly threshold it will inform the accountability partner that they are over the time.
Using the second optional argument of the command (default value 7 days), Harmony will keep track of how long the user has not sent a message, and in a certain number of days, it will inform the other partner that they may need to check in on their friend.
In addition, Harmony observes each user’s message data and based on the type of words the user says it will report a positivity rating on their chats as well as send the sender notifications if a message is too aggressive.
Lastly, Harmony has a feature that tries to stop you from playing video games when you should be doing something else, like being in class. Harmony does this by sending a message that the user is playing games in class. To set your class time the user will use the following command,
/class [single letter day name (For example, M for Monday, R for Thursday, U for Sunday)] [Time period in military time (For example 21:00-22:00)] [three letter time zone (For example CST)
How we built it
To, create the argument that mentored game time, we used discord.js and their listener to see check messages sent and if their presence changed. When the bot detects such a change, it creates an object with the date of the message sent or the presence change. We then check if these values ever go over the set limits, and, if it does, it will send the person supporting them a message alerting them. One additional feature we decided to add was to help people pay attention in classes. Users can input their classes, and if Harmony sees you playing games during a class, it'll send a message saying so. So, for example, if the user says they have a class that's happening right now and then they launch a game it, it'll send a message letting your friends know that you're supposed to be in class, so they can help encourage you to pay attention. The way this works is that it converts the dates you input into start points and endpoints in milliseconds since the beginning of its week, and any time it gets a notification that someone is playing a game, it compares the two.
Our last feature is a positivity calculator. With everything going on it is easy to be negative or aggressive to others so with Harmony if it reads that your messages have been too harsh it will send you a notification. To do this we Harmony observes each user’s message data and based on the type of words the user says it will report a positivity rating on their chats to their accountability partner as well as send the user notifications if a message is too aggressive. Harmony also has a command
that will allow for Harmony to crawl through an entire text channel to see how positive a user has been. The algorithm we created to calculate message positivity utilizes the AFINN-165 dataset, a list of words rated for positivity with an integer between negative five (very negative or aggressive) and positive five (very wholesome or positive). The algorithm had to filter through the AFINN file and create a map that stored each word or phrase and the points associated with it.
Challenges we ran into
In addition, when coding the algorithm for the positivity rating we ran into a few problems because some of the phrases in the AFINN were two words or had dashed in it. This made it really hard to code the algorithm because we couldn't simply just split the string into an array after space or some other simple identifier. To fix this problem we used regex to separate the word or phrase from the positivity score and then we used that output to create a map object. After this was created all we had to do was use a nested loop to iterate through the user input and map that stored the AFINN to obtain the sum of scores
Also, coding the class schedule feature proved to be a little harder than anticipated since we had to deal with time zones! The bot operates on UTC time, but converting your local time to UTC time would be really, really annoying, so we had to find a way to go from local time to UTC time, which, as any programmer knows, is really complicated and hard when you're not just letting a library handle it for you, which we couldn't. In addition, we had to store the times in a way that made the intervals repeat weekly, which was a hard problem which we found a creative solution to, as previously explained.
Accomplishments that we're proud of
One of the very good parts of the project was the lack of technical debt built up, from the very beginning, we feel the code was very concise and clean. When we had to expand the bot from the gaming limiting feature to also include the not talking for a long time feature, the baseline code was already there, and we were easily able to adapt it for a newer feature. We also had to change how it decided when someone has played for too long, a potentially costly decision but managed to do it very cleanly due to our originally written code being well put together (abnormal for a hackathon)
Finally, we think we did a really great job of just defining the problems we were going to solve and how we were going to solve them before we started coding, which was something which really helped us, as Max explained, avoid building up a lot of technical debt. It also helped us as we started putting pieces together because we were able to easily understand what data we had access to and how it all fits together. In other words, we think we did a great job of working together... In Harmony
What we learned
What's next for Harmony
We'd like to expand how we keep track of data for people, and rather than having the person offering support set a number of hours or days, have a system that is able to do some statistical analysis on users' behavior and detect when there's an anomaly. Other than that, we'd just need to handle a lot more edge cases to make it more stable and therefore ready to be sent in multiple servers.