This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Put a "on/off switch"

Old posts that have not been replied to for several years.
Locked
User avatar
Thunderdome
Op
Posts: 187
Joined: Tue Mar 15, 2005 4:42 pm

Put a "on/off switch"

Post by Thunderdome »

Code: Select all

##################################
### TimeMessage.tcl            ###
### Version 1.0                ###
### By Wcc                     ###
### wcc@techmonkeys.org        ###
### http://www.dawgtcl.com:81/ ###
### EFnet #|DAWG|Tcl           ###
##################################

############################################################################
### Copyright © 2000 - 2002 |DAWG| Scripting Group. All rights reserved. ###
############################################################################

############################################################################
## This script sends a message to a channel (or channels) every x seconds ##
## (or minutes).                                                          ##
############################################################################

##########################################################
## Just load the script, edit the settings, and rehash. ##
##########################################################

#################################
# Set the message to send here. #
#################################

set timemessage_setting(message) {
	"message here"
      
      
      
      
      
}

##########################################
# Set the channel(s) to send it to here. #
##########################################

set timemessage_setting(channel) "#channel"

###########################################################################
# Set the time in minutes between messages here. Prefix the time with a ! #
# to use seconds.                                                         #
###########################################################################

set timemessage_setting(time) "15"

####################
# Code begins here #
####################

if {![string match 1.6.* $version]} { putlog "\002TIMEMESSAGE:\002 \002WARNING:\002 This script is intended to run on eggdrop 1.6.x or later." }
if {[info tclversion] < 8.2} { putlog "\002TIMEMESSAGE:\002 \002WARNING:\002 This script is intended to run on Tcl Version 8.2 or later." }

if {[string compare [string index $timemessage_setting(time) 0] "!"] == 0} { set timemessage_timer [string range $timemessage_setting(time) 1 end] } { set timemessage_timer [expr $timemessage_setting(time) * 60] }
if {[lsearch -glob [utimers] "* timemessage_go *"] == -1} { utimer $timemessage_timer timemessage_go }

proc timemessage_go {} {
	foreach chan $::timemessage_setting(channel) {
		if {![validchan $chan] || ![botonchan $chan]} { continue }
		foreach line $::timemessage_setting(message) { putserv "PRIVMSG $chan :$line" }
	}
	if {[lsearch -glob [utimers] "* timemessage_go *"] == -1} { utimer $::timemessage_timer timemessage_go }
}
putlog "\002TIMEMESSAGE:\002 TimeMessage.tcl Version 1.0 by Wcc is loaded."

How do I put a on/off switch than can be use from a bind to owner (+n) only?
like !timemsg and the script starts.... I would also like it to be disabled by default, only starting with !timemsg

Thanks! :)
User avatar
Thunderdome
Op
Posts: 187
Joined: Tue Mar 15, 2005 4:42 pm

Post by Thunderdome »

I saw some of the topics related, but the on/off would not work...

Can you please give me a hand on this one?
User avatar
Thunderdome
Op
Posts: 187
Joined: Tue Mar 15, 2005 4:42 pm

Post by Thunderdome »

I've also searched other similar scripts... they are all activated at start, with no switch... :\

help needed... :D
D
Dizzle
Op
Posts: 109
Joined: Thu Apr 28, 2005 11:21 am
Contact:

Post by Dizzle »

Hope this will work

Code: Select all


proc mute::av { nickname hostname handle channel arguments } {
set mode [lindex [split $arguments] 0]
  switch $mode {
	on {
	  if {[channel get $channel "autovoice"]} {
	    putquick "NOTICE $nickname :autovoice is already enabled for $channel."
	    return 0
	   }
	    channel set $channel +autovoice
	    putquick "NOTICE $nickname :autovoice has been enabled for $channel."
	   }
	off {
	  if {![channel get $channel "autovoice"]} {
	    putquick "NOTICE $nickname :autovoice is already disabled for $channel."
	    return 0
	   }
	    channel set $channel -autovoice
	    putquick "NOTICE $nickname :autovoice has been disabled for $channel."
         }
	default {
        if {[channel get $channel "autovoice"]} {
	    putquick "NOTICE $nickname :autovoice is currently enabled for $channel."
	  } else {
	    putquick "NOTICE $nickname :autovoice is currently disabled for $channel."
	  }
      }
   }
}


all credits too Metroid, he build this
User avatar
Thunderdome
Op
Posts: 187
Joined: Tue Mar 15, 2005 4:42 pm

Post by Thunderdome »

How exactly do I merge the two codes?
I found a similar code in the forum, but I simply cannot make it work at all... how do I blend the codes?

I tried this but does not work at all....

Code: Select all

##################################
### TimeMessage.tcl            ###
### Version 1.0                ###
### By Wcc                     ###
### wcc@techmonkeys.org        ###
### http://www.dawgtcl.com:81/ ###
### EFnet #|DAWG|Tcl           ###
##################################

############################################################################
### Copyright © 2000 - 2002 |DAWG| Scripting Group. All rights reserved. ###
############################################################################

