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 

help tcl welcome

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


Joined: 30 Oct 2006
Posts: 221
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Thu Jul 07, 2016 1:34 am    Post subject: help tcl welcome Reply with quote

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"

_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Thu Jul 07, 2016 4:00 am    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Thu Jul 07, 2016 4:04 am    Post subject: Reply with quote

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


Joined: 30 Oct 2006
Posts: 221
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Thu Jul 07, 2016 2:34 pm    Post subject: Reply with quote

very good .. thanks caesar Smile

No funciono juan pero gracias por la ayuda Razz
la tcl de caesar si funciona y esta perfecta Very Happy
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Arnold_X-P
Master


Joined: 30 Oct 2006
Posts: 221
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Thu Jul 07, 2016 2:55 pm    Post subject: Reply with quote

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... "
}

_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Fri Jul 08, 2016 7:46 am    Post subject: Reply with quote

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


Joined: 07 May 2005
Posts: 206
Location: New Zealand

PostPosted: Fri Jul 08, 2016 8:04 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
juanamores
Master


Joined: 15 Mar 2015
Posts: 317

PostPosted: Sat Jul 09, 2016 6:08 am    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message
caesar
Mint Rubber


Joined: 14 Oct 2001
Posts: 3741
Location: Mint Factory

PostPosted: Sat Jul 09, 2016 10:53 am    Post subject: Reply with quote

Si -nocase se especifica, entonces las cadenas se comparan de manera mayúsculas y minúsculas. Smile
_________________
Once the game is over, the king and the pawn go back in the same box.
Back to top
View user's profile Send private message
Arnold_X-P
Master


Joined: 30 Oct 2006
Posts: 221
Location: DALnet - Trinidad - Beni - Bolivia

PostPosted: Sat Jul 09, 2016 6:10 pm    Post subject: Reply with quote

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
_________________
Very Happy thanks to that they help, that others learn Very Happy
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
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