TwIrssi on Slackware
What is Twirssi?
Twirssi is a Perl script that allows you you to read and post to twitter from your favourite IRC client. The reason for writing this page is highlighting how to get it to run on Slackware. It seems to work well and above all, it is still in active development!
What do you need?
- A Functional install of Slackware (12.2 is recommended, but it’ll work on 12.1)
- screen – A terminal multiplexer.
- irssi – a very good and decent irc client (the best in my opinion)And possibly (although you can use it without):
- bitlbee – an IRC instant messaging gateway.
I am not going to highlight how to set up irssi and screen together, nor what to install on Slackware or have installed. Basically that kind of information is outside the scope of this page, and you would have irssi installed anyway if you are looking for this.
A quick word about CPAN:
Probably an easier way to install Perl Modules is to use CPAN. CPAN is short for the Comprehensive Perl Archive Network. It offers an easy way to access the Perl Modules. Among others if offers ‘dependency’ resolution. So if you are a bit more lazy you probably can install the three main Modules from CPAN (as mentioned below), and let the underlying dependencies be resolved.
For more information, either look at the CPAN Wikipedia page, or cpan(1)
So, why not use CPAN?
The reason for this is two fold: I prefer to use SlackBuild scripts instead of CPAN as this gives me a better control of what exactly gets installed on my system. Also it makes it a lot easier to maintain the various perl modules, especially over version humps with perl and Slackware. If you want to install it using cpan, here’s how (thanks to Mark Walling):
# cpan
> install Net::Twitter
> install WWW::Shorten::TinyURL
Installing the needed Perl Modules:
The complete dependency tree is highlighted in this post. For this Howto page, I am just going to highlight the build orders. For general instructions on how to use the SlackBuild scripts, please follow the SBo HowTo.
To verify the validity of the tarballs, you can use the following command:
gpg --verify $filename.tar.gz.asc
You will two different set of GPG-KEYS. You’ll need the one from SlackBuilds.org for their packages, as well as my personal key for those packages that I host.
Note, that the below perl modules and their dependencies are grouped and listed in (what I think their most logical build order. YMMV). Just to explain perhaps in more detail:
- To Build LWP::UserAgent, you will need perl-html-parser.
- To Build perl-html-parser, you will need perl-html-tagset.
The first set of modules you need to install is libwww-perl and it’s dependencies for LWP::User-Agent.
| perl-html-tagset | Build files | tarball | gpg signature |
| perl-html-parser | Build files | tarball | gpg signature |
| — | — | — | —- |
| LWP::UserAgent | Build files | tarball | gpg signature |
.
While not strictly needed (TwIrssi will run without this, but throw up an warning), it is nice to also compile WWW:Shorten::TinyURL. (Note that WWW::Shorten::TinyURL will need the LWP::User agent installed to build)
| WWW::Shorten::TinyURL | Build files | tarball | gpg signature |
.
The following set of modules you need to install is the JSON::Any Perl Module and it’s dependencies:
Note that JSON::Syck and JSON::DWID, are just dependencies of JSON::Any, and don’t need anything else to compile. JSON::XS is an optional but preferred dependency of JSON. If you choose not to install JSON::XS, JSON will fall back to it’s own internal JSON::PP module which is compatible with JSON::XS.
| JSON::Syck | Build files | tarball | gpg signature |
| JSON::DWID | Build files | tarball | gpg signature |
| — | — | — | — |
| JSON::XS | Build files | tarball | gpg signature |
| JSON | Build files | tarball | gpg signature |
| — | — | — | — |
| JSON::Any | Build files | tarball | gpg signature |
.
Net::Twitter also requires the use of both Test::Exception and Sub::Uplevel. Two dependencies that I previous missed.
| Sub::Uplevel | Build files | tarball | gpg signature |
| Test::Exception | Build files | tarball | gpg signature |
.
After all of the above scripts have been build/compiled and installed, we can finally compile the needed Net::Twitter module.
| Net::Twitter | Build files | tarball | gpg signature |
.
With all of the above perl modules installed, we finally can move on to installing and running TwIrssi.
Installing the script:
One you have downloaded and installed all of the above Perl Modules, you can download the twirrsi.pl script from the TwIrssi website.
Remove the old script first:
rm ~/.irssi/scripts/twirssi.pl
Download the latest script from the TwIrssi website:
wget -c http://www.twirssi.comtwirssi.pl \
-O ~/.irssi/scripts/twirssi.pl
From TwIrssi 1.3, it seems to be possible to actually update TwIrssi from within irssi, by just running the command: /twirssi_upgrade
If you want it to automatically load with irssi, link the script from ~/.irssi/scripts/autorun
mkdir -p ~/.irssi/scripts/autorun
cd ~/.irssi/scripts/autorun
ln -sf ../twirssi.pl
Set up irssi to use twirssi
If you don’t already have a twitter window, create a new window:
/win new hidden
Name the new window:
/win name twitter
Load the script in irssi:
/script load twirssi.pl
Log in to twitter:
/twitter_login username password
From version 1.4, TwIrssi now supports auto-login features. To enable this you need to type the following commands:
/set twitter_usernames username
/set twitter_passwords password
You can supply more than one username/password as it is being read as a comma-seperated list. Once you have stored your passwords for twirssi, you can now login with:
/twitter_login
Every 5 minutes, new updates from twitter will be posted to the named window. To manually poll, you can always type /twitter_updates, though if you do it too often, twitter will block your access for a while. From this point onwards you can start posting and reading your tweets straight from your favourite IRC client.
Settings and other information
The TwIrssi website has a lot more informations on the various settings and runtime configuration. Duplication should only be taking so far.
Various fixes and gotchas.
Occasionally twirssi has the problem that it forks off irssi processes which can fill your system up pretty quick. The solution for this was highlighted on this blog. and discussed on #linode @ irc.oftc.net
To get rid of all the processes, do this, find out how many processes are running on your computer:
ps aux | grep irssi | grep defunct | wc -l
Then use the number of that as substitute for N in the string below.
/script exec for ($i = 0; $i < N; $i++) { wait;}
After that unload and reload the twirssi.pl script. Now the defunct processes that got forked should have been neatly cleaned up from your system without you having to restart irssi.
What I would like to see in TwIrssi:
- Auto login features. (present in twirssi >= 1.5)(I know this is on the to-do list anyway). Perhaps a way to parse ~/.irssi/config for a “twitter server setup”. Not sure how this would effectively be handled. It would enable storing all your passwords in one place, which admittedly, is both a good and a bad thing.
- The ability to have the window highlight if anything show up related to my name. (fixed in twirssi >= 1.78)
- Instead of having to name a window, make it sort of work on a server/channel tag.This would be much in line with how bitlbee does things. However I am willing to accept that might be beyond the scope of what TwIrssi was intended to do. And I know bitlbee is a bigger program than TwIrssi is.
- Ability to show the latest ${x} amount of tweets on login.
–Enjoy!
very nice ^_^