Inactive Auctionbot Revamp

V4Victini

再起不能
is a Battle Simulator Admin Alumnusis a Community Leader Alumnusis a Programmer Alumnusis a Top Researcher Alumnus
I edited the current auctionbot script to be easier to set up. I'll add some documentation below. For any Questions, Comments, Requests, or Concerns please just post below.

Download auctionbot.mrc
Code:
on *:LOAD: {
  ; This file contains the default settings.
  set %spl.ini $sfile($scriptdir.ini, Select Auction Settings File)

  ; This could be a base template so we just make a copy of this to work with for our auction
  set %spl.template.ini %spl.ini

  ; Copy is named running-FILE.ini and is located in the same folder as this script
  set %spl.ini $qt($+($scriptdirrunning-,$nopath(%spl.ini)))
  copy -o %spl.template.ini %spl.ini

  set %spl.players.txt $qt($sfile($scriptdir.txt, Select Players' File))
  set %spl.bought.log $qt($scriptdirbought.log)

  ; If there is already an ACTIVE bought.log, remove it
  if ($isFile(%spl.bought.log)) remove %spl.bought.log
  var %i = 1, %defaults
  while ($ini(%spl.ini, settings, %i)) {
    var %defaults = $+(%defaults,$crlf,$v1,:,$chr(32),$readini(%spl.ini, settings, $v1))
    inc %i
  }
  var %useSettings = $?!=" Use these settings? $crlf %defaults "
  if (!%useSettings) {
    var %i = 1
    while ($ini(%spl.ini, settings, %i)) {
      var %setting = $v1
      if ($?=" %setting (Leave blank to skip)") writeini %spl.ini settings %setting $v1
      inc %i
    }
  }
  auctionstart
}
on *:TEXT:!*:%spl.chan: {
  if ($1 == !showteam) && ($isTeam($2)) {
    msg $iif($chan,$v1,$nick) $getfullname($2) Credits: $getcredits($2) $chr(124) Bidders: $getbidders($2) $chr(124) Players: $getplayers($2)
  }
  if ($chan) {
    if (($1 == !withdraw) && (%spl.active == 1) && ($getbidderteam($nick) == $getcurrteam)) {
      if ($getnumplayers($getcurrteam) < $getminplayers) {
        msg $chan  $+ %colour $+ Team must have purchased $v2 players before withdrawing.
        return
      }
      set %spl.skip $puttok(%spl.skip,0,$getteam($getcurrteam),32)
      msg $chan $getfullname($getcurrteam) have withdrawn from the auction.
      msg $chan $getfullname($getnext) up to nominate. Bidders: $getbidders($getcurrteam)
    }
    if (($1 == !nominate || $1 == !nom) && (%spl.active == 1) && ($getbidderteam($nick) == $getcurrteam)) {
      var %player = $2-
      if ($isPlayer(%player)) {
        var %player = $v1
        if ($isBought(%player)) {
          msg $chan $+(,%colour,,%player,) has already been sold.
          return
        }
        msg $chan $+(,%colour,$getplayerdata(%player))
        set %spl.nominated %player
        set %spl.active 2
        set %spl.highbid $getminbid
        set %spl.highbidteam $getcurrteam
        set %spl.bids $puttok(%spl.bids, %spl.highbid, $getteam(%spl.highbidteam), 32)
        msg $chan $getfullname(%spl.highbidteam) $+ : %spl.highbid
        .timerinitial 1 %spl.time lastten
      }
      else {
        msg $chan $getfullname($getbidderteam($nick)) $+ : Player " $+ %player $+ " not found.
      }
    }
    if ((($left($right($1,-1),1) isnum) || ($left($right($1,-1),1) == +)) && (%spl.active == 2)) {
      echo -s : Bid placed
      if ($isbidder($nick)) {
        echo -s : Bidder recognized
        if (!$gettok(%spl.skip,$getteam($getbidderteam($nick)),32)) {
          return
        }
        var %bid $processbid($right($1,-1))
        if (!%bid) {
          msg $chan $getfullname($getbidderteam($nick)) $+ : Invalid bid amount.
          return
        }
        if (%bid < $getminbid) {
          msg $chan $getfullname($getbidderteam($nick)) $+ : Minimum bid is $getminbid $+ .
          return
        }
        if (($right(%bid,3) != 000) && ($right(%bid,3) != 500)) {
          msg $chan $getfullname($getbidderteam($nick)) $+ : Only bids that are multiples of 500 are accepted.
          return
        }
        if (%bid > $getmaxbid($getbidderteam($nick))) {
          msg $chan $getfullname($getbidderteam($nick)) $+ : Bid exceeds max bid of $getmaxbid($getbidderteam($nick)) $+ .
          return
        }
        if (%bid > $getcredits($getbidderteam($nick))) {
          msg $chan $getfullname($getbidderteam($nick)) $+ : Bid exceeds your credit amount $+ .
          return
        }
        if (%bid < $calc(%spl.highbid + 500)) {
          msg $chan $getfullname($getbidderteam($nick)) $+ : Bid must be at least 500 above %spl.highbid $+ .
          return
        }
        set %spl.highbid %bid
        set %spl.highbidteam $getbidderteam($nick)
        set %spl.bids $puttok(%spl.bids,%bid,$getteam($getbidderteam($nick)),32)
        msg $chan $getfullname($getbidderteam($nick)) $+ : %bid
        if (%spl.10) {
          lastten
        }
      }
    }
    ; Host Stuff
    if ($isTok($readini(%spl.ini, settings, adminHosts),$address($nick,2),32)) {
      echo -s Admin Access: $nick
      if ($1 == !showall) {
        var %i 1
        while ($ini(%spl.ini, teams, %i)) {
          var %team = $v1
          msg $chan $getfullname(%team) Credits: $getcredits(%team)  $+ $chr(124) Bidders: $getbidders(%team) $chr(124) Players: $getplayers(%team)
          inc %i
        }
      }
      if (($1 == !setchan) && ($2)) {
        join $2
        set %spl.chan $2
        msg $chan  $+ %colour $+ Commands will now function only in $2 $+ .
      }
      if (($1 == !addcredits) && ($isTeam($2)) && ($3 isnum)) {
        writeini %spl.ini credits $2 $calc($getcredits($2) + $3)
        msg $chan  $+ %colour $+  $+ $3 credits added to $getfullname($2) $+ .
      }
      if (($1 == !addretainer) && ($isTeam($2)) && ($3 isnum) && ($0 > 3)) {
        if ($isPlayer($4-)) {
          buyPlayer $2 $3 $4-
          msg $chan  $+ %colour $+  $+ $4- retained by $getfullname($2) for $3 $+ .
        }
        else {
          msg $chan $getfullname($2) $+ : Player " $+ $4- $+ " not found.
        }
      }
      if (($1 == !settimer) && ($2 isnum)) {
        set %spl.time $2
        msg $chan  $+ %colour $+ Initial timer changed to $2 seconds.
      }
      if ($1 == !undobid) {
        msg $chan  $+ %colour $+ The highest bid has been forcefully retracted.
        set %spl.highbid $gettok($sorttok(%spl.bids,32,nr),2,32)
        set %spl.highbidteam $ini(%spl.ini, teams, $findtok(%spl.bids,%spl.highbid,1,32))
        msg $chan $getfullname(%spl.highbidteam) $+ : %spl.highbid
      }
      if (($1 == !pause) && (%spl.active >= 1)) {
        turntimersoff
        msg $chan  $+ %colour $+ The auction has been paused.
        set %spl.active 4 %spl.active
      }
      if (($1 == !resume) && ($gettok(%spl.active,1,32) == 4)) {
        set %spl.active $gettok(%spl.active,2,32)
        msg $chan  $+ %colour $+ The auction has been resumed.
        if (%spl.active == 2) {
          .timerinitial 1 %spl.time lastten
          msg $chan $getfullname(%spl.highbidteam) $+ : %spl.highbid
        }
        else if (%spl.active == 3) {
          .timercont 1 3 nextbidding
        }
      }
      if (($1 == !start) && (!%spl.active)) {
        msg $chan $getfullname($getnext) up to nominate. Bidders: $getbidders($getcurrteam)
        set %spl.active 1
      }
      if (($1 == !next) && (%spl.active)) {
        msg $chan  $+ %colour $+ Skipping to next team.
        msg $chan $getfullname($getnext) up to nominate. Bidders: $getbidders($getcurrteam)
        set %spl.active 1
        turntimersoff
      }
      if ($1 == !reset) {
        resetauction
        msg $chan  $+ %colour $+ All details have been reset.
      }
      if ((($1 == !setcolour) || ($1 == !setcolor)) && ($2 isnum)) {
        if ($len($2) == 2) {
          set %colour $2
        }
        else {
          set %colour 0 $+ $2
        }
        msg $chan  $+ %colour $+ Text color changed.
      }
      if (($1 == !addbidder) && ($isTeam($2)) && ($3)) {
        if ($isbidder($3)) {
          msg $chan  $+ %colour $+ $3 is already a bidder for $getfullname($getbidderteam($3)) $+ .
          return
        }
        writeini %spl.ini bidders $2 $addtok($readini(%spl.ini, bidders, $2), $3, 44)
        msg $chan  $+ %colour $+ $3 added to bidders for $getfullname($2) $+ . Bidders: $getbidders($2)
      }
      if (($1 == !removebidder) && ($isTeam($2)) && ($3)) {
        if (!$isbidder($3, $2)) {
          msg $chan  $+ %colour $+ $3 is not a bidder for $getfullname($2) $+ . Bidders: $getbidders($2)
          return
        }
        writeini %spl.ini bidders $2 $remtok($readini(%spl.ini, bidders, $2), $3, 1, 44)
        msg $chan  $+ %colour $+ $3 removed from bidders for $getfullname($2) $+ . Bidders: $getbidders($2)
      }
      ; New Commands
      if ($1 == !end || $1 == !endauction) {
        endauction
      }
      if ($1 == !savesettings) {
        copy -o %spl.ini $qt($+($scriptdir, $asctime(mmddyy-HHnn)-, $nopath(%spl.template.ini)))
      }
    }
  }
}
on *:TEXT:!setchan #*:*: {
  if ($isTok($readini(%spl.ini, settings, adminHosts),$address($nick,2),32)) {
    join $2
    set %spl.chan $2
    msg $iif($chan,$v1,$nick)  $+ %colour $+ Commands will now function only in $2 $+ .
  }
}
alias turntimersoff {
  .timercont off
  .timerten off
  .timerfive off
  .timerinitial off
}
alias isTeam {
  if ($ini(%spl.ini, teams, $1)) return $true
  return $false
}
alias getminplayers {
  return $iif($readini(%spl.ini, settings, minimumPlayers), $v1, 8)
}
alias getminbid {
  return $iif($readini(%spl.ini, settings, minimumBid) isnum 500-, $v1, 500)
}
alias getmaxbid {
  var %minbid = $getminbid, %minplayers = $getminplayers - 1
  return $calc($getcredits($1) - ($iif($calc(%minplayers - $getnumplayers($1)) >= 0,$calc(%minplayers - $getnumplayers($1)),0) * %minbid))
}
alias processbid {
  var %pbid 0
  var %mbid $1
  if (%mbid isnum 0.5-499) {
    return $iif($numtok($calc(%mbid * 1000),46) == 1,$calc(%mbid * 1000 + %pbid),0)
  }
  else if (%mbid isnum 500-) {
    return $iif($numtok(%mbid,46) == 1,$calc(%mbid + %pbid),0)
  }
  else if ($right(%mbid,1) == k) {
    var %kbid $left(%mbid,-1)
    if (%kbid isnum 0.5-) {
      return $iif($numtok($calc(%kbid * 1000),46) == 1,$calc(%kbid * 1000 + %pbid),0)
    }
  }
  return 0
}
alias getplayerdata {
  var %data $read(%spl.players.txt,s,$+($1,$chr(44)))
  if (%data) var %mplayed = $replace($v1,$chr(44),$+($chr(32),/,$chr(32)))
  return $+(,$1,) is up for auction. $iif(%mplayed, Metagames: $v1)
}
; $isBidder(nick) - If nick is a bidder
; $isBidder(nick, team) - If nick is a bidder for team
alias isbidder {
  if ($0 > 1) return $isTok($readini(%spl.ini, bidders, $2), $1, 44)
  var %i = 0, %isbidder = $false
  while (!%isbidder && $ini(%spl.ini, teams, %i)) {
    var %isbidder = $isTok($readini(%spl.ini, bidders, $v1), $1, 44)
    inc %i
  }
  return %isbidder
}
alias isPlayer {
  if ($read(%spl.players.txt, ns, $+($1,$chr(44)))) return $gettok($read(%spl.players.txt, n, $readn), 1, 44)
  if ($readn) return $gettok($read(%spl.players.txt, n, $v1), 1, 44)
  return
}
alias isBought {
  if ($read(%spl.bought.log, ns, $+($1,$chr(44)))) return $true
  if ($readn) return $true
  return $false
}
alias getbidderteam {
  var %i = 1, %nick = $1
  while ($ini(%spl.ini,bidders,%i)) {
    var %team = $v1
    if ($isTok($readini(%spl.ini, bidders, %team), %nick, 44)) {
      return %team
    }
    inc %i
  }
}
alias getnext {
  set %spl.currbid $calc(%spl.currbid + %spl.currdir)
  var %numTeams = $ini(%spl.ini, teams, 0)
  if (%spl.currbid > %numTeams) {
    set %spl.currbid %numTeams
    set %spl.currdir -1
  }
  else if (%spl.currbid == 0) {
    set %spl.currbid 1
    set %spl.currdir 1
  }
  var %count 0
  while (!$gettok(%spl.skip,$getteam($getcurrteam),32)) {
    set %spl.currbid $calc(%spl.currbid + %spl.currdir)
    if (%spl.currbid > %numTeams) {
      set %spl.currbid %numTeams
      set %spl.currdir -1
    }
    else if (%spl.currbid == 0) {
      set %spl.currbid 1
      set %spl.currdir 1
    }
    inc %count
    if (%count == 20) {
      endauction
      halt
    }
  }
  return $getcurrteam
}
alias getteam {
  return $ini(%spl.ini, teams, $1)
}
alias getcurrteam {
  return $ini(%spl.ini,teams,%spl.currbid)
}
alias getnumplayers {
  if ($ini(%spl.ini, $1, 0)) return $v1
  return 0
}
alias getfullname {
  if ($ini(%spl.ini, teams, $1)) return $+(,$iif($readini(%spl.ini, colors, $1), $v1, %colour),,$readini(%spl.ini, teams, $1),,%colour)
}
alias getcredits {
  return $readini(%spl.ini, credits, $1)
}
alias getbidders {
  return $replace($readini(%spl.ini, bidders, $1), $chr(44), $+($chr(32),/,$chr(32)))
}
alias getplayers {
  var %i = 1, %playerList = ""
  while ($readini(%spl.ini, $1, %i)) {
    %playerList = $addtok(%playerList, $v1, 47) | ; $asc(/)
    inc %i
  }
  return $replace(%playerList, /, $+($chr(32),/,$chr(32)))
}
alias lastten {
  .timerfive off
  .timerten off
  set %spl.10 1
  .timerten 1 15 endbidding
  .timerfive 1 10 msg %spl.chan  $+ %colour $+ 5 seconds remaining.
}

alias endbidding {
  msg %spl.chan  $+ %colour $+ SOLD: %spl.nominated to $getfullname(%spl.highbidteam) for %spl.highbid $+ .
  buyPlayer %spl.highbidteam %spl.highbid %spl.nominated
  set %spl.active 3
  set %spl.bids $regsubex(%spl.bids, /\d+/g, 0)
  unset %spl.10
  if ($getcredits(%spl.highbidteam) < $getminbid) {
    set %spl.skip $puttok(%spl.skip,0,$getteam(%spl.highbidteam),32)
  }
  .timercont 1 8 nextbidding
}
; $buyPlayer(Player, Team, Price)
; /buyPlayer team price player
alias buyPlayer {
  writeini %spl.ini credits $1 $calc($getcredits($1) - $2)
  writeini %spl.ini $1 $calc($getnumplayers($1) + 1) $3-
  write %spl.bought.log $+($3-, $chr(44), $chr(32), $1, $chr(44), $2)
}
alias nextbidding {
  var %i 1
  while ($ini(%spl.ini, teams, %i)) {
    var %team = $v1
    msg %spl.chan $getfullname(%team) Credits: $getcredits(%team)  $+ $chr(124) Players: $getplayers(%team)
    inc %i
  }
  msg %spl.chan $getfullname($getnext) up to nominate. Bidders: $getbidders($getcurrteam)
  set %spl.active 1
}

alias endauction {
  msg %spl.chan  $+ %colour $+ The auction has officially ended.
  turntimersoff
  write %spl.bought.log Log for auction that concluded at $fulldate (EDT) in %spl.chan $(|) UNIX: $ctime
  copy -o %spl.bought.log $qt($+($nofile(%spl.bought.log),bought-,$asctime(mmddyy-HHnn),.log))
  remove %spl.bought.log
  remove %spl.ini
}
alias resetauction {
  ; Variables we dont want reset
  var %ini = %spl.ini, %template = %spl.template.ini, %bought = %spl.bought.log, %players = %spl.players.txt
  unset %spl.*
  set %spl.ini %ini
  set %spl.template.ini %template
  set %spl.bought.log %bought
  set %spl.players.txt %players
  turntimersoff
  remove %spl.bought.log
  copy -o %spl.template.ini %spl.ini
  auctionstart
}
alias auctionstart {
  set %colour $iif($readini(%spl.ini, settings, messageColor), $v1, 12)
  var %i = 1, %splteams, %splbids, %splskip, %startCred = $iif($readini(%spl.ini, settings, startCredits), $v1, 80000)
  while ($ini(%spl.ini, teams, %i)) {
    var %splteams = $addtok(%splteams, $v1, 32)
    remini %spl.ini $v1
    ; Figure out how much credits the team should start with
    writeini %spl.ini credits $v1 $iif($readini(%spl.ini, credits, $v1) isnum, $iif(+* iswm $v1 || -* iswm $v2, $calc(%startCred + $v2), $v2), %startCred)
    var %splbids = $instok(%splbids, 0, 0, 32)
    var %splskip = $instok(%splskip, 1, 0, 32)
    inc %i
  }
  set %spl.teams %splteams
  set %spl.bids %splbids
  set %spl.skip %splskip
  set %spl.currbid 0
  set %spl.currdir 1
  set %spl.time $readini(%spl.ini, settings, timer)
  set %spl.chan $readini(%spl.ini, settings, chan)
  set %spl.active 0
}

Download auction_setup.txt
Code:
/* The editted spl script works EXACTLY like the old one.
* The only difference is that it should be a little easier to set up
* You need two files.
* - A .ini file that contains setting information
* - A .txt file that contains player information
* Once you have these two files. Simply load the script and select them when prompted.
* Then confirm your settings or change them if you wish.
*/

/* Player Info Format. Metas can be left blank.
* Player Name, The comma signifies the end of the name and is required.
* When adding a list of metas make sure you seperate it from the comma with a space
*/
// OK
Player Name, Meta 1,Meta 2,Meta 3
// OK
Player Name,
// NOT OK
Player Name,Meta 1,Meta 2,Meta 3
// NOT OK
Player Name
// NOT OK
Player Name Meta 1 Meta 2 Meta 3

/* bought.log - This file is automatically generated, Check it for a pseudo-log.
* Once again note the space
*/
Player Name, Buyer,Price

// The settings ini file looks like this.
[teams] - List of teams / team names. Most important.
code=team name

[colors] - Specify a teams color
code=##

[credits] - Specify starting credits, if different than default specified in settings
code=N

[bidders] - List of bidders by team
code=IRC_Nick,IRC_Nick,IRC_Nick,...,

[settings]
startCredits - amount of credits each team begins with by default
chan - channel the auction will be held in / commands will work in
timer - how long until bid wins
messageColor - color of the bot's text
adminHosts - hosts of nicks that can use commands like !addcredits and !showall, *!*@host.here format
minimumBid - minimum you have to bid on a player
minimumPlayers - minimum amount of players a team can have


Example:
Code:
[teams]
mcm=Team McMeghan
gab=Team Gab
vin=Team Vinc2612

[colors]
mcm=02
gab=03
vin=04

[bidders]
mcm=McMeghan
gab=Gab
vin=Vinc2612

[settings]
startCredits=80000
chan=#spl
timer=20
messageColor=12
adminHosts=*!*@m.catcher *!*@Dont.get.burned
minimumBid=1000
minimumPlayers=8
Code:
sparktrain, ORAS,TangMa,LC UU,BW2,DPP
melon, ORAS
rumor, ORAS,TangMa,LC UU,BW2,DPP
kingler12345, ORAS,TangMa,LC UU,BW2
soldier, ORAS
dundies, ORAS
tuo, ORAS,TangMa,LC UU,BW2,DPP
coinstalker, ORAS
level 56, ORAS
lasagne, ORAS,TangMa,LC UU,BW2,DPP
kavatika, ORAS,TangMa
the avalanches, ORAS,TangMa,LC UU
rzl2000, ORAS
Screenshots:


Commands:
!showteam [teamcode]
Displays team information for the specified team

Bidders Only: !withdraw
Withdraws your team from the auction. You can only withdraw when you are up to nominate and you already have the minimum number of players on your team.

Bidders Only: !nominate [Player Name]
Nominates the player to be bid upon. Bidders may use this command when it's their team's turn to nominate.

Bidders Only: ![Bid_Amount]
Bid the specified amount on the player, bids can only be multiples of 500.Example of proper bids are !500 !1000 !1k !5.5k or !6.5

Admin Only: !showall
Displays team information for all teams

Admin Only: !setchan [#channel]
Changes the channel the bot's commands will work in

Admin Only: !addcredits [teamcode] [amount]
Adds the specified amount to the specified teams current credit total

Admin Only: !addretainer [teamcode] [amount] [Player Name]
Adds the specified player to the specified team at the cost of the specified amount of credits.

Admin Only: !settimer [seconds]
Changes how long the highest bid has to go uncontested for the bidding team to win the auction

Admin Only: !undobid
Retracts the current highest bid, returning it to the previous bid amount.

Admin Only: !pause
Halts the auction to be resumed later.

Admin Only: !resume
Resumes a paused auction.

Admin Only: !start
Begins the auction.

Admin Only: !next
Skips the team currently up to nominate.

Admin Only: !reset
Resets the auction to just after the !start command.

Admin Only: !addbidder [teamcode] [IRC_Nick]
Adds the specified IRC user as a bidder for the specified team.

Admin Only: !removebidder [teamcode] [IRC_Nick]
Removes the specified bidder from the specified team.

Admin Only: !setcolor [color_code] or !setcolour [colour_code]
Sets the bot's text color to the specified color code.


New Commands:
[18:13:45] <&Sweep> !nom aim
[18:13:53] <@PROBLEMS> inate
[18:13:54] <~Fireburn> you have to do !nominate
Not anymore! Alias for !nominate

Admin Only: !end or !endauction
Immediately ends the auction.

Admin Only: !savesettings
Saves the current auction's settings as an INI file.
 
Last edited:

Users Who Are Viewing This Thread (Users: 1, Guests: 0)

Top