| View previous topic :: View next topic |
| Author |
Message |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Thu Jul 07, 2016 1:34 am Post subject: help tcl welcome |
|
|
This works well tcl only it works in a channel
| Code: |
set ayuda_chanxp "#tcl"
set msg_greet($::ayuda_chanxp) {
"welcome $nick to $chan"
"thanks for visit"
"for view rules tipe !rules"
}
bind join - * chan_greet
proc chan_greet {nick uhost hand chan} {
global botnick ayuda_chanxp msg_greet
if {$nick == $botnick} {return 1}
if {$chan == $ayuda_chanxp} {
set msg_temp $msg_greet($chan)
foreach i $msg_temp {puthelp "NOTICE $nick :[subst $i]"}
return 1
}
}
|
but my question is
You can extend this tcl to operate in several channels?
example:
| Code: |
set ayuda_chanxp "#tcl #help #mirc"
|
_________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Thu Jul 07, 2016 4:00 am Post subject: |
|
|
Prueba con esto:
| Code: | set ayuda_chanxp "#tcl #help #mirc"
set msg_greet($::ayuda_chanxp) {
"welcome $nick to $chan"
"thanks for visit"
"for view rules tipe !rules"
}
bind join - * chan_greet
proc chan_greet {nick uhost hand chan} {
global botnick ayuda_chanxp msg_greet
if {$nick == $botnick} {return 1}
if {[lsearch -exact [string tolower $ayuda_chanxp] [string tolower $chan]] != -1} {
set msg_temp $msg_greet($chan)
foreach i $msg_temp {puthelp "NOTICE $nick :[subst $i]"}
return 1
} else {
return 0
}
}
|
No lo he probado, pero debería funcionarte sin problemas. _________________ If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Thu Jul 07, 2016 4:04 am Post subject: |
|
|
You achieve that with lsearch.
| Code: |
namespace eval greet {
set greet(channels) "#tcl #help #mirc"
set greet(message) "Welcome %nick to %chan, thanks for visit. To view rules type !rules"
bind join - * [namespace current]::doGreet
proc doGreet {nick uhost hand chan} {
variable greet
if {[isbotnick $nick]} return
if {[lsearch -nocase $greet(channels) $chan] == -1} return
set message [string map [list %nick $nick %chan $chan] $greet(message)]
puthelp "NOTICE $nick :$message"
}
}
|
Squeezed the 3 lines in just a single one cos are short.
@juanamores: Por que utilizar -exact y la string tolower cuando se puede ir directamente con -nocase? _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Thu Jul 07, 2016 2:34 pm Post subject: |
|
|
very good .. thanks caesar
No funciono juan pero gracias por la ayuda
la tcl de caesar si funciona y esta perfecta  _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Thu Jul 07, 2016 2:55 pm Post subject: |
|
|
cesar is possible to change your tcl to work well
| Code: |
set greet(message) {
"Welcome %nick to %chan, thanks for visit. To view rules type !rules"
"come back soon"
" bye bye... "
}
|
_________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Jul 08, 2016 7:46 am Post subject: |
|
|
| Code: |
namespace eval greet {
set greet(channels) "#tcl #help #mirc"
set greet(messages) {
"Welcome %nick to %chan, thanks for visit. To view rules type !rules"
"come back soon"
" bye bye... "
}
bind join - * [namespace current]::doGreet
proc doGreet {nick uhost hand chan} {
variable greet
if {[isbotnick $nick]} return
if {[lsearch $greet(channels) $chan] == -1} return
foreach line $greet(messages) {
set message [string map [list %nick $nick %chan $chan] $line]
puthelp "NOTICE $nick :$message"
}
}
}
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Get_A_Fix Master

