egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need a little help

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
garfwen
Halfop


Joined: 12 Mar 2008
Posts: 61

PostPosted: Tue Jan 06, 2009 5:59 pm    Post subject: Need a little help Reply with quote

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
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Tue Jan 06, 2009 6:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
garfwen
Halfop


Joined: 12 Mar 2008
Posts: 61

PostPosted: Mon Jan 12, 2009 6:03 am    Post subject: Reply with quote

Thanks, it works Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber