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.

timebomb help

Support & discussion of released scripts, and announcements of new releases.
Post Reply
r
roughnecks
Voice
Posts: 33
Joined: Sun Sep 14, 2008 9:33 am
Location: Italy

timebomb help

Post by roughnecks »

Hi, i have a request, if it is possible, naturally...here i go:

In timebomb script, if you mispell a nick...or timebomb a non-existent one, the bot still
puts the bomb into the wrong nick's pants...this is a little bug i think

Would you like to help me fix this thing ? I am not able to do it myself.
Maybe the bot could put the bomb into the user who mispelld the nick,
some sort of revenge, i mean...but this is only a suggestion.

So, thank you for reading, hope you can help

I'm going to paste the tcl:

Code: Select all

###############################################################################

bind  pub   -   timebomb  doTimebomb
bind  pub   -   cutwire   doCutWire

###############################################################################
# Configuration
#

set gTimebombMinimumDuration 20
set gTimebombMaximumDuration 60
set gWireChoices "Red Orange Yellow Green Blue Indigo Violet Black White Grey Brown Pink Mauve Beige Aquamarine Chartreuse Bisque Crimson Fuchsia Gold Ivory Khaki Lavender Lime Magenta Maroon Navy Olive Plum Silver Tan Teal Turquoise"
set gMaxWireCount 3

###############################################################################
# Internal Globals
#

set gTheScriptVersion "0.4"
set gTimebombActive 0
set gTimerId 0
set gTimebombTarget ""
set gTimebombChannel ""
set gCorrectWire ""
set gNumberNames "zero one two three four five six seven eight nine ten eleven twelve"

###############################################################################

proc note {msg} {
  putlog "% $msg"
}

proc IRCKick {theNick theChannel theReason} {
  note "Kicking $theNick in $theChannel (Reason: $theReason)"
  putserv "KICK $theChannel $theNick :$theReason"
}

proc IRCPrivMSG {theTarget messageString} {
  putserv "PRIVMSG $theTarget :$messageString"
}

proc IRCAction {theTarget messageString} {
  putserv "PRIVMSG $theTarget :\001ACTION $messageString\001"
}

proc MakeEnglishList {theList} {
  set theListLength [llength $theList]
  set returnString [lindex $theList 0]
  for {set x 1} {$x < $theListLength} {incr x} {
    if { $x == [expr $theListLength - 1] } {
      set returnString "$returnString and [lindex $theList $x]"
    } else {
      set returnString "$returnString, [lindex $theList $x]"
    }
  }
  return $returnString
}

proc SelectWires {wireCount} {
  global gWireChoices
  set totalWireCount [llength $gWireChoices]
  set selectedWires ""
  for {set x 0} {$x < $wireCount} {incr x} {
    set currentWire [lindex $gWireChoices [expr int( rand() * $totalWireCount )]]
    if { [lsearch $selectedWires $currentWire] == -1 } {
      lappend selectedWires $currentWire
    } else {
      set x [expr $x - 1]
    }
  }
  return $selectedWires
}

proc DetonateTimebomb {destroyTimer kickMessage} {
  global gTimebombTarget gTimerId gTimebombChannel gTimebombActive
  if { $destroyTimer } {
    killutimer $gTimerId
  }
  set gTimerId 0
  set gTimebombActive 0
  IRCKick $gTimebombTarget $gTimebombChannel $kickMessage
}

proc DiffuseTimebomb {wireCut} {
  global gTimerId gTimebombActive gTimebombTarget gTimebombChannel
  killutimer $gTimerId
  set gTimerId 0
  set gTimebombActive 0
  IRCPrivMSG $gTimebombChannel "$gTimebombTarget cut the $wireCut wire.  This has defused the bomb!"
}

proc StartTimeBomb {theStarter theNick theChannel} {
  global gTimebombActive gTimebombTarget gTimerId gTimebombChannel gNumberNames gCorrectWire
  global gMaxWireCount gTimebombMinimumDuration gTimebombMaximumDuration
  if { $gTimebombActive == 1 } {
    note "Timebomb not started for $theStarter (Reason: timebomb already active)"
    if { $theChannel != $gTimebombChannel } {
      IRCPrivMSG $theChannel "I don't have a single bomb to spare. :-("
    } else {
      IRCAction $theChannel "points at the bulge in the back of $gTimebombTarget's pants."
    }
  } else {
    set timerDuration [expr $gTimebombMinimumDuration + [expr int(rand() * ($gTimebombMaximumDuration - $gTimebombMinimumDuration))]]
    set gTimebombTarget $theNick
    set gTimebombChannel $theChannel
    set numberOfWires [expr 1 + int(rand() * ( $gMaxWireCount - 0 ))]
    set listOfWires [SelectWires $numberOfWires]
    set gCorrectWire [lindex $listOfWires [expr int( rand() * $numberOfWires )]]
    set wireListAsEnglish [MakeEnglishList $listOfWires]
    set wireCountAsEnglish [lindex $gNumberNames $numberOfWires]
    IRCAction $theChannel "stuffs the bomb into $gTimebombTarget's pants.  The display reads \[\002$timerDuration\002\] seconds."
    if { $numberOfWires == 1 } {
      IRCPrivMSG $theChannel "Diffuse the bomb by cutting the correct wire. There is $wireCountAsEnglish wire. It is $wireListAsEnglish."
    } else {
      IRCPrivMSG $theChannel "Diffuse the bomb by cutting the correct wire. There are $wireCountAsEnglish wires. They are $wireListAsEnglish."
    }
    note "Timebomb started by $theStarter (Bomb handed to $theNick it will detonate in $timerDuration seconds)"
    set gTimebombActive 1
    set gTimerId [utimer $timerDuration "DetonateTimebomb 0 {\002*BOOM!*\002}"]
  }
}

