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.

Help with READ/REPLACE Script

Old posts that have not been replied to for several years.
Locked
m
mil1i

Help with READ/REPLACE Script

Post by mil1i »

Hi, I'm new to learning TCL, and I just got a new webhost for my website. I got access to a shell account, so I figured I'd set up an eggdrop, but for all I knew, the codes had to be a different language than what IRC uses.

Heres my IRC Code:

Code: Select all

*/     Gaming Script by Matt Milligan (mil1i)
*/     September 26, 2004
*/     
*/
*/     Load script setting up var's
on 1:load:{
  if (!%chans) {  /set %chans $?="What's the channel you wish for this script to run in? (ex. #openfire)"  }
  elseif (!%id) { /set %id $?="What prefix do you want to use to execute commands? (ex. @commands [or] ?commands)"  }
  elseif (!%mode) { /set %mode /notice  }
  elseif (!%adbanhistory) { /set %adbanhistory 0  }
}
*/
*/    Auto-Join Channels bot is working in
*/
on 1:start:/j %chans
*/
*/     Unwanted advertising prevention
*/
*/
on 1:text:*#*:%chans:{
  if (($nick !isvoice $chan) && ($nick !isop $chan)) {
    /inc %adbanhistory 1
    /ban -u240 %chans $nick 3
    /kick $chan $nick Do NOT adverstise. ( $+ %adbanhistory $+  users.)
  }
}
on 1:action:*#*:%chans:{
  if (($nick !isvoice $chan) && ($nick !isop $chan)) {
    /inc %adbanhistory 1
    /ban -u240 %chans $nick 3
    /kick $chan $nick Do NOT adverstise. ( $+ %adbanhistory $+  users.)
  }
}
*/
*/    Public Commands
*/
*/
on 1:text:*:%chans:{
  if (($flood(chanflood, $nick, $chan, 4, 4, 1) == f) && ($nick !isop $chan)) {
    /ban -u350 $chan $nick 3
    /mode $chan +m
    /timerum 1 10 mode $chan -m
  }
  elseif ((%id == $left($1, $calc($len($1) - $calc($len($1) - 1)))) && ($nick isop $chan)) {
    if ($right($1, $calc($len($1) - 1)) == commands) {
      /msg $chan Commands: $iif(%roster,  $+ %id $+ Roster), $iif(%record,  $+ %id $+ Record), $iif(%sponsors,  $+ %id $+ Sponsors), $iif(%website,  $+ %id $+ Website), $iif(%server,  $+ %id $+ Server), $iif(%cal,  $+ %id $+ CAL), $iif(%ugs,  $+ %id $+ UGS)
      /timeradmin 1 1 notice $nick $chr(34) $+  $+ %id $+ Set <cmd> <text> $+ $chr(34) - To change any of the above responses. ( $+ %id $+ Set mode <Pub/Priv>) - Pub = msg chan - Priv = notice nick
    }
    elseif ($right($1, $calc($len($1) - 1)) == help) {
      /msg $chan Commands: $iif(%roster,  $+ %id $+ Roster), $iif(%record,  $+ %id $+ Record), $iif(%sponsors,  $+ %id $+ Sponsors), $iif(%website,  $+ %id $+ Website), $iif(%server,  $+ %id $+ Server), $iif(%cal,  $+ %id $+ CAL), $iif(%ugs,  $+ %id $+ UGS)
      /timeradmin 1 1 notice $nick  $chr(34) $+  $+ %id $+ Set <cmd> <text> $+ $chr(34) - To change any of the above responses. ( $+ %id $+ Set mode <Pub/Priv>) - Pub = msg chan - Priv = notice nick
    }
    elseif ($right($1, $calc($len($1) - 1)) == roster) {
      %mode $iif(%mode == /msg, $chan, $nick) Roster: %roster
    }
    elseif ($right($1, $calc($len($1) - 1)) == sponsors) {
      %mode $iif(%mode == /msg, $chan, $nick) Sponsors: %sponsors
    }
    elseif ($right($1, $calc($len($1) - 1)) == website) {
      %mode $iif(%mode == /msg, $chan, $nick) Website: %website
    }
    elseif ($right($1, $calc($len($1) - 1)) == cal) {
      %mode $iif(%mode == /msg, $chan, $nick) CAL: %cal
    }
    elseif ($right($1, $calc($len($1) - 1)) == ugs) {
      %mode $iif(%mode == /msg, $chan, $nick) UGS: %ugs
    }
    elseif ($right($1, $calc($len($1) - 1)) == server) {
      %mode $iif(%mode == /msg, $chan, $nick) Server: %server
    }
    elseif ($right($1, $calc($len($1) - 1)) == record) {
      %mode $iif(%mode == /msg, $chan, $nick) Record: %record
    }
    elseif ($right($1, $calc($len($1) - 1)) == set) {
      if ($2 == mode) {
        if ($3 == pub) {
          /set %mode /msg
          /notice $nick Commands will now be displayed Publicly.
        }
        elseif ($3 == priv) {
          /set %mode /notice
          /notice $nick Commands will now be displayed Privately.
        }
        else {
          /notice $nick Error: Must use "Pub" or "Priv" to change.  (ex. %id $+ set mode pub)
        }
      }
      elseif (($2 == roster) || ($2 == record) || ($2 == sponsors) || ($2 == website) || ($2 == server) || ($2 == cal) || ($2 == ugs)) {
        /set $chr(37) $+ $2 $3-
        /notice $nick Changed to -  $+ $upper($left($2,1)) $+ $lower($right($2, $calc($len($2) - 1))) $+ : $3-
      }
      else {
        /notice $nick  $+ $upper($left($2,1)) $+ $lower($right($2, $calc($len($2) - 1))) $+  - is not a command.
      }
    }
  }
  elseif ((%id == $left($1, $calc($len($1) - $calc($len($1) - 1)))) && ($nick !isop $chan)) {
    if ($right($1, $calc($len($1) - 1)) == commands) {
      /msg $chan Commands: $iif(%roster,  $+ %id $+ Roster), $iif(%record,  $+ %id $+ Record), $iif(%sponsors,  $+ %id $+ Sponsors), $iif(%website,  $+ %id $+ Website), $iif(%server,  $+ %id $+ Server), $iif(%cal,  $+ %id $+ CAL), $iif(%ugs,  $+ %id $+ UGS) 
    }
    elseif ($right($1, $calc($len($1) - 1)) == help) {
      /msg $chan Commands: $iif(%roster,  $+ %id $+ Roster), $iif(%record,  $+ %id $+ Record), $iif(%sponsors,  $+ %id $+ Sponsors), $iif(%website,  $+ %id $+ Website), $iif(%server,  $+ %id $+ Server), $iif(%cal,  $+ %id $+ CAL), $iif(%ugs,  $+ %id $+ UGS)
    }
    elseif ($right($1, $calc($len($1) - 1)) == roster) {
      %mode $nick Roster: %roster
    }
    elseif ($right($1, $calc($len($1) - 1)) == sponsors) {
      %mode $iif(%mode == /msg, $chan, $nick) Sponsors: %sponsors
    }
    elseif ($right($1, $calc($len($1) - 1)) == website) {
      %mode $iif(%mode == /msg, $chan, $nick) Website: %website
    }
    elseif ($right($1, $calc($len($1) - 1)) == cal) {
      %mode $iif(%mode == /msg, $chan, $nick) CAL: %cal
    }
    elseif ($right($1, $calc($len($1) - 1)) == ugs) {
      %mode $iif(%mode == /msg, $chan, $nick) UGS: %ugs
    }
    elseif ($right($1, $calc($len($1) - 1)) == server) {
      %mode $iif(%mode == /msg, $chan, $nick) Server: %server
    }
    elseif ($right($1, $calc($len($1) - 1)) == record) {
      %mode $iif(%mode == /msg, $chan, $nick) Record: %record
    }
  }
}


