Jabber -vs- Twitter
Perl bot to interact with Twitter via Jabber.
This bot is sending you news from Twitter to your Jabber account and sending status updates from Jabber to Twitter. It’s free, open source and after some setup it’s very easy to use! A sample usage of interact with the bot from Gajim can be seen in figure 1.
Dependencies
The following Perl modules should be installed:
- Net::Jabber::Bot
- Net::Twitter
- Date::Parse
- HTML::Entities
- DateTime::Format::Strptime
- Data::Dumper
- Switch
- URI::Find
On Debian based systems you may want use the following command line:
If you cannot find these packages in your distribution’s repository you’ll have to install them manually. Example for installing Net::Jabber::Bot
:
Configuration
All configuration stuff is located in j-vs-t.conf
.
- copy `src/j-vs-t.conf.sample` to `src/j-vs-t.conf`
- Set up a Jabber account. Some popular servers can be found at http://www.jabberes.org/servers/.
- Set up a Twtitter account at http://twitter.com/
- Fill in your Jabber credentials and serversettings in `j-vs-t.conf`
- Create a new Twitter App at https://dev.twitter.com/apps
- Store in your access tokens in `j-vs-t.conf`
- Store your consumer key and secret in `j-vs-t.pl` in `$APPKEY` and `$APPSECRET`
It’s quiet obvious to me that the setup is more or less confusing. So don’t be afraid to ask me for help.
Usage
Just run the script with
from wherever you want. All you need is Perl and a internet connection.
For the first time you are asked to visit a website to authenticate. This website will offer a pin to you, provide it to this bot and see how fine it works.
White the tool is running it sends status updates in your Twitter time line as messages to the authorized account. Replies and retweets are send separately.
Each message that arrives from the authorized user to the Jabber account the bot is listening on will be send to Twitter as status update. But keep in mind to leave them shorter than 140 chars, otherwise the bot won’t send it and gives you an reply informing you about your failure.
In addition you can send some command to the bot. These command start with an exclamation mark (!). Each message starting with ! is expected to be a command.
The following commands are available:
- !help
- list of available commands
- !follow [USER]
- follow the user USER
- !unfollow [USER]
- stop following the user USER
- !profile [USER]
- print the profile of USER
- !following
- list the users you are following
- !followers
- list the users that follow you
- !retweet [ID]
- retweet message with id ID (last number in jabber message)
- !favorite [ID]
- favorite message with id ID (last number in jabber message)
If the following error occurs you should check the credentials of the Jabber user:
Download
You can download this tool from GitHub. The latest sources can be obtained from
Leave a comment
There are multiple options to leave a comment: