Code: Select all
# Script : Advert v1.05 by David Proper (Dr. Nibble [DrN])
# Copyright 1999-2002 Radical Computer Systems
# All Rights Reserved
#
# Testing
# Platforms : Linux 2.2.16 TCL v8.3
# Eggdrop v1.6.2
# Eggdrop v1.6.6
# And : SunOS 5.8 TCL v8.3
# Eggdrop v1.5.4
#
# Description : Advert will allow you to define advertisment lines to
# be sent to anyone leaving a channel the bot is on.
# May also be used with a connected bot to send the ads
# threw. Definable probability if it will advertise.
#
# History : 06/16/1999 - First Release
# 03/23/2001 - v1.01
# o Added in a nochannel list
# 11/19/2001 - v1.02
# o Added in a random "Starter Line"
# Added in botnet ability
# One bot sees the part and tells the other
# bot to advertise. Best if used in bots on
# different sitemasks.
# o Added NOTICE or PRIVMSG message types
# o Advertisments can be sent randomly or
# in sequencial order.
# o Wont advertise to itself. :)
# o Probability of sending the advertisment
# 04/11/2002 - v1.03
# o Optional advert on part and/or join.
# o Added 1 more starterline
# o Optional random time before sending advert
# (Requested by Chad \ hockey@IRC)
# 06/21/2002 - v1.04
# o Fixed $channel variable error in on-join
# (Reported by illusi0n)
# 12/09/2002 - v1.05
# o Fixed reverse variable error.
# (Reported by: \L\ @DALnet)
# o Fixed missing sendit proc
# (Reported by: \L\ @DALnet)
# o Fixed [die] nick vulnerability
#
# Donations : https://www.paypal.com/xclick/business=rainbows%40stx.rr.com
# (If you don't have PayPal and want to donate, EMail me for an address.
# Will take money or hardware/computer donations)
# Significant (or even non-significant donations) can be published on a
# web site if you so choose.
#
# Future Plans : Make a suggestion
#[\L\(asdf@cmb7-137.dial-up.arnes.si)] Btw, can you add function, that bot will advertise adverts in public channel, automaticaly every x mins all adverts.. ?
#[\L\(asdf@cmb7-137.dial-up.arnes.si)] and "!searchadvert" will be also welcome
#[\L\(asdf@cmb7-137.dial-up.arnes.si)] for example:
#[\L\(asdf@cmb7-137.dial-up.arnes.si)] !searchadvert *old car*
#[\L\(asdf@cmb7-137.dial-up.arnes.si)] will find all adverts that are like this: I'm selling 3 years old car, white color, ....
#(\L\@DN) can you also add - AUTO-EXPIRE-ADVERT ... so advertisement will expire after x days
#(\L\@DN) can you do some kind of MAIN SWITCH ... so if I turn that !mainswitch off, then it will totaly disable script ...
#
#
# Author Contact : Email - DProper@chaotix.net
# Homepage - http://www.chaotix.net/~dproper
# IRC - Primary Nick: DrN
# UseNet - alt.irc.bots.eggdrop
# Support Channels: #RCS @UnderNet.Org
# #RCS @DALnet
# #RCS @EFnet
# #RCS @GalaxyNet
# #RCS @Choatix Addiction
# Other channels - Check contact page for current list
#
# Current contact information can be located at:
# http://www.chaotix.net/rcs/contact.html
#
# New TCL releases are sent to the following sites as soon as they're released:
#
# FTP Site | Directory
# ---------------------------+-------------------------------
# ftp.chaotix.net | /pub/RCS
# ftp.eggheads.org | Various
# ftp.realmweb.org | /drn
#
# Radical Computer System's Main Support Site: http://rcs.chaotix.net
# To subscribe to the RCS mailing list:
# http://www.chaotix.net/mailman/listinfo/rcs-list
#
#
# Feel free to Email me any suggestions/bug reports/etc.
#
# You are free to use this TCL/script as long as:
# 1) You don't remove or change author credit
# 2) You don't release it in modified form. (Only the original)
#
# If you have a "too cool" modification, send it to me and it'll be
# included in the official. (With your credit)
#
# Commands Added:
# Where F CMD F CMD
# ---------- - --------- - ----------
# Public: o !listadvert m !deladvert
# m !addadvert m !adverts
# - !adverthelp
# MSG: - adverthelp
# DCC: - adverthelp
#
set cmdchar_ "!"
# Datafile to store adverts in
set advert(datafile) "adverts"
# [0/1] Set this to 1 if you want the advert to be sent on join
set advert(onjoin) 0
# [0/1] Set this to 1 if you want the advert to be sent on part
set advert(onpart) 1
# [0+] (Seconds) Set this above 0 if you want a delay on sending the advert.
set advert(delay) 15
# [0+] (Seconds) Set this to the minimum delay.
set advert(delay_base) 10
# Delay is calculated as: delay_base + (random number from 0 to delay)
# Channels not to send adverts to people when parting
set advert(ignore) "#channel1 #channel2"
# [NOTICE/PRIVMSG] Method of sending text
set advert(type) "NOTICE"
# [0/1] Set to 0 for random adverts, set to 1 for sequencial
set advert(gettype) 1
# Set this to the botnet nick of the bot to spam for you. Set to ""
# if you want this bot to do the adverts.
set advert(usebot) ""
# Netcode. Change for each network this script is run on so you don't send
# advert requests for UnderNet to DALnet or so.
set advert(netcode) 927
# This is the percentage chance they will get an advertisment.
# Set to 100 to always send an advertisment.
set advert(prob) 85
# This is the starter line to send before the actually advert. Set to ""
# if you don't want anything sent.
set advert(starterline) {
{Hi. How are you?}
{Hi there.}
{You looked bored in $chan.}
{Hey There!}
}
set advert(ver) "1.05.01"
set advert(tag) "\[\002AdverT\002\]"
proc cmdchar { } {
global cmdchar_
return $cmdchar_
}
bind pub o [cmdchar]listadvert pub_advertlist
proc pub_advertlist {nick uhost hand channel rest} {
global random_advert
advert_load
putserv "NOTICE $nick :Listing Advertisments Database"
set looper 0
while {($looper < [llength $random_advert])} {
putserv "NOTICE $nick :\026 $looper \026 : [lindex $random_advert $looper]"
incr looper 1
}
putserv "NOTICE $nick :--EOF"
}
bind pub m [cmdchar]deladvert pub_advertdel
proc pub_advertdel {nick uhost hand channel rest} {
global random_advert
set delwhat [lindex $rest 0]
if {($delwhat == "")} {putserv "NOTICE $nick :Calling Syntax: [cmdchar]deladvert #"
return 1}
if {($delwhat < 0) || ($delwhat > [llength $random_advert])} {
putserv "NOTICE $nick :You specified an invalid reference."
return 1
}
set advert_temp $random_advert
unset random_advert
set deleted [lindex $advert_temp $delwhat]
set looper 0
while {($looper < [llength $advert_temp])} {
if {($looper != $delwhat)} {lappend random_advert [lindex $advert_temp $looper]}
incr looper 1
}
putserv "NOTICE $nick :Deleted advert #$delwhat - $deleted"
advert_write
}
bind pub m [cmdchar]addadvert pub_advertadd
proc pub_advertadd {nick uhost hand channel rest} {
global random_advert
set addwhat [lrange $rest 0 end]
if {($addwhat == "")} {putserv "NOTICE $nick :Calling Syntax: [cmdchar]addadvert \[advertisment line\]"
return 1}
lappend random_advert $addwhat
putserv "NOTICE $nick :Added advert #[llength $random_advert] - $addwhat"
advert_write
}
proc advert_load {} {
global random_advert advert adverts
if {[info exists random_advert]} {unset random_advert}
if {[catch {set fd [open $advert(datafile) r]}] != 0} {return 0}
set adverts [gets $fd]
while {![eof $fd]} {
set inp [gets $fd]
if {[eof $fd]} {break}
if {[string trim $inp " "] == ""} {continue}
lappend random_advert [lrange $inp 0 end]
}
close $fd
return 1
}
proc advert_write {} {
global advert random_advert adverts_changed adverts
set fd [open $advert(datafile) w]
puts $fd "$adverts"
set looper 0
while {($looper < [llength $random_advert])} {
puts $fd "[lindex $random_advert $looper]"
incr looper 1
}
close $fd
set advertss_changed 0
return 1
}
bind join - ***** do_advert_join
proc do_advert_join {nick uhost hand chan} {
global adverts random_advert advert botnick
if {$advert(onjoin) == 0} {return 1}
if {$adverts == 0} {return 1}
if {[string tolower $nick] == [string tolower $botnick]} {return 0}
if {$advert(usebot) != ""} {putbot $advert(usebot) "ADVERT $advert(netcode) $nick $chan"
} else {utimer [get_adverttime] "advert_do $nick $chan"
}
}
bind part - ***** do_advert_part
proc do_advert_part {nick uhost hand channel {msg ""}} {
global adverts random_advert advert botnick
subst -nobackslashes -nocommands -novariables nick
subst -nobackslashes -nocommands -novariables msg
regsub -all {\[} $nick "\\\[" nick
regsub -all {\]} $nick "\\\]" nick
regsub -all {\[} $nick "\\\[" msg
regsub -all {\]} $nick "\\\]" msg
#regsub -all {\[} $nick "!BRAKET!" nick
#if {[string match "*!BRAKET!*" "$nick"] > 0 } {
# putserv "privmsg #rcs :Found a \[ so [censored]'um"
# return 0
#}
if {$advert(onpart) == 0} {return 1}
if {$adverts == 0} {return 1}
if {[string tolower $nick] == [string tolower $botnick]} {return 0}
if {$advert(usebot) != ""} {putbot $advert(usebot) "ADVERT $advert(netcode) $nick $channel"
} else {utimer [get_adverttime] "advert_do $nick $channel"
}
}
bind bot - advert advert_in
proc advert_in {bot cmd arg} {
subst -nobackslashes -nocommands -novariables arg
global advert network
set c [lindex $arg 0]
set nick [lindex $arg 1]
set chan [lindex $arg 2]
if {$c == $advert(netcode)} {
putlog "$advert(tag) Advertisment requested for $nick on $chan from $bot"
utimer [get_adverttime] "advert_do $nick $chan
}
}
proc get_adverttime {} {
global advert
return [expr $advert(delay_base) + [rand $advert(delay)]]
}
proc advert_do {nick chan} {
subst -nobackslashes -nocommands -novariables nick
global adverts random_advert advert
if {![probability $advert(prob)]} {return 1}
if {[lsearch -glob $advert(ignore) [string tolower "*$chan*"] ] == -1 } {
if {$advert(starterline) != ""} {
set txt [randomline $advert(starterline)]
regsub -all {\$chan} $txt "$chan" txt
putserv "$advert(type) $nick :$txt"
}
if {$advert(gettype) == 0} {set theadvert [lindex $random_advert [rand [llength $random_advert]]]}
if {$advert(gettype) == 1} {set theadvert [lindex $random_advert $advert(current)]
set advert(current) [expr $advert(current) + 1]
if {$advert(current) > [llength $random_advert]} {set advert(current) 0}
}
putserv "$advert(type) $nick :$theadvert"
}
}
proc probability {prob} {
if {$prob == 100} {return 1}
set r [rand 100]
set rng [rand [expr 100 - $prob]]
set rngu [expr $rng + $prob]
if {($r > $rng) && ($r < $rngu)} {return 1}
return 0
}
proc randomline {text} {
return [lindex $text [rand [llength $text]]]
}
proc pub_adverts {nick uhost hand channel rest} {
global adverts
switch [string tolower [lindex $rest 0]] {
"" { putserv "NOTICE $nick :Syntax: [cmdchar]adverts \[on/off\]" }
"off" { set adverts 0 }
"on" { set adverts 1 }
}
if {$adverts == 0} { putserv "NOTICE $nick :Adverts are currentlly off"
} else { putserv "NOTICE $nick :Adverts are currentlly on" }
advert_write
}
bind pub m [cmdchar]adverts pub_adverts
############# HELP SECTION #######################################[START]#
proc adverthelp {nick channel dirc dire args} {
global adverts advert
set topic [string tolower [lindex $args 0]]
if {([string length $topic]) < 3} { sendit $nick $channel $dirc "Use \002ADVERTHELP help\002 to list avliable topics." }
switch [string tolower $topic] {
"status" {
if {($adverts == 0)} {set adverttemp Off} else {set adverttemp On}
sendit $nick $channel $dirc "Adverts are currentlly $adverttemp."
}
"adverts" {
sendit $nick $channel $dirc "ADVERTS - Syntax: adverts \[on/off\]"
sendit $nick $channel $dirc "(MAS) This command allows you to turn advertisments on or off."
}
"addadvert" {
sendit $nick $channel $dirc "ADDADVERT - Syntax: addadvert <advertline>"
sendit $nick $channel $dirc "(MAS) This command allows you to add an advertisment to the database."
}
"deladvert" {
sendit $nick $channel $dirc "DELADVERT - Syntax: deladvert <number>"
sendit $nick $channel $dirc "(MAS) This command allows you to delete an advertisment from the database."
}
"listadvert" {
sendit $nick $channel $dirc "LISTADVERT - Syntax: listadvert"
sendit $nick $channel $dirc "(OPs) This command will list all advertisments in the database."
}
"help" {
sendit $nick $channel $dirc "Help Topics Avaliable:"
sendit $nick $channel $dirc "listadvert deladvert addadvert adverts status"
}
}
}
proc pub_adverthelp {nick uhost handle channel args} {
global advert
sendit $nick $channel 1 "Advert v$advert(ver) by David Proper (DrN)"
adverthelp $nick $channel 1 1 $args
}
bind pub - [cmdchar]adverthelp pub_adverthelp
proc msg_adverthelp {nick uhost handle args} {
global advert
sendit $nick $nick 2 "Advert v$advert(ver) by David Proper (DrN)"
adverthelp $nick $nick 2 2 $args
}
bind msg - adverthelp msg_adverthelp
proc dcc_adverthelp {handle idx args} {
global advert
sendit $idx $idx 4 "Advert v$advert(ver) by David Proper (DrN)"
adverthelp $idx $idx 4 4 $args
}
bind dcc - adverthelp dcc_adverthelp
proc sendit {nick channel dirc txt} {
if {$dirc == "1"} { putserv "PRIVMSG $channel :$txt" }
if {$dirc == "2"} { putserv "PRIVMSG $nick :$txt" }
if {$dirc == "3"} { putserv "NOTICE $nick :$txt" }
if {$dirc == "4"} { putdcc $nick "$txt" }
}
############# HELP SECTION #########################################[END]#
set adverts_changed 0
set random_advert ""
set adverts 1
set advert(current) 0
advert_load
putlog "Advert v$advert(ver) by David Proper (DrN) -=:LoadeD:=-"
return "Advert v$advert(ver) by David Proper (DrN) -=:LoadeD:=-"
Code: Select all
} else {utimer [get_adverttime] "advert_do $nick $chan"
Code: Select all
} else {utimer [get_adverttime] [list advert_do $nick $chan]
Code: Select all
subst -nobackslashes -nocommands -novariables arg