Finally, it would be great to know if our bot was alive and kicking, or being lazy and taking a break from its duties and having a rest. To determine this information, we'll need to use presence
and presence subscriptions
. First, we'll update our code to tell the server that we're available on connection, make a presence subscription
request to our bot (which it will automatically accept), and then display the presence of the bot on screen.
Let's add a little piece of HTML to index.html
and default the bot to showing as offline (you just can't get the right bots sometimes!):
Now that we have this code in place, our first task is to send our own presence availability to the server once we've successfully logged in. We'll need to update the connected method to send our presence out: