| View previous topic :: View next topic |
| Author |
Message |
garfwen Halfop
Joined: 12 Mar 2008 Posts: 61
|
Posted: Tue Jan 06, 2009 5:59 pm Post subject: Need a little help |
|
|
Hello guys
I have some channels like this:
#1.channel.PT
#2.channel.UK
#3.channel.ES
etc.
Now my question is how can i get the country in a var ?
Example:
| Code: |
(chan == #1.channel.pt)
<nick> .language
<botnick> This channel is PT
|
Thnx
GaRfWeN |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Tue Jan 06, 2009 6:47 pm Post subject: |
|
|
If say it is always the last two characters of the variable chan that represent the country code then you can extract it using 'string range' as follows :-
[string range $chan end-1 end]
If you are unsure of exactly what the bot knows the channel as in terms of case, I would recommend :-
[string toupper [string range $chan end-1 end]]
The following script could be used to output both the country code and the country name in a channel using the public command !locale (if it exists in the preset array).
array set varCountries {
PT "Portugal"
UK "United Kingdom"
ES "Spain"
}
bind PUB - !locale prcLocale
proc prcLocale {nick uhost hand chan text} {
global varCountries
set code [string toupper [string range $chan end-1 end]]
if {[info exists varCountries($code)]} {
putserv "PRIVMSG $chan :The channel locale is $varCountries($code) ($code)"
} else {
putserv "PRIVMSG $chan :The channel locale is unknown"
}
return 0
} |
|
| Back to top |
|
 |
garfwen Halfop
Joined: 12 Mar 2008 Posts: 61
|
Posted: Mon Jan 12, 2009 6:03 am Post subject: |
|
|
Thanks, it works  |
|
| Back to top |
|
 |
|