This is a request by a forum user named CrAnk who asked if it's possible to replace two-letter country codes with their actual country names shown in users addresses. (if shown) I thought I would give it a shot and here is the finished product:
e.g CrAnK (CrAnK@XXXXXXXXXX-***.libero.it)
will result in:
CrAnK (CrAnK@XXXXXXXXXX-***.libero.Italy)
To enable it, initiate the switch via the popups.
I know you may wonder why I use a socket. My main purpose is to borrow the efficiency of socket and pull the country codes into a hash table for later reference, merely for convenience's sake.
UPDATE: Thanks to SnoooP who found a little bug. I have updated the script, along with the add of hsave command when you exit or get disconnected (making it only remove everything completely when you have disabled the script), and a check to see if the script has been turned on already.
on *:start:{
ccload
}
on *:connect:{
ccload
}
on *:exit:{
hsave -o cc cc.hsh
}
on *:disconnect:{
hsave -o cc cc.hsh
}
alias -l ccload {
if !$hget(cc) {
hmake cc 5
if $isfile(cc.hsh) {
.hload cc cc.hsh
}
}
}
on *:sockread:cc:{
var %cc
sockread %cc
tokenize 32 %cc
if $rid($1) {
sockmark cc $v1 $2-
}
if </PRE> isin %cc {
sockclose cc
}
if $sock(cc).mark {
write cc.txt $v1
}
}
on *:sockopen:cc:{
var %c sockwrite -n cc
.timercc 1 2 read
.timerdel 1 3 write -c cc.txt
%c GET /Generic/countries.htm HTTP/1.1
%c Host: www.paladinsoftware.com
%c $crlf
}
alias -l rid {
return $remove($1,<p>,<pre>,<HTML>)
}
alias -l read {
var %r 24
while $read(cc.txt,%r) {
hadd -m cc $v1
inc %r
}
}
menu channel,nicklist,menubar,status {
Enable Country Codes {
if !$isfile(cc.txt) {
if $sock(cc) {
sockclose cc
}
sockopen cc www.paladinsoftware.com 80
echo -a * Country Codes have been activated!
}
else {
echo -a * Country Code was already activated!
}
}
Disable Country Codes {
$iif($hget(cc),hfree cc)
$iif($isfile(cc.txt),.remove cc.txt)
$iif($isfile(cc.hsh),.remove cc.hsh)
echo -a * Country Codes have been deactivated!
}
}
on !^*:quit:{ cc }
on !^*:join:#:{ cc }
on !^*:part:#:{ cc }
alias -l cc {
haltdef
noop $regex($fulladdress,/(.*?\100)/)
var %r $regml(1)
if ($hget(cc)) && ($regex($site,/.*\56(\w{2})$/)) {
var %q $comchan($nick,0)
while %q {
if $me ison $comchan($nick,%q) {
var %v2 $v2
if $event == quit {
echo -bfilmrt %v2 * $+(%r,$regsubex($site,/( $+ $regml(1) $+ )$/,),$&
$hget(cc,$hfind(cc,$regml(1),1,w))) has quit %v2
}
else {
echo -bfilmrt %v2 * $+(%r,$regsubex($site,/( $+ $regml(1) $+ )$/,),$&
$hget(cc,$hfind(cc,$regml(1),1,w))) has $iif($event == part,$v1,join) $+ ed %v2
}
dec %q
}
}
}
}
(23:52:10) * Snoopy!Bertrum@989981.965c23.a13d28.ad1 has quit #Paradox
(23:52:10) * Snoopy!Bertrum@teSao Tome and Principe.Sao Tome and Principea has joined #Paradox
(23:52:10) * irc.ParadoxIRC.net sets mode: +v Snoopy
-
Snoopy is Bertrum@test.star * http://IRC-Wiki.org
(23:53:26) * Snoopy!Bertrum@testing.f has joined #Paradox
(23:53:26) * irc.ParadoxIRC.net sets mode: +v Snoopy
-
Snoopy is Bertrum@testing.fr * http://IRC-Wiki.org
Jethro another thing, I think you should check that the vhost is like blahblah.XX
(03:52:13) 11 * Tabz!vorpal@fuck.like.a.stArgentina has joined #zeronet
-=-
Tabz is vorpal@fuck.like.a.star
star shows as argentina, so maybe have it check that there is a . then two letters before it gives the country code.
Not just the asterix, if you look at the first thing i posted it just says
(01:07:10) Chelle!supramad01@Chatter-A92EB388.too.secksy.France
That does not specify what channel has been joined. The second part I posted includes an asterix and 'has joined #Chat'
Edit:
This is a clearer example:
(01:50:46) * Snoopy (Bertrum@989981.d5c616.948a24.d4be1c) has joined #Paradox
(01:50:46) * Paradox sets mode: +v Snoopy
(01:50:58) * +Snoopy (Bertrum@989981.d5c616.948a24.d4be1c) Quit (Changing hosts)
(01:50:58) * Snoopy!Bertrum@blahblah.blah.France
(01:50:58) * irc.ParadoxIRC.net sets mode: +v Snoopy
(01:51:08) * +Snoopy (Bertrum@blahblah.blah.fr) Quit (Changing hosts)
(01:51:08) * Snoopy!Bertrum@blahblah.blah.Italy
(01:51:08) * irc.ParadoxIRC.net sets mode: +v Snoopy
(01:51:10) * +Snoopy (Bertrum@blahblah.blah.it) Quit (Changing hosts)
(01:51:10) * Snoopy!Bertrum@blahblah.blah.Ireland
(01:51:10) * irc.ParadoxIRC.net sets mode: +v Snoopy
(01:51:13) * +Snoopy (Bertrum@blahblah.blah.ie) Quit (Changing hosts)
(01:51:13) * Snoopy!Bertrum@blahblah.blah.Colombia
(01:51:13) * irc.ParadoxIRC.net sets mode: +v Snoopy
Notice how it doesn't show "has joined #Paradox" when it replaces the country code, only the first join which isn't a country code shows "has joined #Paradox"
Also another thing you may want to implement:
(01:07:10) * @Chelle (supramad01@Chatter-A92EB388.too.secksy.fr) has left #Chat
(01:07:10) Chelle!supramad01@Chatter-A92EB388.too.secksy.France
Is how we would see it, so perhaps make it a bit more user friendly so it would instead display as
(01:07:10) * @Chelle (supramad01@Chatter-A92EB388.too.secksy.fr) has left #Chat
(01:07:10) * Chelle!supramad01@Chatter-A92EB388.too.secksy.France has joined #Chat
Other than that I love thise code, 8/10
Which brings out my point being, "without posting a comment why he or she thinks this script deserves to be lowered in ratings." If they feel that it's incomplete, they should suggest to me how to improve it so I can refine the script further.
I know there are lots of folks who horse around and randomly lower people snippets for no reason. This happens a lot to FordLawnMower. He makes some great scripts and out of the blue, some people lower the rating of them. Again, no comments posted as to why.
Thank you, RusselB.
I knew I could do it that way, but I was told once by a user named WorldDMT (whom I believe still frequents Hawkee every now and then) who suggested to me that I shouldn't do it with the asterisk symbol, because it could trigger the PicWin. He didn't explain the cause and effect, since he doesn't speak English very well.