One of the best parts of my previous job—and also the part that kept me going for so long—is that I had the chance to work on a variety of projects, in many cases for completely different business ventures. One week I had been privileged with the task of writing a small program which ended up being semi-intelligent (of course artificially, thus AI). As it so happens I also seemed to have stretched PHP to its limits.
When originally typing up this post, I kept the details to a minimum, but now that I’ve moved on I can freely discuss it. This program—code-named “twitterbot”—was tasked with searching Twitter for tweets with certain keywords within a radius of a location, like for tweets containing “hungry” within 30 miles of Minneapolis, and @reply to that person within an hour of their tweet about … a website I probably shouldn’t name. However this becomes tricky since Twitter is really good at detecting spam, and a lot of Twitter users really hate spam (like me). To get around it, I made a bunch of twitter accounts using anonymous email addresses, created bios, set profile pictures, and set color schemes, all to make them look like real people.
However, just because a Twitter account has a profile picture, it does not mean it will be treated like a human: the account has to have realistic-looking posts. No problem. First I set a limit to the number of posts an account can make per day, make sure all the posts are within normal waking hours (like 6am to 10pm), have 30-50% of the tweets be the spamming tweets, and the rest be copies of tweets from a different search that none of the accounts will be replying to. Then since the spam tweets themselves are also randomized, the sum of it all equals twitter accounts that even people are sometimes not able to recognize that the account is a bot.
For the technical, I wrote this program in PHP both because we had thousands and thousands of lines of legacy code in other programs that we didn’t want to touch, and second because it is extremely simple and quick to code and deploy. With a semi-AI bot though, the scene changes and suddenly both opportunities and concerns that weren’t there before suddenly are. Example opportunity: pcntl-fork becomes available. Example concern: the PHP program will probably be running as a daemon on a server, use up all your RAM and explode.
In the end, the bot ran strong for about 2 weeks before management changed their minds and had it shut down—spamming people does not make for good press. I felt terrible having to write such a program; I really don’t like spam, let alone being the one doing the spamming. But since then I’ve moved on to a position at a different company and write ethical code now.