Joined: 07 May 2005 Posts: 206 Location: New Zealand
|
Posted: Fri Jul 08, 2016 8:04 am Post subject: |
|
|
I would probably use caesar's code, due to his expertise, but I did make something exactly like this a while back for someone. This uses a setudef (user defined setting), allowing you to enable/disable per channel.
This method allows for you to utilise $nick and $chan like normal, inside your message list.
| Code: |
# $Id: greeter.tcl,v1.1 18/01/2016 06:20:47am GMT +12 (NZST) IRCSpeed Exp $
## SYNTAX:
# !greet on|off
# Feel free to edit this setting. Change the ! to any character you would like as a trigger.
set greettrig "!"
# Set here what flags you wish to allow to enable/disable this script. (change them to "-|-" for anyone)
set greetflags "ovf|ovf"
# Set here the greetings you wish to send each user that joins.
set mymsgs {
"Hi, how are you?"
"Hi $nick!"
"Hello $nick, welcome to $chan"
"Hi [$nick], you have to pay $20 to enter here"
}
### DONT EDIT BELOW ###
proc getTrig {} {
global greettrig
return $greettrig
}
setudef flag autogreet
bind join - * greet:msg
bind pub - ${greettrig}greet greet:pub
proc greet:msg {nick host hand chan} {
global mymsgs
if {[validuser [nick2hand $nick]] && ![channel get $chan autogreet]} {return}
set greetmsg [lindex $mymsgs [rand [llength $mymsgs]]]
set greetmsg [subst -nocommands $greetmsg]
putserv "NOTICE $nick :$greetmsg"
}
proc greet:pub {nick uhost hand chan arg} {
global greetflags
if {[matchattr [nick2hand $nick] $greetflags $chan]} {
if {[lindex [split $arg] 0] == ""} {putquick "PRIVMSG $chan :\037ERROR\037: Incorrect Parameters. \037SYNTAX\037: [getTrig]greets on|off"; return}
if {[lindex [split $arg] 0] == "on"} {
if {[channel get $chan autogreet]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already enabled."; return}
channel set $chan +autogreet
puthelp "PRIVMSG $chan :Enabled Onjoin Greeter for $chan"
savechannels
return 0
}
if {[lindex [split $arg] 0] == "off"} {
if {![channel get $chan autogreet]} {putquick "PRIVMSG $chan :\037ERROR\037: This setting is already disabled."; return}
channel set $chan -autogreet
puthelp "PRIVMSG $chan :Disabled Onjoin Greeter for $chan"
savechannels
return 0
}
}
}
putlog ".:greeter.tcl,v1.1:. Loaded!"
|
_________________ We explore.. and you call us criminals. We seek after knowledge.. and you call us criminals. We exist without skin color, without nationality, without religious bias.. and you call us criminals.
Last edited by Get_A_Fix on Sat Jul 09, 2016 12:56 pm; edited 1 time in total |
|
| Back to top |
|
 |
juanamores Master
Joined: 15 Mar 2015 Posts: 317
|
Posted: Sat Jul 09, 2016 6:08 am Post subject: |
|
|
| caesar wrote: |
@juanamores: Por que utilizar -exact y la string tolower cuando se puede ir directamente con -nocase? |
O sea, el -nocase sirve no sólo para minúsculas, sino también para comparar palabras exactas? _________________ If you do not understand my ideas is because I can not think in English, I help me with Google Translate. I only speak Spanish. Bear with me. Thanks  |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Sat Jul 09, 2016 10:53 am Post subject: |
|
|
Si -nocase se especifica, entonces las cadenas se comparan de manera mayúsculas y minúsculas.  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Arnold_X-P Master

Joined: 30 Oct 2006 Posts: 221 Location: DALnet - Trinidad - Beni - Bolivia
|
Posted: Sat Jul 09, 2016 6:10 pm Post subject: |
|
|
thanks caesar & Get_A_Fix
your help is appreciated
thanks again......
gracias a ti tambien juanamores por tratar de ayudar, yo tambien hablo español, saludos cuate.
I also worked well
| Code: |
set ayuda_chanxp "#tcl #help #mirc"
set mymsgs {
"Welcome $nick to $chan, thanks for visit. To view rules type !rules"
"come back soon"
" bye bye... "
}
bind join - * greet:msg
proc greet:msg {nick host hand chan} {
global mymsgs ayuda_chanxp botnick
if {(([lsearch -exact [string tolower $ayuda_chanxp] [string tolower $chan]] != -1) || ($ayuda_chanxp == "")) && ($nick != $botnick)} {
foreach i $mymsgs {
puthelp "NOTICE $nick :[subst $i]"
} } }
|
I also worked well
| Code: |
set ayuda_chanxp "#tcl #help #mirc"
set mymsgs {
"Welcome %nick to %chan, thanks for visit. To view rules type !rules"
"come back soon"
" bye bye... "
}
bind join - * greet:msg
proc greet:msg {nick host hand chan} {
global mymsgs ayuda_chanxp botnick
if {(([lsearch -exact [string tolower $ayuda_chanxp] [string tolower $chan]] != -1) || ($ayuda_chanxp == "")) && ($nick != $botnick)} {
foreach line $mymsgs {
set message [string map [list %nick $nick %chan $chan] $line]
puthelp "NOTICE $nick :$message"
} } }
|
Thanks again for the help _________________
thanks to that they help, that others learn  |
|
| Back to top |
|
 |
|