############################################################################
## This script sends a message to a channel (or channels) every x seconds ##
## (or minutes).                                                          ##
############################################################################

##########################################################
## Just load the script, edit the settings, and rehash. ##
##########################################################

setudef flag antiadver 

bind PUB n|n !adver adver:switch 

proc adver:switch {nick host hand chan text} { 
 set option [lindex [split $text] 0] 
 switch -- $option { 
  "on" { 
   channel set $chan +antiadver  
   puthelp "NOTICE $nick : Advertise is 9ON9" 
  } 
  "off" { 
   channel set $chan -antiadver 
   puthelp "NOTICE $nick : Advertise is 4OFF4" 
  } 
 } 
} 



#################################
# Set the message to send here. #
#################################

set timemessage_setting(message) {
	"blablablabla"
}

##########################################
# Set the channel(s) to send it to here. #
##########################################

set timemessage_setting(channel) "#channel"

###########################################################################
# Set the time in minutes between messages here. Prefix the time with a ! #
# to use seconds.                                                         #
###########################################################################

set timemessage_setting(time) "15"

####################
# Code begins here #
####################

if {![string match 1.6.* $version]} { putlog "\002TIMEMESSAGE:\002 \002WARNING:\002 This script is intended to run on eggdrop 1.6.x or later." }
if {[info tclversion] < 8.2} { putlog "\002TIMEMESSAGE:\002 \002WARNING:\002 This script is intended to run on Tcl Version 8.2 or later." }

if {[string compare [string index $timemessage_setting(time) 0] "!"] == 0} { set timemessage_timer [string range $timemessage_setting(time) 1 end] } { set timemessage_timer [expr $timemessage_setting(time) * 60] }
if {[lsearch -glob [utimers] "* timemessage_go *"] == -1} { utimer $timemessage_timer timemessage_go }

if {[channel get $chan antiadver]} { 
proc timemessage_go {} {
	foreach chan $::timemessage_setting(channel) {
		if {![validchan $chan] || ![botonchan $chan]} { continue }
		foreach line $::timemessage_setting(message) { putserv "PRIVMSG $chan :$line" }
	}
	if {[lsearch -glob [utimers] "* timemessage_go *"] == -1} { utimer $::timemessage_timer timemessage_go }
}
}
putlog "\002TIMEMESSAGE:\002 TimeMessage.tcl Version 1.0 by Wcc is loaded."
D
Deniska
Voice
Posts: 4
Joined: Mon Apr 25, 2005 12:30 am
Location: Tomsk, Russia
Contact:

Post by Deniska »

Code: Select all

################################## 
### TimeMessage.tcl            ### 
### Version 1.0                ### 
### By Wcc                     ### 
### wcc@techmonkeys.org        ### 
### http://www.dawgtcl.com:81/ ### 
### EFnet #|DAWG|Tcl           ### 
################################## 
############################################################################ 
### Copyright © 2000 - 2002 |DAWG| Scripting Group. All rights reserved. ### 
############################################################################ 
############################################################################ 
## This script sends a message to a channel (or channels) every x seconds ## 
## (or minutes).                                                          ## 
############################################################################ 
########################################################## 
## Just load the script, edit the settings, and rehash. ## 
########################################################## 
setudef flag antiadver 
bind PUB n|n !adver adver:switch 
proc adver:switch {nick host hand chan text} { 
 set option [lindex [split $text] 0] 
 switch -- $option { 
  "on" { 
   channel set $chan -antiadver  
   puthelp "NOTICE $nick : Advertise is 9ON9" 
  } 
  "off" { 
   channel set $chan +antiadver 
   puthelp "NOTICE $nick : Advertise is 4OFF4" 
  } 
 } 
} 
################################# 
# Set the message to send here. # 
################################# 
set timemessage_setting(message) { 
   "blablablabla" 
} 
########################################## 
# Set the channel(s) to send it to here. # 
########################################## 
set timemessage_setting(channel) "#channel" 
########################################################################### 
# Set the time in minutes between messages here. Prefix the time with a ! # 
# to use seconds.                                                         # 
########################################################################### 
set timemessage_setting(time) "15" 
#################### 
# Code begins here # 
#################### 
if {![string match 1.6.* $version]} { putlog "\002TIMEMESSAGE:\002 \002WARNING:\002 This script is intended to run on eggdrop 1.6.x or later." } 
if {[info tclversion] < 8.2} { putlog "\002TIMEMESSAGE:\002 \002WARNING:\002 This script is intended to run on Tcl Version 8.2 or later." } 
if {[string compare [string index $timemessage_setting(time) 0] "!"] == 0} { set timemessage_timer [string range $timemessage_setting(time) 1 end] } { set timemessage_timer [expr $timemessage_setting(time) * 60] } 
if {[lsearch -glob [utimers] "* timemessage_go *"] == -1} { utimer $timemessage_timer timemessage_go } 