###############################################################################
# Eggdrop command binds
#

proc doCutWire {nick uhost hand chan arg} {
  global gTimebombActive gCorrectWire gTimebombTarget
  if { $gTimebombActive == 1 } {
    if { [string tolower $nick] == [string tolower $gTimebombTarget] } {
      if { [llength $arg] == 1 } {
        if { [string tolower $arg] == [string tolower $gCorrectWire] } {
          DiffuseTimebomb $gCorrectWire
        } else {
          DetonateTimebomb 1 "\002snip...*BOOM!*\002"
        }
      }
    }
  }
}

proc doTimebomb {nick uhost hand chan arg} {
  global botnick
  set theNick $nick
  if { [llength $arg] == 1 } {
    set theNick [lindex [split $arg] 0]
  }
  if { [string tolower $theNick] == [string tolower $botnick] } {
    set theNick $nick
    IRCKick $theNick $chan "I will not tollerate this!"
    return
  }
  if { [validuser $theNick] == 1 } {
    if { [matchattr $theNick "+b"] == 1 } {
      set theNick $nick
      IRCKick $theNick $chan "I will not tollerate that!"
      return
    }
  }
  StartTimeBomb $nick $theNick $chan
}

###############################################################################

note "timebomb$gTheScriptVersion: loaded";
note " with $gMaxWireCount wire maximum,"
note " and time range of $gTimebombMinimumDuration to $gTimebombMaximumDuration seconds.";
[/code]
User avatar
tomekk
Master
Posts: 255
Joined: Fri Nov 28, 2008 11:35 am
Location: Oswiecim / Poland
Contact:

Post by tomekk »

I didn't test it, but I think the bomb proc should check if the nick exist on the chan before start, try:

Code: Select all

proc doTimebomb {nick uhost hand chan arg} { 
  global botnick 
  set theNick $nick 
  if { [llength $arg] == 1 } { 
    set theNick [lindex [split $arg] 0] 
  } 
  if { [string tolower $theNick] == [string tolower $botnick] } { 
    set theNick $nick 
    IRCKick $theNick $chan "I will not tollerate this!" 
    return 
  } 
  if { [validuser $theNick] == 1 } { 
    if { [matchattr $theNick "+b"] == 1 } { 
      set theNick $nick 
      IRCKick $theNick $chan "I will not tollerate that!" 
      return 
    } 
  }

  #here is fix
  if {[onchan $theNick $chan]} { 
      StartTimeBomb $nick $theNick $chan 
  }
}
r
roughnecks
Voice
Posts: 33
Joined: Sun Sep 14, 2008 9:33 am
Location: Italy

Post by roughnecks »

Thanks....it works perfectly
Now the bot ignores requests with wrong nicknames.

:)
r
roughnecks
Voice
Posts: 33
Joined: Sun Sep 14, 2008 9:33 am
Location: Italy

Post by roughnecks »

I've added a piece of code to yours:

Code: Select all

# fix: nick exists?
if {[onchan $theNick $chan]} {
      StartTimeBomb $nick $theNick $chan
  } else {
      IRCPrivMSG $chan "Get a pair of glasses"
    }

Thats not a big thing, but...
I thing i 'll go and study some tcl scripting :lol:
I
Ikaa
Voice
Posts: 7
Joined: Wed Dec 17, 2008 3:46 pm

Post by Ikaa »

Very handy code change! Now my timebomb is channel restricted AND doesnt waste time trying to kick invalid names.
t
testebr
Halfop
Posts: 86
Joined: Thu Dec 01, 2005 12:22 pm

Post by testebr »

compile all changes and release in egghelp.org database :]
r
roughnecks
Voice
Posts: 33
Joined: Sun Sep 14, 2008 9:33 am
Location: Italy

Post by roughnecks »

testebr wrote:compile all changes and release in egghelp.org database :]
are you saying to me ? :roll:
Post Reply