Twitter Bot: Magic 8 Ball
April 22nd, 2008 at 7:24 PM (17 years ago) by Matt FreedmanOn the Weekend, Gary Jones from BlueFur (Twitter: bluefur) came up with the idea of a Twitter robot that would act as a Magic 8 Ball. He asked me if I wanted to help make it, I accepted, and development began.
What we came up with was a small script that would automatically reply with a Magic 8 Ball-type answer when it was “replied” to. To use it, all you have to do is write a “tweet” replying to magic_8ball with a yes or no question. Which would look like this “@magic_8ball <yes or no question>”.
This little “Twitter Bot” uses the Twitter API to receive the replies to it, and then send out replies with a randomly selected answer. We quickly found out that the Twitter API is quite restrictive. As outlined in Gary’s post, Twitter only allows 70 authenticated API requests an hour, which not only inconveniences developers while testing their Apps, but also users using Twitter Apps. Also, Twitter restricts API calls for replies and such to the latest 20, which can create quite a few problems.
We’ve decided to make this application Open Source, so that other developers looking to develop with the Twitter API can hopefully learn from our code. Feel feel to use, modify, hack and learn from this code to create your own Twitter Applications. The code is release under the GNU General Public License version 3 (or, at your option, any later version). You can get the code here (or in txt format here).
If you have any questions about the code, feel free to let me know.
I’m on Twitter under mattfreedman, feel free to follow me.
Find something useful here? Feel free to help me out by sending a donation. :)
5 Responses to “Twitter Bot: Magic 8 Ball”
Leave a Reply
June 30th, 2008 at 2:07 PM | Quote Comment
Thanks for sharing, we are going to be looking into creating a fun bot and I can imagine that your source will only help us. Thanks!
September 15th, 2008 at 6:34 PM | Quote Comment
mad idea – trying it out myself, but keep getting error410 (Could not authenticate you)
using the right login password, can’t figure it out. this is the first time i’ve played with the twitter api, so i’m probably missing something fairly obvious.. =P
September 15th, 2008 at 7:21 PM | Quote Comment
This code is out-of-date now (Twitter changed some API things awhile ago) and isn’t actively maintained. However, it shouldn’t be too hard to fix, if you have some time check out the Twitter API Documentation. Building this little bot was a great learning experience, and updating it should be the same.
Besides, nobody ever used our @magic_8ball bot (and it’s obviously broken now). 😉
February 3rd, 2009 at 11:32 AM | Quote Comment
[…] good idea does not merit implementation. Incidentally, it looks like someone else did work on a similar project (though that looks to have gone extinct now […]
April 27th, 2009 at 12:07 AM | Quote Comment
Heh, I was 3/4 of the way through completing my own, when I decided to google if this has been done before. It is a great learning experience though.
Mine is @8ball_