Preamble
It just so happened that “on duty” I need IRC every day. The client used is irssi in tmux on the Debian server. In 99% of cases, I connect via ssh (putty) to the server, then I go to the irssi window and read / write to the channels I need. The remaining 1% is the connection to the proxied irssi channels using Mirand.
For my individual channels, I’m set up emailing messages that meet certain criteria. This thing continues to work now.
But not so long ago, due to some lifestyle change, I stopped using miranda, and it became necessary to read / write to one channel from a smartphone.
I have a smartphone on Android, so it is logical that I first tried to find a native application that would allow to work with irssi proxy. Not found. If you forget about the proxy, then there are still native IRC clients, but this is “not that coat”. So in order not to miss the right message, you need to constantly be online. Yes, and a new account is needed, but it is not always possible. In general, with this approach, it is then easier to connect to the server via ssh and work with irssi there. Actually, I sometimes did that when I really needed it. But ssh-clients for Android leave much to be desired - in principle it is real, but completely inconvenient (especially on the 4-inch screen of my old Samsung Galaxy S).
')
On the other hand, I am very used to Google Hangouts. You can spit, throw stones at me, remember WhatsApp and other IM clients, but it's hard to convince me. Hangouts are really handy. Therefore, I did not cease to rebel the idea of a gateway between IRC and Google Hangouts. Googling gave zero information. Is that a couple of times I ran across a bunch of words irssi + bitlbee. I have already heard about bitlbee before, but did not want to bring up another service on the server.
I have already agreed to just send the content of messages to my Hangouts account (similar to email notifications). Almost it turned out (via sendxmpp). Messages seemed to be getting there, but they only appeared in a third-party client (Miranda), but not in their own Hangouts. And sending was possible only from a non-angled jabber-account (jabber.org, jabber.kiev.ua). For a google account, sendxmpp persistently gave an error, no matter how I fought with the parameters. And I didn’t want to rewrite this softphone.
In the end, I decided to try a bunch of irssi + bitlbee. What is really there? If it does not work, I can always carry this case.
And you know, it worked!
Actually, the decision
For convenience, we create a new Google account that will serve as a bot. All messaging with IRC will be conducted through this account. You can, of course, try to use the recipient account as the sender, i.e. write to myself, but I decided not to pervert. Just added a new account to your Google Apps domain. You can also add alias instead of a full account, but I decided that it would be safer.
Add bot account to bitlbee:
acc add jabber @ set 0 set server talk.google.com acc 0 on
Now an important point. It is necessary to authorize the bot account and personal account between each other. I couldn't do it with the Hangouts. The message exchange in the native client went, but in fact it was the accounts like
<_>@public.talk.google.com
.
So I found nothing better than how to add both accounts to Miranda and authorize them there among themselves. After that, my personal account in the bot's contact list (blist all) in bitlbee began to be displayed with the status Online.
Now we get irssi swiss knife - trigger.pl. To describe the merits of this rich in features plug-in, we need a separate article. Here I will limit my task exclusively.
The general logic of the work is as follows:
- all messages posted on channel X are sent on behalf of the bot to a personal account;
- All messages received by the bot from a personal account are published in channel X.
In the ~ / .irssi / triggers file, this is described by two triggers:
- -publics -channels '#chanX' -command 'msg -localhost -nick PERSONAL_AKK $ N: $ M'
- -privmsgs -masks PERSONAL_ACC -command 'msg -SERVER -channel #chanX $ M'
For experienced users of irssi and trigger.pl, everything should be clear. For beginners I will describe in more detail:
- for everything that is published in the public (-publics) channel (-channels) with the name #chanX, execute the command (-command): send a message (msg) to the user (-nick) with the name PERSONAL_ACC on the server localhost, where the message consists of the sender ($ N) on the channel and message text ($ M);
- for all private messages (-privmsgs) received from user (-masks) with the name PERSONAL_ACC, execute the command (-command): send a message (msg) to the channel (-channel) with the name #chanX on the server SERVER with the text of the message $ M .
The following assumptions are used here:
- Irssi has connections to several servers;
- connection to bitlbee is set as localhost (bitlbee is running at 127.0.0.1, since I don’t want to port 6667 to the world);
- The username on the channel #chanX matches the username on the channel & bitlbee;
- PERSONAL_ACC is the username in the botlbee bot's contact list, which can be changed (help rename);
- SERVER is the name of the server in which channel you want to post messages.
Result
After receiving the first message (no matter from whom - from a bot or from a personal account), a new window will open in irssi with personal correspondence of these two accounts. Well and, accordingly, messages from the channel will come to Google Hangouts, and it will be possible to send messages to the channel.
I also refused to proxy on irssi (as unnecessary).
Epilogue
The possibilities of trigger.pl are very broad. Here, in passing, perhaps less than 10% of the possibilities are considered. Triggers can be configured more flexibly, and using regular expressions you can “paint everything at all” ©
So, besides the variables $ N and $ M, there are many other variables available. You can send messages from several channels, only from certain users or containing certain keywords, depending on the keyword, post a message to a particular channel, broadcast all personal correspondence, etc. For details, see the help / trigger help.