Skip to main content

Ankhbot — Creating an autonomous custom welcome message program


This is an older article but is kept here for posterity's sake. Ankhbot is now Streamlabs Chatbot and does not function in the same matter. This code will not work.
+ + +

Because of Ankhbot’s merger with Streamlabs, this article is now slightly outdated so I have made a new one! Please head over to the aptly named “Streamlabs Chatbot — Creating an (almost) autonomous user-created custom welcome message program”!

A while back I decided to give my Twitch followers, whom I call Drifters, a way to create their own welcome message that, for a small sum of currency (called supplies in my channel), would greet them when they entered chat. This would allow them to spend some of those supplies on something other than ambushes (my channel’s version of heists) and make the community feel a little more like theirs. Of course, this also lead to the idea of them being able to create a welcome message for other users–a fun way for followers to mess with other followers. Luckily, Ankhbot has included a way for welcome messages (among other things) to be included upon specific users entering your channel.

I immediately set this plan in motion and it was a success as I was able to use the $removepoints() parameter to take Supplies from them and they would whisper me the message they wanted their welcome message to be or the username and message of the other Drifter. However, soon after this breakthrough (in my mind), I realized it would be near impossible for me to keep up with their need on a consistent manner without interrupting gameplay repeatedly. That lead me down the path in search of a way to make a completely autonomous way for users to create and change their welcome messages at will.

I’ll be upfront with you: it is not possible to create a completely autonomous user-created custom welcome message in Ankhbot. Running my idea past Marcin Swierzowski on Twitter, he confirmed that my idea just wasn’t able to bear fruit.

John Paul @resonantdrifter
Almost. Need a way to automatically set the On Join Event per user to read their specific $user.txt automatically… #ankhbot@AnkhHeart

Ankh Heart @AnkhHeart
@resonantdrifter That’s not possible. You’ll have to manually create On Join Events manually.

However, my stubbornness persisted and I came upon a way that would allow the user to create and change their (and others) own custom welcome message at will with VERY LITTLE INITIAL SETUP. The following is how I created the (Almost) completely autonomous user-created custom welcome message!

ON JOIN EVENT LIST


First and foremost, the most intensive part of this setup (especially if you already have a lot of followers or get a lot of followers daily) is setting up the On Join Event list. The On Join Event list is where you tell Ankhbot what you want it to do when a specific user enters chat. This unfortunately can not be automated and was where I got hung up on my grand scheme. I really wanted Ankhbot to auto-compile this list from my current followers but automating this system just isn’t possible, so you’ll have to manually enter an entry for each follower. Luckily, you’ll only have to do this once per follower. After that, each message will automatically update on its own.


In the On Join Event system you’ll have to create an entry for each of your followers linking it to a .txt document which will display their command upon entering chat.

First, create a folder where you want to store all the .txt documents that Ankhbot will create. Remember, though they will be small (filesize-wise), there will be numerous files created (assuming you get a lot of followers). Once this is done go back into Ankhbot and create a command for each of your followers as follows (hint: everything stays the same except the Info slot):
UserGroup: Keep this “User_Specific”
Info: individual follower username
Client Only: “False” (True means only the user will be able to see it)
Enabled: “True” (False will, obviously, turn it off for that user)
Vol: Set to whatever level is comfortable for you and your viewers
Message: $readline(C:\user$user.txt)

Let’s take a closer look at the “Message” slot:

$readline(C:\user$user.txt)

The $readline() parameter simply reads the first line in whatever text document you point it to. The destination is put within the parentheses. This is an important part: naming the text document $user.txt allows Ankhbot to search for a .txt document labeled with the user’s name (this will come full circle further down this document).

Once we enter all current followers we are done. However, as we get more followers we must create a new entry for each of them. That is the most work we’ll have to do on this almost autonomous system.

CHAT COMMANDS


Now that we have the core setup, lets create the commands that will allow the users to set and change their welcome message. Just so we’re on the same page, my command for followers to create their own welcome message is !buywelcome and the currency in my channel is supplies.

!BUYWELCOME


