Skip to content
kovshenin edited this page Dec 30, 2010 · 5 revisions

However you got here in the first place? Ugh, anyway.. Welcome to Twibots. If you have never heard of such a term before, then you probably shouldn't be here. Otherwise, keep reading.

The Twibots Platform

Robots? Artificial Intelligence? Yup, this is what Twibots is all about - Social Robots designed and developped to live among humans in the social media world.

Twibots is a project launched back in November 2009 by Konstantin Kovshenin. The general idea behind Twibots is to create a rock-solid platform which would be able to host long-living functional robots, capable of joining social networks and imitating activity. The goal of Twibots is NOT to create social spambots, but more of intelligent social feeders, which will be able to participate in a community, gathering data into conversation lists, followers, etc.

Twibots right now is a set of Python modules that could be imported in any project of yours and used (wisely).

So, what is a Twibot?

A Twibot is a pre-configured instance of a social robot, which as a background process. The life cycle of a robot depends on it's configuration, may be a few seconds, minutes, hours, months, or an infinite loop. A twibot's configuration is:

  • A set of sources which define where data comes from (RSS feeds, Twitter Search, etc.)
  • One or more social channels which define where data goes to (Twitter, Facebook, etc.)
  • A set of filters which may be applied to channels, sources and twibots themselves.
  • So-called writables which store data and go back and forth between channels, filters and sources.

Such a simple, yet powerful data structure allows Twibots to be extended via modules and social channels, share data between two or more modules and filter all outgoing data with a pre-defined (and extensible) set of rules in order to avoid being annoying, spammish and be more smart and intelligent.

Gimme an example!

Ever wanted to create a Twitterfeed clone? Well, here's one in the Twibots language:

import time
from twibots import tb, sources, filters, channels

twibot = tb.Twibot()
rss = sources.RssFeed(feed_url="http://kovshenin.com/feed")
twitter = channels.Twitter()

twibot.sources.append(rss)
twibot.channels.append(twitter)

for life in twibot.live():
    time.sleep(30) # sleep 30 seconds

That's about it! Note that I've omitted the part where you have to authenticate a Twitter channel with a valid Twitter account, but this happens via OAuth, is quite smooth and simple, but the general idea is illustrated.

Filters? Hmm?

Good question, filters let you do anything. Let's extend the example above and add a couple of filters so you'll get a taste of what they're capable of:

twitter.filters.append(filters.Bitly(username='username', api_key='key'))
twitter.filters.append(filters.InlineHashtags())
twitter.filters.append(filters.TagsToHashtags())
twitter.filters.append(filters.Trim140(max_length=100))

Awesome, so the Bitly filter will shorten our permalinks coming in from RSS feeds, the InlineHashtags filter will ehh, how do I explain this.. An entry in the RSS generally has a title, categories and a bunch of other stuff. Well the RssFeed source converts that into a Writable object, which contains the title and the categories as tags. The InlineHashtags grabs those tags and saves some extra space, for instance:

Google Unveils Nexus S! Wow, I'm so happy! Dumping my old phone and getting that new piece! Cool! http://google.com (tagged: google, nexus, android)

So the output would be:

#Google Unveils #Nexus S! Wow, I'm so happy! Dumping my old phone and getting that new piece! Cool! http://google.com (tagged: android)

Smart, eh? This is sort of what Feedburner can do. So the TagsToHashtags filter converts the remaining tags into hashtags, so the final output is:

#Google Unveils #Nexus S! Wow, I'm so happy! Dumping my old phone and getting that new piece! Cool! http://google.com #android

Dang! The final filter, Trim140 simply trims down your final message to fit 100 characters (see the max_length parameter), by removing tags, then reducing the words in the title, and finally raising an exception if the tweet is still too long (perhaps the URL shortener didn't work out). And the final output (approximately):

#Google Unveils #Nexus S! Wow, I'm so happy! Cool! http://google.com

There we go, hope that explains it ;)

What's next?

Get in touch, I'm @kovshenin on Twitter.