;$flood 1.2 script
;Elfrond - 2002
;usage: $flood(<description>,<nick|address>,<#channel|query|dcc>,<max>,<secs>,<inc>)

alias flood {
  var %y = $+(f,$cid,,$$1,,$$2,,$$3)
  hadd $+(-mu,$$5) %y $ticks $$6
  var %i = $hget(%y,0).item
  var %x
  while (%i) {
    inc %x $hget(%y,%i).data
    dec %i
  }
  if (%x >= $4) return f
}
Basically, it:
- kick/timebans someone from a channel for spamming their channel name
- bans (without kicking) and sets mode (+m) in chan for text spam of 5 lines in 2 secconds
- .command script (with a set command, to change the variables it displays, along with a different menu for channel ops)

I made an attempt to start this in TCL, but it's not working to well so far...
here is what I have:

Code: Select all

#Gaming Script for clans beta1 by mil1i.
#Objective: to act as a spamblocker/channel advertisement stopper and clanbot.
#Usage: !explain explination 

### VARIABLES ###
set commandv "?Roster ?Record ?Server ?Sponsors ?Webstie ?CAL ?UGS"
set rosterv "socrat3s  tr!cky  sanct!on  abuse  mil1i  t!poff  muruko"
set recordv "CAL-O S12 : 3-0-0  UGS-O S7 : 1-1-0  Overall : 4-1-0"
set serversv "Nuclear Fallout Priv Server: happy.nuclearfallout.net:27015"
set sponsorsv "www.abusegaming.com"
set websitev "www.happy-gaming.com"
set ugsv "http://ugsleague.com/?lid=0&sid=clans&cid=21074"
set calv "http://caleague.com/?page=teams&teamid=16038"

### SCRIPT ### 
bind pub - ?commands pub:commands 
bind pub - ?roster pub:roster
bind pub - ?record pub:record
bind pub - ?servers pub:servers
bind pub - ?sponsors pub:sponsors
bind pub - ?website pub:website
bind pub - ?ugs pub:ugs
bind pub - ?cal pub:cal
bind pub - ?set pub:set


### OUTPUTS ###
proc pub:commands {nick uhost hand chan text} { 
 global botnick commandv
 putquick "PRIVMSG $chan :$commandv"; return 0 
} 
proc pub:roster {nick uhost hand chan text} { 
 global botnick rosterv
 putquick "NOTICE $nick  :$rosterv"; return 0 
} 
proc pub:record {nick uhost hand chan text} { 
 global botnick recordv
 putquick "NOTICE $nick  :$recordv"; return 0 
} 
proc pub:servers {nick uhost hand chan text} { 
 global botnick serversv
 putquick "PNOTICE $nick  :$serversv"; return 0 
} 
proc pub:sponsors {nick uhost hand chan text} { 
 global botnick sponsorsv
 putquick "NOTICE $nick :$sponsorsv"; return 0 
} 
proc pub:website {nick uhost hand chan text} { 
 global botnick websitev
 putquick "NOTICE $nick  :$websitev"; return 0 
} 
proc pub:ugs {nick uhost hand chan text} { 
 global botnick ugsv
 putquick "NOTICE $nick  :$ugsv"; return 0 
} 
proc pub:cal {nick uhost hand chan text} { 
 global botnick calv
 putquick "NOTICE $nick  :$calv"; return 0 
} 
#proc pub:set {nick uhost hand chan text} {
# global commandv rosterv recordv serversv sponsorsv websitev ugsv calv
# if {[isop $nick $chan]} {
#  lset sponsorsv {} {Sponsors: $text}
#  putquick "NOTICE $nick :Changed to - Sponsors: $text"; return 0
# }
#}



### CHANEL ADVERTISEMENT PROTECT ###
bind pubm - "*#*" pub:chanadvsm
proc pub:chanadvsm {nick uhost hand chan text {dest ""}} {
  if {![isop $nick $chan]} {
  pushmode $chan +b $nick
  pushserv "BAN $chan $nick "
  putkick $chan $nick "Do NOT advertise. Temp 5m Ban."; return 0
  }
}


#bind act - "*#*" pub:actionadv
#bind notc - "*#*" pub:noticeadv

Any help would be nice. :( HELP!!!! lol
User avatar
qwek
Voice
Posts: 35
Joined: Tue Sep 21, 2004 7:51 am
Location: space

Post by qwek »

mil1i: what game is that? anyway i cant describe how to making a copy game from irc game into tcl eggdrop game, maybe someone will helping you to figure out this code :D. i'm a newbie too but i'm still learning.


Regards,
qwek
m
mil1i

Post by mil1i »

Ok, I found a change to use so far for the variables at the beginning. I first open the file with the variable responses to the .command scritps, and store all the data to var lines. Then it when it actually sets the variables, it sets to whatever the updated clanbot.txt is stored too. Next, I need to learn how to replace an entire certain line, read just a certain line, and output it. Then that should be fine for what I need for that. But also, my channel advertise protection isn't working still lol. I had it working!!!!!!!! Now it won't work. I'm so confused. I don't think I changed anything.

Code: Select all

#Respond channel
set my_chan "#>-lo"

# File name to read.
set fname "clanbot.txt"

# Open file for read access (note we're not catching errors, you
# want to use catch {} if the file might not exist.
set fp [open $fname "r"]

# Here we read in all of the data.
set data [read -nonewline $fp]

# Cloes the file, since we're done reading.
close $fp

# Now we split the data into lines.
set lines [split $data "\n"]


### VARIABLES ###
set commandv "lindex $lines 0"
set rosterv "lindex $lines 1"
set recordv "lindex $lines 2"
set serversv "lindex $lines 3"
set sponsorsv "lindex $lines 4"
set websitev "lindex $lines 5"
set ugsv "lindex $lines 6"
set calv "lindex $lines 7"
And it's not a game for IRC. :( I Just named it that lols. It's more of a clanbot command script, that allows channel ops to change the variables, and how I had it mIRC code, I made it so the ops could also change the method of output (channel message, or private notice) thru the code:

Code: Select all

$iif(%mode == /msg, $chan, $nick)
Where it basically says:
If variable mode is set to /msg, then channel message the following... if not, if variable mode is not set to /msg (otherwise, the only other thing it could be set to is notice), private notice the nick triggering the event.
Locked