To get this to work you must first create a .txt document with two parameters inside: $removepoints(“target”,”min”,”max”,”succeed”,”fail”,”forceremove”) and ***$overwritefile(“FileLocation”, “Text”)***. I labeled my document buywelcome.txt and filled it out thusly:

$removepoints(“$user”,”100",”100",”$value supplies have been removed from your inventory and your welcome message has been changed to ‘$msg’”,”You do not have enough supplies in your inventory!”,”false”) $overwritefile(“C:\Ankhbot\user$user.txt”,”$user: $msg”)

The first parameter — $removepoints() — does exactly what it says and removes points (or currency) from the user who enters the command. In this instance it removes 100 Supplies (if the user has enough) and returns a message both if they have or do not have enough Supplies. Let’s take a closer look:

“$user” — connects the $removepoints() parameter to the user entering the command

“min”, “max” — in my parameter sets the minimum and maximum payout at 100 supplies each so it does not vary

“succeed” — “$value supplies blah blah blah ‘$msg’” takes whatever amount is removed from currency (100) and displays it in the in-chat message along with the success message. The $msg parameter will reprint whatever message the user has set so they can see it. I included this so they know it has changed.

“fail” — “You do no blah blah” is the message if the user doesn’t have 100 supplies (they like to gamble)

“forceremove” — “false” allows users to not be able to buy if they don’t have enough supplies. Setting this to “True” would allow the to go into negative currency.

The second parameter allows us to store the message in a .txt document labeled as the user’s name ($user.txt) using the $overwritefile(“FileLocation”, “Text”) parameter.

Before we get into this, i want to explain something. Remember back when we created the On Join Event list? We created a folder to house all the user .txt files, but we didn’t create any actual text files. Why? This ensures that when a user who didn’t enter anything as a welcome message won’t get one when they join chat. Let’s take a closer look:

$overwritefile(“FileLocation”) — by using $overwritefile instead of $savetofile the user can change this message whenever they want.

“text” — “$user: $msg” these two parameters save the username of the user and the message they typed to print them on screen both later.

In the actual !buywelcome command you simply put $readline(FileLocation) and point it toward the document you created (in my case, the buywelcome.txt). That’s all you need to do to make this work.

!BUYOTHERWELCOME


To create a fun and somewhat competitive experience, I wanted to allow my followers to be able to create welcome messages for other users. I knew this would closely resemble the !buywelcome command, but would present its own hurdles as it’s one user creating a message for another. Here’s how I set this up:

Much like the previous command, you create a .txt document with the $removepoints(“target”,”min”,”max”,”succeed”,”fail”,”forceremove”) and the $overwritefile(“FileLocation”, “Text”) parameters in it. Unlike the previous command, you’ll have to set it up slightly differently to get it to work. Here’s how mine looks:


$removepoints(“$user”,”100",”100",”$value supplies have been removed from your inventory and $target’s welcome message has been changed to ‘$msg’”,”You do not have enough supplies in your inventory!”,”false”) $overwritefile(“C:\Users\JohninMotion\Documents\Ankhbot\user$target.txt”,”$msg”)

The first parameter — $removepoints() — does exactly what it says and removes points (or currency) from the user who enters the command. In this instance it removes 100 Supplies (if the user has enough) and returns a message both if they have or do not have enough Supplies. Where it differs is it enters a target for the message. Let’s take a closer look:

“$user” — connects the $removepoints() parameter to the user entering the command

“min”, “max” — in my parameter sets the minimum and maximum payout at 100 supplies each so it does not vary

“succeed” — “$value supplies blah blah $target blah ‘$msg’” takes whatever amount is removed from currency (100) and displays it in the in-chat message along with the success message. $target will tell the system who you want the message to go to. The $msg parameter will reprint whatever message the user has set so they can see it. I included this so they know it has changed.

“fail” — “You do no blah blah” is the message if the user doesn’t have 100 supplies (again, they like to gamble)

“forceremove” — “false” allows users to not be able to buy if they don’t have enough supplies. Setting this to “True” would allow the to go into negative currency.

