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.
The following Perl modules should be installed:
On Debian based systems you may want use the following command line:
aptitude install libnet-jabber-bot-perl libnet-twitter-perl libtimedate-perl libdatetime-format-dateparse-perl libdatetime-format-strptime-perl libhtml-html5-entities-perl libhtml-entities-numbered-perl libdata-dump-perl libswitch-perl liburi-find-perl curl
If you cannot find these packages in your distribution’s repository you’ll have to install them manually. Example for installing
perl -MCPAN -e shell
cpan> install Net::Jabber::Bot
All configuration stuff is located in
- 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
- Create a new Twitter App at https://dev.twitter.com/apps
- Store in your access tokens in
- Store your consumer key and secret in
It’s quiet obvious to me that the setup is more or less confusing. So don’t be afraid to ask me for help.
Just run the script with
perl -w j-vs-t.pl
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:
- list of available commands
- !follow [USER]
- follow the user USER
- !unfollow [USER]
- stop following the user USER
- !profile [USER]
- print the profile of USER
- list the users you are following
- 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:
Failed to re-connect: error
You can download this tool from GitHub.
The latest sources can be obtained from
git clone https://github.com/binfalse/jabber-vs-twitter.git