It all started when @ndoto replied to one of my â€œeeyupâ€ tweets saying that he wished there was a Big Macintosh Twitter bot that would reply with an â€œeeyupâ€ if you sent a tweet containing â€œeeyupâ€.
For those who arenâ€™t in the know, Big Macintosh is a character on the cartoon My Little Pony: Friendship is Magic. Itâ€™s a slight re-imagining of the original show, headed by the same creative mind behind Fosterâ€™s Home for Imaginary Friends â€“ an awesome show with clever writing. Needless to say, that same maturity (but kid-appeal) carries over to the new My Little Pony. I suppose I should clarify that Iâ€™m not enough of a fan to call myself a brony, but I do think the show is about 20% cooler than most other things on television â€“ and Big Macintosh is by far my favorite character. :)
Iâ€™ve always wanted to make a Twitter bot, so I jumped at the opportunity. In this post, Iâ€™d like to share some of the technical details, and decision making, that brought @BigMacinbot to life.
The first thing I had to decide was how I was going to interface with Twitter. From my experience with Trowl, I figured I could throw together a simple C# program, running on my home computer, using the Twitter library I had already created. The downside, though, is that if my internet connection went down, or my computer powered off, the bot would go quiet. So instead, I decided to write a PHP script, and host it on my remote server space. Iâ€™d also use cron to automatically run the script every five minutes. Finally, since I was already familiar with the Twitter API, I didnâ€™t feel the need to write the API calls from scratch. I used a PHP Twitter library, tmhOAuth, that had everything I needed, and was simple to use.
With that decided, I turned my attention to how the bot, itself, would work. It seemed very simple at first: search Twitter, then send a reply to every tweet containing â€œeeyupâ€. As I kept thinking about it, though, I realized just how annoying that would be. If someone used that phrase often enough, theyâ€™d end up being spammed by the bot. The point of this was to have a bit of fun, not annoy people.
To confirm my suspicions, I created a very simple script that just did the â€œsearch Twitterâ€ part, and emailed the results. I let this run over the course of a couple days and, indeed, more people than I expected used â€œeeyupâ€ — and used it frequently. With this in mind, I started to create a set of rules that a tweet would have to pass through before the bot would send a reply:
Big Macintoshâ€™s Rules of Agreement
- Tweet was sent within the last two hours.
- Not a retweet
- Tweet says â€œeeyupâ€ somewhere. (Twitter name cannot contain â€œeeyupâ€.)
- User isnâ€™t being ignored. If a user really doesnâ€™t like Big Macinbot, they can reply with â€œnopeâ€, and theyâ€™ll never receive another reply.
- The user has never received a reply from Big Macinbot, or they havenâ€™t received a reply recently. The definition of â€œrecentlyâ€ is based on probability. If the last time the user received a reply was within two weeks, Big Macinbot looks to see how long ago it was. The closer to two weeks, the more likely a reply will be sent. After two weeks, a reply is definitely sent. Here is the code, for those interested:
1: $diff = time() â€“ $previous_reply_timestamp;
2: $prob = ($diff / 1209600) * 100; // Number of seconds in two weeks.
4: $rand = rand(1,100);
6: if ($rand > 1 && $rand < $prob)
8: return true;
Coding these rules wasnâ€™t too difficult â€“ the trickiest part was building a simple database to keep track of users, and when their last reply was sent. Relying on a database makes the script a bit more complex, but the ability to stagger Big Macinbotâ€™s replies makes it worthwhile.
After implementing this base functionality, I wondered what should happen if someone replied to Big Macinbot. Most other bots, as far as I knew, didnâ€™t do anything if you replied or mentioned them. But I didnâ€™t want to miss out on a chance to give this bot a little more personality â€“ it would still respond with â€œeeyupâ€, but the interaction could be fun. Since I was already checking mentions for ignore requests, I just added another case that sent a reply back if it was a normal mention. To build upon the goal of adding some more personality, I actually have Big Macinbot choose from three random responses: Eeyup. / Eeyup! / â€¦ Eeeyup?
Another reason for the random responses is to try and get around Twitterâ€™s â€œduplicate statusâ€ error â€“ Twitter denies a status posting if itâ€™s the same as your previous status. Unfortunately, it seems as though Twitter doesnâ€™t just check your last status, like I thought, but all of your recent statuses. So right now, once someone exhausts the three random responses, Big Macinbot goes quiet due to Twitter errors.
At the beginning, though, I wasnâ€™t even sure if anyone would bother replying. Everything else was in place, and seemed to be working, so it was time to move forward. On Saturday, January 14, 2012, Big Macinbot came to life.
I have to admit that about halfway through coding the bot â€“ about the time that I was perfecting the Rules of Agreement â€“ I wondered if I should keep going. I started to think that no one was going to like the bot; that everyone would block and it would be done within a week or two.
Well, all I can say is that Twitter bronies are awesome! Not only does everyone seem to love Big Macinbot, but they reply to and follow the bot on a regular basis. It has been fun seeing the reactions, and the general love for Big Macintosh. Iâ€™ve had the pleasure of discovering a few very nice folks, too, so that has been a wonderful bonus. :)
Because of Big Macinbotâ€™s popularity, Iâ€™ve been making regular tweaks and updates to how he works, and Iâ€™m currently working on a suggestion to have Big Macinbot reply to everyone when being mentioned. I never expected him to gain such a following, but Iâ€™m really happy he did, because I think heâ€™s a really fun bot! I just hope Twitter doesnâ€™t suspend the account â€“ Iâ€™ve tried to be light on Twitterâ€™s resources, and follow best practices, so hopefully theyâ€™ll let him keep going. Eeyup!
Iâ€™d like to finish this post with some of my favorite reactions and replies to Big Macinbot. Thank you again to everypony for such a wonderful welcome to Twitter! If anyone has suggestions, or questions about what I wrote about here, please feel free to post a comment, or send me a message at @mageuzi! :)
@AH_Dylon Dude, I just had an encounter with the best Twitterbot ever.@BigMacinbot. So legit.
â€” Chris P. Come here! (@tictac472_FTW) January 14, 2012
@BigMacinbot I LOVE YOU.
â€” Justin Bieber fan.à²Œ(@HackedByBieber) January 15, 2012
@BigMacinbot :3 that made my day
â€” DMName (@SirDMName) January 15, 2012
Eeyup.RT @foalpapers: Eeyup. RT @IndieLexy: Eeyup RT @HybridMisfit: Eeyupception? RT @Tempy_: RT @foalpapers: Eeyup. RT @BigMacinbot: Eeyup.
â€” Lexy (@IndieLexy) January 20, 2012
@BigMacinbot I agree
â€” Please Stand By (@StandbyPlease) January 19, 2012
â€” Big Macintosh (@BigMacinbot) January 17, 2012
â€” Big Macintosh (@BigMacinbot) January 16, 2012
@BigMacinbot This conversation seems one-sided.
â€” Philip Kardefelt (@Terkup) January 17, 2012
â€” Big Macintosh (@BigMacinbot) January 16, 2012
I use “Eeyup” in casual conversation, testing for random bronies that might be nearbyâ€”no luck so farâ€”but I use it on Twitter with the express purpose of soliciting replies from @BigMacinbot. He really, really makes my day sometimes. -:)
Thank you SO much!
i highly doubt twitter will bann this bot
heck urbandictionary runs a bot and it no doubt uses loads more twitter resources then this bot