The second parameter allows us to store the message in a .txt document labeled as the target’s name this time ($target.txt) using the $overwritefile(“FileLocation”, “Text”) parameter. Let’s take a closer look:

$overwritefile(“FileLocation”) — by using $overwritefile instead of $savetofile the user can change this message whenever they want.

“text” — “$target: $msg” these two parameters save the username of the target and the message they typed to print them on screen both later.

In the actual !buyotherwelcome command you simply put $readline(FileLocation) and point it toward the document you created (in my case, the ***buyotherwelcome.txt)***. And that’s all you need to do to make this work.

!MYWELCOME


Finally, I wanted a way for my followers to see their message even if it was after they had entered chat if only for the sheer fact they want to be able to see that it did work. This is a very simple thing to set up. Here’s how:

Create a command, in my case it’s !mywelcome, and put inside of it the $readrandline(FileLocation) parameter. Inside you simply point it toward the folder housing all the user welcome messages (***\user*** for me) with $user.txt at the end. For example, mine look like:

$readrandline(C:\Users\JoininMotion\Documents\Ankhbot\users$user.txt)

That’s it. Now when a user types in the !mywelcome command they will see their own welcome message.

THE SELF-SUFFICIENT MACHINE


By following the path set above you will be able to create your own (almost) completely autonomous user-created custom welcome message. Maybe someday in the future, if Marcin decides to continue upgrading Ankhbot, we will be able to create a truly completely autonomous system. Until then, for all intensive purposes, this will have to do for now.

Popular posts from this blog

Eternally Doomed

Four years after the phenomenal Doom 2016 was laid upon us unexpecting gamers, id Software releases their highly anticipated follow up - Doom Eternal - which manages to not only take and build upon what was created in the earlier games of the series, but to add in new mechanics as well; however, is it all a worthwhile experience? ☠ ☠ ☠Doom Eternal picks up sometime after the events of the first game with the "Doom Slayer" hovering above Earth like some omnipresent God lording over his flock in the Fortress of Doom - a towering citadel planted on a jagged piece of rock that acts as his personal headquarters he will visit after almost every mission. Last seen being teleported away to somewhere by Samuel Hayden at the end of Doom 2016, the Slayer's presumably just arrived somehow after a long journey to find Earth overwhelmed by demons. The resistance - whom you never see and who manage to put out radio broadcasts like John Conner in some demon-infested reimagining of Term…

D&D Variants: Dash

There are a slew of actions that players can take whilst in combat that can help them do a multitude of things from aiding in battle to avoiding it altogether. However, I feel that although some of these rules as written (RAW) get the job done, they often feel subpar, uninspired or even a little overpowered so I thought it would be interesting and fun to take an objective look at all the D&D rules and propose variant rules.Being a big proponent of actions and consequences, I have come up with some ideas that fit within this mold making these actions less of a "sure thing" and more chaotic. To allow for multiple levels of fun, I came up with three tiers of increasing complexity that the DM (with their players) can decide to use.That said, let's take a look at the Dash action.DASH The Dash rules as written (RAW) on page 192 of the PHB are:Dash
When you take the Dash action, you gain extra movement for the current turn. The increase equals your speed, after applying any m…

Betrayal at House on the Hill - Tabletop Review

Wanting to get together with friends during this Covid-19 lockdown but not wanting to break quarantine protocol and spread the disease, I reached out to a member of my community who was wonderful enough to gift me a copy of Tabletop Simulator and promptly got a list of games together to play which included Betrayal at House on the Hill, but with so many games out there, is this game worth your money and time?  ⚅⚅⚅ The story behind Betrayal at House on the Hill doesn't matter.

Rather, the story behind Betrayal at House on the Hill is simply whatever you want or need it to be in order to get your group of various characters to the house sitting atop the hill because this wonderful game by Avalon Hill knows it's what happens within these walls that truly matters. It's what transpires behind that locked door that provides the most entertainment, and what happens is a lot of fun with a twist of betrayal!

I played this game with three of my friends, but it can be played with up…