A person can "sell" something via auction, using the !sell command
While an auction is in progress, people can bid using !bid
All commands work via pm or oin channel. Seller must have a common channel with the bot/client running the code in order to sell. Bidders (at the time of bidding) must also have a common channel.
Help is available using !auction help
Auctions run for one day, unless the client exits/disconnects, in which case the auction is "held" until the next connection, when the timers for the auctions will resume from where they left off.
I was unable to figure out how to incorporate an incremental increase for the bids, so that a maximum bid could be entered (similar to the way E-Bay works)
When a new high bid is entered, the seller, highbidder (and if applicable old highbidder) are notified via a notice.
At the end of the auction, the seller and the highbidder are notified, unless there have been no bids, in which case the seller is told so.
Seller's are not allowed to bid on their own auctions, and changing nicks won't help, as nick changes are accounted for.
on *:exit:{
save_auctions
}
on *:disconnect:{
save_auctions
}
alias save_auctions {
var %a = 1, %b = $timer(0)
while %a <= %b {
var %auction = $timer(%a), %time = $timer(%auction).secs
if Auction isincs %auction {
%details = $hget(%auction), %details = $puttok(%details,%time,-2,32)
.hadd -m Auction %auction %details
}
inc %a
}
.hsave -o Auction Auction.hsh
}
on *:start:{
if !$hget(Auction) { .hmake Auction 100 }
if $exists(Auction.hsh) { .hload Auction Auction.hsh }
}
on *:connect:{
var %a = 1, %b = $hget(Auction,0}.item
while %a <= %b {
var %timer.name = $hget(Auction,%a), %timer = $gettok($hget(Auction,%a).data,-2,32)
if !$timer(%timer.name) {
$+(.timer,.,%timer.name) 1 %timer end_auction $gettok(%timer.name,1,46) $gettok(%timer.name,2,46)
}
inc %a
}
}
on me:*:join:#:{
if $hget(Auction,0).item {
.notice $chan There are $hget(Auction,0).item auction(s) in progress
}
}
on *:text:!auction*help:*:{
.timer 1 1 .msg $nick Auction Help
.timer 1 2 .msg $nick ============
.timer 1 4 .msg $nick To sell items, use !sell <item description> <price>
.timer 1 5 .msg $nick <price> is the minimum amount that you are willing to sell for
.timer 1 6 .msg $crlf
.timer 1 8 .msg $nick To bid for an item, use !bid <auction.id> <bid>
.timer 1 9 .msg $nick A message will be sent to you if you are outbid or if you are the winner at the end of the auction
.timer 1 10 .msg $nick $crlf
.timer 1 12 .msg $nick You are not allowed to bid on your own auctions
.timer 1 13 .msg $nick $crlf
.timer 1 15 .msg $nick To see a list of current auctions, use !list
.timer 1 16 .msg $nick You and I must have at least one channel in common at the time you put the item up for sale and/or bid for an item
.timer 1 17 .msg $nick Auctions run for one (1) day unless I get disconnected, in which case all current bids & auctions are nullified
}
on *:text:!sell*:*:{
if !$2 || $2 isnum { .notice $nick You didn't specify what you want to sell }
elseif !$comchan($nick,0) { .notice $nick Sorry, but you must be in at least one channel with me to sell items }
else {
var %price = $gettok($2-,-1,32), %item = $gettok($2-,$+(1-$calc($numtok($2-,32) - 1)),32)
if %price !isnum { .notice $nick You didn't specify the minimum selling amount }
else {
.hinc Auction $+($nick,.0)
var %auction = $hget(Auction,$+($nick,.0))
.hadd -m Auction $+($nick,.,%auction) %item %price 86400 $nick
.ame announces that $nick has put %item up for bids.
.ame notes that this item can be referenced using the auction ID of $+($nick,.,%auction)
.ame States that bidding will start at $round($calc(%price / 10),0)
set $+(%,seller,$address) $addtok($($+(%,seller,$address),2),$nick,32)
}
$+(.timer,.,$+($nick,.,%auction)) 1 86400 end_auction $nick %auction
}
}
on *:nick:{
set $+(%,seller,$address) $addtok($($+(%,seller,$address),2),$newnick,32)
}
on *:text:!bid*:*:{
if !$2 { .notice $nick You didn't specify what you want to bid on }
elseif !$comchan($nick,0) { .notice $nick Sorry, but you must be in at least one channel with me to bid on items }
elseif $3 !isnum { .notice $nick You can't bid an amount of 0 }
elseif !$hget(Auction,$2) { .notice $nick Sorry, I can't find that auction }
else {
var %seller = $gettok($2,1,46)
if $istok($($+(%,seller,$address),2),$nick,32) { .notice $nick You can't bid on your own items }
else {
var %details = $hget(Auction,$2)
var %time = $gettok(%details,-2,32)
var %price = $gettok(%details,-3,32)
var %item = $numtok(%details,32)
dec %item 3
%item = $gettok(%details,$+(1-,%item),32)
if $3 > %price {
var %oldhigh = $gettok(%details,-1,32), %newhigh = $nick, %price = $3
.enable #bid_notice
.ison %seller %oldhigh
.notice $nick You now have high bid for auction ID %id
.hadd -m Auction $2 $3 $timer($2).secs $nick
}
else {
.notice $nick Sorry, but the current bid for this item is %price
}
}
}
}
#bid_notice off
raw 303:*:{
if $istok($2-,%seller,32) {
.notice %seller %newhigh has just set a high bid for auction ID %id
}
if $istok($2-,%highbidder,32) {
.notice %oldhigh You have been outbid on auction ID %id $+ . Current bid is %price
}
.disable #bid_notice
}
#bid_notice end
on *:text:!list:*:{
var %a = 1, %b = $hget(Auction,0).item
.msg $nick There are $bytes(%b,b) auctions
while %a <= %b {
var %auction = $hget(Auction,%a).item
var %item = $numtok($hget(Auction,%auction),32)
dec %item
%item = $gettok($hget(Auction,%auction),$+(1-,%item),32)
var %price = $gettok($hget(Auction,%auction),-1,32)
var %time = $timer(%auction).secs
.timer 1 %a .msg $nick Auction: %auction - Item: %item - Price: %price - Time Remaining: $duration(%time)
inc %a
}
}
alias -l end_auction {
var %seller = $1
var %auction = $+($1,.,$2)
%highbidder = $gettok($hget(Auction,%auction),-1,32)
%price = $gettok($hget(Auction,%auction),-2,32)
if %highbidder == %seller {
.notice %seller Sorry but your item didn't sell
}
else {
.enable #auction_end
.ison %seller %highbidder
}
}
#auction_end off
raw 303:*:{
if $istok($2-,%seller,32) {
.notice %seller Congratulations, %highbidder has made the highest bid of %price for %item (Auction ID: %auction)
}
if $istok($2-,%highbidder,32) {
.notice %highbidder Congratulations, You have won auction ID %auction by %seller for %item
}
.hdel Auction %auction
.disable #auction_end
}
#auction_end end
-> Neptune
if %price !isnum <---
You put 32,000 <- here is a token "," isnum return true when is only numbers.
=)
try $remove(%price,$chr(36),$chr(46),$chr(44)) <-
!sell lol $32,000.000 = 32000000
^^
alias test {
%price = $remove($1,$chr(36),$chr(46),$chr(44))
if ( %price !isnum ) {
echo -a %price
}
else {
echo -a %price
}
;unset %price
}
Due to the fact that I was unable to find any kind of consistancy regarding when the script worked and when it didn't, I stopped working on it, and as you can tell from the date of my last post here, it's been over a year.
I have a couple of other projects on the go right now, but once I have them completed, or if I find myself needing a break, I will see about re-doing this project.
Would it be possible to maybe incorporate a "buy it now!" feature when you're putting an item up for auction?
I'm also really confused at this:
[09:49:16] <~Neptune> !sell moon 32,000
[09:49:17] -X- You didn't specify the minimum selling amount
[09:50:10] <~Neptune> !sell moon 32,000 40,000
[09:50:12] -X- You didn't specify the minimum selling amount
The help topics show nothing of a minimum amount. :O
My apologies to those that have had problems with this script.
I\'ve had other people show the same problems, and yet, other people haven\'t had any problems.
I am still trying to get this worked out.
I realize that this has been a long time working on it, but there have been several other things that have come up and required my attention, but I have not forgotten about this.