Cry Bot

Last edited: 9 July 2017, 6:03PM


This is a small Facebook/Discord chat bot that keeps track of the number of crying faces used in conversations it is a part of. Well, technically, it's supposed to be a :joy: face since there are better crying emojis out there, but I'm going to push those details aside. I also have to thank Michael with his work on MikalBot, as that's what I used as a huge basis for this.


Honestly, I'm not even sure I should even be writing about this project. This bot only has two features, !cry to send a cry emoji into chat and !count to return a count of crying faces so far. The whole thing is less than 50 lines long, and it cost me a couple hours to make. But I guess despite everything, some of the history behind this is pretty interesting at least to me, so I'll see it through.

So I'm part of a really active Facebook group chat with some of my friends. Most of these guys are from osu! UCI, though we do have an odd person or two who aren't a part of it. One day, one of us stumbled upon MikalBot and added it to our chat. It keeps track of how much you talk and interact in a group chat, with fancy charts and everything. Also, I know I wrote my past 30 projects in past tense, but we're going to stick with whatever tense I feel like now.

Anyways, MikalBot was a double edge sword. On one hand, it promoted a lot more talking and some friendly rivalry between the members, but soon it became a whose dick is bigger competition. The whole conversation got derailed into nonsense posts and spam. I think it did more harm than good, but I could tolerate it and its side effects. Finally, I don't know if it was one of us that removed it or maybe the bot reset itself, but eventually we did away with it and peace was restored(?).

I didn't really make much of it then, but I did wonder how Michael made the bot. He posted up the source code for Mikal, and I caught a glimpse of it. I'm very inexperienced with JavaScript/Node, so his code's still somewhat confusing to me. At the very least I could see that he used an unofficial Facebook chat library to hook up to conversations.

It wouldn't be until a while later when I considered making a bot myself. In the osu! UCI group, the crying face became our default chat emoji, and I think we all liked it pretty ironically. I don't really know why it got so popular among us. I guess it's got that sad yet happy look going on at the same time, a perfect representation of our lives. I suppose meme factor-wise, it beats out all the rest.

So with it being so popular in our group, I decided to maybe give a shot at writing a bot to keep track of its usage. After finishing up a storyboard for Royce's map and waiting a bit for the club's beatmap to come together, I took some time out to do this. I actually put it off for a while to play like a million hours of ARAM. That's another story, but when I got around to writing this, it wasn't that bad at all.

I don't think there's too much to say about the actual coding part. Callbacks were a little weird, for sure, but not unmanageable. The documentation for the chat api and low were pretty thorough. It was pretty fun working back in a language I haven't visited in a long time. I don't imagine I'll stick around with JS, however, since I'm probably just going back to C++ for storyboard work.


Some time has passed now, and I've just updated the bot to support Discord conversations. Royce told me I should do it, and since I was doing things on my server at the time, I looked into it and thought why not. At the time, I was addressing a pretty critical major issue where my server was pretty much completely out of disk space. It actually took me quite a while to figure out what was wrong.

After df-ing and du-ing a while, I finally figured out after looking into hidden files that my forever log was something like 10 gigs, half of my server's total allocated space. I don't know why forever was logging so much, or if I should be concerned, but I just deleted everything, rebooted, installed updated, rebooted again, and everything just werked.

Maybe possibly related but probably is the problem, I ran into an issue in the past with the chat bot, where it would blow up and disconnect for seemingly no reason. I couldn't figure out why it was dying, so every hour or so I think I made it relogin and reconnect. I don't know. Putting another bandaid on a gunshot wound, but whatever it works.

Anyways, I looked into discordjs. It was pretty easy to follow and setup. I had a lot of reusable code from the Facebook bot, so I adopted that, and that's pretty much that. Fairly simple and just took maybe an afternoon's work.

As of July 2017, I've decided to retire this and the CLG Retweet bot until further notice. I'm busy with other projects at the moment, and I want to focus my attention on those without having to fix and look at old issue. Thanks to all, my friends, who've been using it.