proc timemessage_go {} { 
   foreach chan $::timemessage_setting(channel) { 
      if {![validchan $chan] || ![botonchan $chan]} { continue } 
      if {![channel get $chan antiadver]} { 
      foreach line $::timemessage_setting(message) { putserv "PRIVMSG $chan :$line" } 
   } 
}
   if {[lsearch -glob [utimers] "* timemessage_go *"] == -1} { utimer $::timemessage_timer timemessage_go } 

} 
putlog "\002TIMEMESSAGE:\002 TimeMessage.tcl Version 1.0 by Wcc is loaded."
Imho.. When is +antiadver, procedure will not show message on this channel.
Dixi.
User avatar
Thunderdome
Op
Posts: 187
Joined: Tue Mar 15, 2005 4:42 pm

Post by Thunderdome »

but still won't work in either on or off... what am I doing wrong? :\
D
Deniska
Voice
Posts: 4
Joined: Mon Apr 25, 2005 12:30 am
Location: Tomsk, Russia
Contact:

Post by Deniska »

Code: Select all

################################## 
### TimeMessage.tcl            ### 
### Version 1.0                ### 
### By Wcc                     ### 
### wcc@techmonkeys.org        ### 
### http://www.dawgtcl.com:81/ ### 
### EFnet #|DAWG|Tcl           ### 
################################## 
############################################################################ 
### Copyright c 2000 - 2002 |DAWG| Scripting Group. All rights reserved. ### 
############################################################################ 
############################################################################ 
## This script sends a message to a channel (or channels) every x seconds ## 
## (or minutes).                                                          ## 
############################################################################ 
########################################################## 
## Just load the script, edit the settings, and rehash. ## 
########################################################## 
setudef flag antiadver 
bind pub n|n !adver adver:switch 
proc adver:switch {nick host hand chan text} { 
set option [lindex [split $text] 0] 
if { $option == "on" } {
channel set $chan -antiadver 
puthelp "NOTICE $nick : Advertise is 9ON9" 
} 
if { $option == "off" } { 
channel set $chan +antiadver 
puthelp "NOTICE $nick : Advertise is 4OFF4" 
} 
} 
################################# 
# Set the message to send here. # 
################################# 
set timemessage_setting(message) { 
"blablablabla" 
} 
########################################## 
# Set the channel(s) to send it to here. # 
########################################## 
set timemessage_setting(channel) "#channel" 
########################################################################### 
# Set the time in minutes between messages here. Prefix the time with a ! # 
# to use seconds.                                                         # 
########################################################################### 
set timemessage_setting(time) "15" 
#################### 
# Code begins here # 
#################### 
if {![string match 1.6.* $version]} { putlog "\002TIMEMESSAGE:\002 \002WARNING:\002 This script is intended to run on eggdrop 1.6.x or later." } 
if {[info tclversion] < 8.2} { putlog "\002TIMEMESSAGE:\002 \002WARNING:\002 This script is intended to run on Tcl Version 8.2 or later." } 
if {[string compare [string index $timemessage_setting(time) 0] "!"] == 0} { set timemessage_timer [string range $timemessage_setting(time) 1 end] } { set timemessage_timer [expr $timemessage_setting(time) * 60] } 
if {[lsearch -glob [utimers] "* timemessage_go *"] == -1} { utimer $timemessage_timer timemessage_go } 
proc timemessage_go {} { 
foreach chan $::timemessage_setting(channel) { 
if {![validchan $chan] || ![botonchan $chan]} { continue } 
if {![channel get $chan antiadver]} { 
foreach line $::timemessage_setting(message) { putserv "PRIVMSG $chan :$line" } 
} 
} 
if {[lsearch -glob [utimers] "* timemessage_go *"] == -1} { utimer $::timemessage_timer timemessage_go } 
} 
putlog "\002TIMEMESSAGE:\002 TimeMessage.tcl Version 1.0 by Wcc is loaded." 
This variance must work correctly.
Hm.. I think it does not work because of codepage. When i copy code in file and try to launch, bot putlog a message.. Mm.. something about '=' symbol before every string /-:. But when i retype all spaces in cp1251 codepage, script will work correctly.. Also i fix some part of code..
--
Sorry for my english..
Dixi.
User avatar
Thunderdome
Op
Posts: 187
Joined: Tue Mar 15, 2005 4:42 pm

Post by Thunderdome »

Thanks... works fine but....
I want it to NOT start when the eggdrop starts... only when I do !advert on
I tried:

Code: Select all

setudef flag antiadver
into

Code: Select all

set flag antiadver 
but

Code: Select all

Tcl error [adver:switch]: illegal channel option: -antiadver
then I tried

Code: Select all

proc adver:start {nick host hand chan text} { 
channel set $chan +antiadver
} 
which seems to work... is it okay, or is there something better?

Thanks for all your help. :) Most precious.
D
Deniska
Voice
Posts: 4
Joined: Mon Apr 25, 2005 12:30 am
Location: Tomsk, Russia
Contact:

Post by Deniska »

When you use

Code: Select all

set flag antiadver
you just set a variable ( $flag ). When you use

Code: Select all

setudef flag antiadver
you set a channel flag. This flag maybe + or - ( == 1 or <>1 ). You can see that in .chaninfo #chan. Also exists setudef int, setudef str. Read more in tcl manuals.
Dixi.
Locked