In #utah on Freenode, there has been some active discussion lately about Dvorak vs. Qwerty. As such, ibot, a channel bot, has the ability to display text when someone enters a channel. Some of the chatters, including myself, have a join that is "encrypted". Well, not really, per se, but rather, just Dvorak text that was typed using the QWERTY layout. One such join is as follows:
>>> vontrapp Dr, co yd. Ekrpat jrmcbiZ
Not exactly intuitive as to what is trying to be said. The only way to figure it out, is set your keyboard layout to Dvorak, and type the letters as they would appear on a QWERTY keyboard. Doing so would produce:
>>> vontrapp How is the Dvorak coming?
As we began discussing in the channel, we thought that it would be great if we could have ibot do the decoding for us. Well, I'm not familiar with blootbot or it's scripting capabilities, so I wrote a script for Irssi that can convert any "Dvorak text" to QWERTY and vice versa. The commands to run are '/dv some text here' and '/qw some text here'. When ran, it just puts the the result in the channel in a single line, as to not flood or annoy the channel. The script does not utilize color, but that could be added easily to help identify the difference between the input and output text.
Here is the code below (no syntax highligting. Sorry). Save it as 'dvoark-qwerty.pl' in your ~/irssi/scripts/ directory, and run "/script load dvorak-qwerty.pl" in Irssi.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | # dvorak-qwerty.pl # Aaron Toponce (aaron .toponce@gmail.com) # Decodes dvorak to qwerty and qwerty to dvorak # # qwerty layout (from left to right, top to bottom): _+QWERTYUIOP{}ASDFGHJKL:"ZXCVBNM<>?-=qwertyuiop[]asdfghjkl;'zxcvbnm,./ # dvorak layout (from left to right, top to bottom): {}"<>PYFGCRL?+AOEUIDHTNS_:QJKXBMWVZ[]',.pyfgcrl/=aoeuidhtns-;qjkxbmwvz use Irssi; use strict; use vars qw($VERSION %IRSSI); $VERSION = "0.1"; %IRSSI = ( authors => "Aaron Toponce", contact => "aaron.toponce\@gmail.com", name => "dvorak-qwerty", decscription => "Decodes dvorak-to-qwerty and reverse", license => "GPLv2", changed => "$VERSION", commands => "dvorak qwerty" ); sub qwerty2dvorak($) { my ($text) = @_; $text =~ y/\_\+QWERTYUIOP\{\}ASDFGHJKL\:"ZXCVBNM\<\>\?\-\=qwertyuiop \[\] asdfghjkl\;\'zxcvbnm\,\.\//\{\}"\<\>PYFGCRL\?\+AOEUIDHTNS\_\:QJKXBMWVZ\[\] \'\,\.pyfgcrl\/\=aoeuidhtns\-\;qjkxbmwvz/; # "return "'@_' to dvorak: " . $text; } sub dvorak2qwerty($) { my ($text) = @_; $text =~ y/\{\}"\<\>PYFGCRL\?\+AOEUIDHTNS\_\:QJKXBMWVZ \[\] \'\,\.pyfgcrl\/\=aoeuidhtns\-\;qjkxbmwvz/\_\+QWERTYUIOP\{\}ASDFGHJKL\:"ZXCVBNM\<\>\?\-\=qwertyuiop\[\] asdfghjkl\;\'zxcvbnm\,\.\//; # "return "'@_' to qwerty: " . $text; } sub dvorak_decode( ![]() { my ($arg, $server, $witem) = @_; if($witem && ($witem->{type} eq 'CHANNEL' || $witem->{type} eq 'QUERY')) { $witem->command('MSG ' . $witem->{name} . ' ' . qwerty2dvorak($arg)); } else { print qwerty2dvorak($arg); } } sub cmd_qwerty($$$) { my ($arg, $server, $witem) = @_; if($witem && ($witem->{type} eq 'CHANNEL' || $witem->{type} eq 'QUERY')) { $witem->command('MSG ' . $witem->{name} . ' ' . dvorak2qwerty($arg)); } else { print dvorak2qwerty($arg); } } Irssi::command_bind('dv',\&cmd_dvorak); Irssi::command_bind('qw',\&cmd_qwerty); Irssi::signal_add('message public', sub {dvorak_decode($_[0], $_[4], $_[1]);} ); Irssi::signal_add('message own_public', sub {dvorak_decode($_[0], $_[2], $_[1]);} ); print "%B>>%n " . $IRSSI{name} . " " . $VERSION . " loaded"; |
{ 3 } Comments