All pastes #744273 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-10-21 08:37 UTC
rendered paste body
ON *:START:{
  hmake x.c.aidt
  if ( $exists($scriptdir $+ info\x.c.aidt.txt) == $true ) { hload x.c.aidt " $+ $scriptdir $+ info\x.c.aidt.txt $+ " }
  echo -s $x.hmake(aid.gold.amnt)
  echo -s $x.hmake(aid.gold.time)
  echo -s $x.hmake(aid.gold.comm)
  echo -s $x.hmake(aid.rune.amnt)
  echo -s $x.hmake(aid.rune.time)
  echo -s $x.hmake(aid.rune.comm)
  echo -s $x.hmake(aid.sold.amnt)
  echo -s $x.hmake(aid.sold.time)
  echo -s $x.hmake(aid.sold.comm)
  echo -s $x.hmake(aid.food.amnt)
  echo -s $x.hmake(aid.food.time)
  echo -s $x.hmake(aid.food.comm)
}

ON *:EXIT:{
  hsave x.c.aidt " $+ $scriptdir $+ info\x.c.aidt.txt $+ "
  echo -s $x.hsave(aid.gold.amnt)
  echo -s $x.hsave(aid.gold.time)
  echo -s $x.hsave(aid.gold.comm)
  echo -s $x.hsave(aid.rune.amnt)
  echo -s $x.hsave(aid.rune.time)
  echo -s $x.hsave(aid.rune.comm)
  echo -s $x.hsave(aid.sold.amnt)
  echo -s $x.hsave(aid.sold.time)
  echo -s $x.hsave(aid.sold.comm)
  echo -s $x.hsave(aid.food.amnt)
  echo -s $x.hsave(aid.food.time)
  echo -s $x.hsave(aid.food.comm)
}

ON *:TEXT:@set aidtime*:#:{
  if ( $hget(x. $+ $xchan($chan) $+ .user.levl,$xuser($nick,$3)) < 90 ) { notice $nick No council access! | halt }
  if ( $2 !isnum ) { notice $nick specify a number in hours please | halt }
  hadd x.c.aidt $xchan($chan) $calc($2 * 3600)
  notice $nick Length of time for aid requests to show in red has been changed to $2 hrs
}

ON *:TEXT:@need*:#:{
  if ( $x.login($nick,$chan) != $null ) { notice $nick $x.login($nick,$chan) | halt }
  if ( $num($2) !isnum ) { halt }
  if ( $3 == gc || gold isin $3 || coin isin $3 ) { record.aid $nick $chan gold gc $2 $4- | halt }
  if ( sold isin $3 || troop isin $3 || army isin $3 || men isin $3 || boy isin $3 ) { record.aid $nick $chan sold soldiers $2 $4- | halt }
  if ( rune isin $3 ) { record.aid $nick $chan rune runes $2 $4- | halt }
  if ( food isin $3 || bush isin $3 || hay isin $3 ) { record.aid $nick $chan food bushels $2 $4- | halt }
  notice $nick Syntax: 7@need amount7 resource - e.g. @need 5k gc
}


;-- record.aid $nick $chan resourcedb resource amount comment
alias record.aid {
  var %prov = $hget(x. $+ $xchan($2) $+ .user.prov,$xuser($1,$2))
  var %amt = $calc($hget(x. $+ $xchan($2) $+ .aid. $+ $3 $+ .amnt,$replace(%prov,$chr(32),$chr(59))) + $num($5))
  hadd x. $+ $xchan($2) $+ .aid. $+ $3 $+ .amnt $replace(%prov,$chr(32),$chr(59)) %amt
  hadd x. $+ $xchan($2) $+ .aid. $+ $3 $+ .time $replace(%prov,$chr(32),$chr(59)) $gmt
  if ( $6- != $Null ) { hadd x. $+ $xchan($2) $+ .aid. $+ $3 $+ .comm $replace(%prov,$chr(32),$chr(59)) $6- }
  if ( $hget(x. $+ $xchan($2) $+ .aid. $+ $3 $+ .amnt,$replace(%prov,$chr(32),$chr(59))) > $num($5) ) {
    msg $2 10 $tnum(%amt) $4 14total $chr(124) 10 $+ %prov 14 $+ $chr(124) 14 $+ $hget(x. $+ $xchan($2) $+ .aid. $+ $3 $+ .comm,$replace(%prov,$chr(32),$chr(59))) 
    halt
  }
  notice $1 $2 $+ : Aid request of10 $num($5) $4 recorded, %prov
}


ON *:TEXT:@clearaid*:#:{
  if ( $x.login($nick,$chan) != $null ) { notice $nick $x.login($nick,$chan) | halt }
  if ( $2 == $null ) {
    clear.aid $hget(x. $+ $xchan($chan) $+ .user.prov,$xuser($nick,$chan)) $chan gold
    clear.aid $hget(x. $+ $xchan($chan) $+ .user.prov,$xuser($nick,$chan)) $chan sold
    clear.aid $hget(x. $+ $xchan($chan) $+ .user.prov,$xuser($nick,$chan)) $chan food
    clear.aid $hget(x. $+ $xchan($chan) $+ .user.prov,$xuser($nick,$chan)) $chan rune
    notice $nick $chan $+ : All your requests have been cleared
  }
  if ( gc isin $2 || gold isin $2 || coin isin $2 ) { clear.aid $chan gold $hget(x. $+ $xchan($chan) $+ .user.prov,$xuser($nick,$chan)) | notice $nick $chan $+ : All your requests for gold have been cleared }
  if ( sold isin $2 || troop isin $2 || army isin $2 || men isin $2 || boy isin $2 ) { clear.aid $chan sold $hget(x. $+ $xchan($chan) $+ .user.prov,$xuser($nick,$chan)) | notice $nick $chan $+ : All your requests for soldiers have been cleared }
  if ( rune isin $2 ) { clear.aid $chan rune $hget(x. $+ $xchan($chan) $+ .user.prov,$xuser($nick,$chan)) | notice $nick $chan $+ : All your requests for runes have been cleared }
  if ( food isin $2 || bush isin $2 || hay isin $2 ) { clear.aid $chan food $hget(x. $+ $xchan($chan) $+ .user.prov,$xuser($nick,$chan)) | notice $nick $chan $+ : All your requests for food have been cleared }
}


;-- clear.aid $chan resourcedb province
alias clear.aid {
  hdel x. $+ $xchan($1) $+ .aid. $+ $2 $+ .amnt $replace($3-,$chr(32),$chr(59))
  hdel x. $+ $xchan($1) $+ .aid. $+ $2 $+ .time $replace($3-,$chr(32),$chr(59))
  hdel x. $+ $xchan($1) $+ .aid. $+ $2 $+ .comm $replace($3-,$chr(32),$chr(59))
}

ON *:TEXT:@sent*:{
  if ( $x.login($nick,$chan) != $null ) { notice $nick $x.login($nick,$chan) | halt }
  if ( $num($2) !isnum ) { halt }
  if ( $3 == gc || gold isin $3 || coin isin $3 ) { echo $reduce.aid($nick,$chan,$4-,$2,gold,gc) | halt }
  if ( sold isin $3 || troop isin $3 || army isin $3 || men isin $3 || boy isin $3 ) { echo $reduce.aid($nick,$chan,$4-,$2,sold,soldiers) | halt }
  if ( rune isin $3 ) { echo $reduce.aid($nick,$chan,$4-,$2,rune,runes) | halt }
  if ( food isin $3 || bush isin $3 || hay isin $3 ) { echo $reduce.aid($nick,$chan,$4-,$2,food,bushels) | halt }
  notice $nick Syntax: 7@sent amount 7resource 7province/user - e.g. @sent $nick 5k gc - you can also paste text from in-game
}

ON *:TEXT:We have sent*to*:#:{
  if ( $x.login($nick,$chan) != $null ) { notice $nick $x.login($nick,$chan) | halt }
  var %s = $calc($pos($1-,to,1) + 3)
  var %e = $calc($pos($1-,$chr(40),1) - 1)
  var %prov = $replace($mid($1-,%s,$calc(%e - %s)),$chr(32),$chr(59))
  if ( Gold Coin isin $1- ) {
    var %amt = $gettok($1-,$calc($findtok($1-,gold,1,32) - 1),32)
    if ( $num(%amt) isnum ) { reduce.aid $nick $chan %prov %amt gold gc }
  }
  if ( Rune isin $1- ) {
    msg $chan amtr is %amtr
    var %amtr = $gettok($1-,$calc($findtok($1-,runes,1,32) - 1),32)
    if ( %amtr == $null ) { var %amtr = $gettok($1-,$calc($findtok($1-,rune,1,32) - 1),32) }
    if ( %amtr > 1 ) { var %s = s }
    if ( $num(%amtr) isnum ) { echo $reduce.aid($nick,$chan,%prov,%amtr,rune,rune $+ %s) }
    msg $chan amtr is %amtr
  }
  if ( soldier isin $1- ) {
    var %amts = $gettok($1-,$calc($findtok($1-,soldiers,1,32) - 1),32)
    if ( %amts == $null ) { var %amts = $gettok($1-,$calc($findtok($1-,soldier,1,32) - 1),32) }
    if ( %amts > 1 ) { var %s = s }
    if ( $num(%amts) isnum ) { echo $reduce.aid($nick,$chan,%prov,%amts,sold,soldier$+ %s) }
  }

  if ( bushel isin $1- ) {
    var %amtb = $gettok($1-,$calc($findtok($1-,bushels,1,32) - 1),32)
    if ( %amtb == $null ) { var %amtb = $gettok($1-,$calc($findtok($1-,bushel,1,32) - 1),32) }
    if ( %amtb > 1 ) { var %s = s }
    if ( $num(%amtb) isnum ) { echo $reduce.aid($nick,$chan,%prov,%amtb,food,bushel $+ %s) }
    msg $chan amtb is %amtb
  }

}

;-- reduce.aid $nick $chan receipient amount resourcedb resource
alias reduce.aid {
  var %r = $x.match($2,$replace($3,$chr(59),$chr(32)),prov)
  var %r = $replace(%r,$chr(32),$chr(59))
  if ( %r == $null ) { notice $1 Couldn't find matching prov/found more than one matching prov. Please specify. | halt }
  var %amnt = $calc($hget(x. $+ $xchan($2) $+ .aid. $+ $5 $+ .amnt,%r) - $num($4))
  if ( %amnt > 0 ) {
    hadd x. $+ $xchan($2) $+ .aid. $+ $5 $+ .amnt %r %amnt
    msg $2 14Thanks for aiding.10 $replace(%r,$chr(59),$chr(32)) 14still wants10 $tnum(%amnt) $6
  }
  if ( %amnt <= 0 ) {
    clear.aid $2 $5 %r
    notice $1 $2 $+ : Thanks for aiding! Request filled.
  }
}

ON *:TEXT:@listaid*:#:{
  if ( gold isin $1- || gc isin $1- || coin isin $1- ) { listaid $chan gold gc | goto done }
  if ( sold isin $1- || troop isin $1- || army isin $1- || men isin $1- || boy isin $1- ) { listaid $chan sold soldiers | goto done }
  if ( rune isin $1- ) { listaid $chan rune runes | goto done }
  if ( food isin $1- || bush isin $1- || hay isin $1- ) { listaid $chan food bushels | goto done }
  listaid $chan gold gc
  listaid $chan sold soldiers
  listaid $chan rune runes
  listaid $chan food bushels
  goto done
  :done
  msg $chan 14 $str(-,20) All listed $str(-,20) 
}

;-- list.aid $chan resourceDB resourcename
alias listaid {
  var %n = 1
  while ( $hget(x. $+ $xchan($1) $+ .aid. $+ $2 $+ .amnt,%n).item ) {
    var %prov = $hget(x. $+ $xchan($1) $+ .aid. $+ $2 $+ .amnt,%n).item
    var %i = 1
    while ( $hget(x. $+ $xchan($1) $+ .user.prov,%i).item ) {
      if ( $hget(x. $+ $xchan($1) $+ .user.prov,%i).data == $replace(%prov,$chr(59),$chr(32)) ) { var %nick = $hget(x. $+ $xchan($1) $+ .user.prov,%i).item }
      inc %i
    }
    var %time = $calc($gmt - $hget(x. $+ $xchan($1) $+ .aid. $+ $2 $+ .time,%prov))
    if ( %time < $hget(x.c.aidt,$xchan($1)) ) { msg $1 10 $+ $tnum($hget(x. $+ $xchan($1) $+ .aid. $+ $2 $+ .amnt,%prov)) $3 14 $+ $chr(124) 10 $+ $replace(%prov,$chr(59),$chr(32)) 14 $+ $chr(40) $+ $no.hl(%nick) $+ $chr(41) $chr(124)  $duration(%time,3) $chr(124) $hget(x. $+ $xchan($1) $+ .aid. $+ $2 $+ .comm,%prov) }
    if ( %time >= $hget(x.c.aidt,$xchan($1)) ) { msg $1 10 $+ $tnum($hget(x. $+ $xchan($1) $+ .aid. $+ $2 $+ .amnt,%prov)) $3 14 $+ $chr(124) 10 $+ $replace(%prov,$chr(59),$chr(32)) 14 $+ $chr(40) $+ $no.hl(%nick) $+ $chr(41) $chr(124) 04 $+ $duration(%time,3) 14 $+ $chr(124) $hget(x. $+ $xchan($1) $+ .aid. $+ $2 $+ .comm,%prov) }
    inc %n
  }
}

---------------------------------------------------------------------------------

xbot.aliases.mrc

-----------------------------------------------------------------------------------
;-- $xuser($nick,$chan) ; returns username for a logged-in address ; xbot.admin.mrc, xbot.kd.db.mrc
alias xuser { return $hget(x. $+ $hget(x.cname.c,$2) $+ .addr.user,$address($1,1)) }

;-- $xchan($chan) ; returns channel db number for a #channel ; xbot.admin.mrc, xbot.kd.db.mrc
alias xchan { return $hget(x.cname.c,$1) }

;-- $no.hl(testing,test) ; returns te!sting ; xbot.kd.db.mrc, xbot.aid.mrc
alias no.hl { return $left($1,3) $+ $chr(39) $+ $right($1,-3) }

;-- $hl(testing,test) ; returns orange "test" in "testing" ; xbot.kd.db.mrc
alias hl { return $replace($1,$2,7 $+ $2 $+ 10) }

;-- $x.login($nick,$chan) ; checks if $nick is logged in, returns $null if he is ; xbot.admin.mrc, xbot.kd.db.mrc
alias x.login {
  if ( $xuser($1,$2) == $null ) { return Login/register first! 7/msg $me xbot login $2 Username 7Password or 7/msg $me xbot register $2 ChannelCode 7Username 7Password }
}

;-- $num(5,000k) ; returns 5000000 ; xbot.aid.mrc
alias num {
  var %n = $remove($1,$chr(44))
  if ( k !isin %n && m !isin %n ) { return %n }
  if ( k isin %n ) { return $calc($remove(%n,k) * 1000 ^ $count(%n,k)) }
  if ( m isin %n ) { return $calc($remove(%n,m) * 1000000 ^ $count(%n,m)) }
}

;-- $tnum(5000000); returns 5,000,000 ; xbot.aid.mrc
alias tnum {
  if ( $1 >= 1000000 ) { return $calc($1 / 1000000) $+ m }
  if ( $1 >= 1000 ) { return $calc($1 / 1000) $+ k }
  if ( $1 < 1000 ) { return $1 }
}

;-- $x.match($chan,user/prov string,user/prov) ; returns complete username/province, returns $null if more than one match ; xbot.aid.mrc
alias x.match {
  ;logged-in nicknames
  if ( $3 == user ) { var %u = $xuser($2,$1) }
  if ( $3 == prov ) { var %u = $hget(x. $+ $xchan($1) $+ .user.prov,$xuser($2,$1)) }
  if ( %u != $null ) { goto done }
  ;search by complete username/province
  var %i = 1
  while ( $hget(x. $+ $xchan($1) $+ .user.prov,%i).item ) {
    if ( $2 == $hget(x. $+ $xchan($1) $+ .user.prov,%i).data || $2 == $hget(x. $+ $xchan($1) $+ .user.prov,%i).item ) {
      if ( $3 == user ) { var %c = $hget(x. $+ $xchan($1) $+ .user.prov,%i).item }
      if ( $3 == prov ) { var %c = $hget(x. $+ $xchan($1) $+ .user.prov,%i).data }
    }
    inc %i
  }
  if ( %c != $null ) { goto done }
  ;search by partial username/province
  var %i = 1
  while ( $hget(x. $+ $xchan($1) $+ .user.prov,%i).item ) {
    if ( $2 isin $hget(x. $+ $xchan($1) $+ .user.prov,%i).data || $2 isin $hget(x. $+ $xchan($1) $+ .user.prov,%i).item ) {
      if ( %p != $null ) { return $null }
      if ( $3 == user ) { var %p = $hget(x. $+ $xchan($1) $+ .user.prov,%i).item }
      if ( $3 == prov ) { var %p = $hget(x. $+ $xchan($1) $+ .user.prov,%i).data }
    }
    inc %i
  }
  :done
  if ( %p != $null ) { return %p }
  if ( %u != $null ) { return %u }
  if ( %c != $null ) { return %c }
  return $null
}



;-- $x.hsave(user.pass) ; saves hash table for all channels on EXIT ; xbot.admin.mrc, xbot.kd.db.mrc
alias x.hsave {
  var %n = 1
  while ( %n <= $finddir($scriptdir $+ info,*,0) ) {
    var %dir = $finddir($scriptdir $+ info,*,%n)
    var %c = $remove(%dir,$scriptdir $+ info\)
    hsave x. $+ %c $+ . $+ $1 " $+ %dir $+ \ $+ $1 $+ .txt $+ " 
    inc %n
  }
  return xBot: Hash table " $+ $1 $+ " saved
}

;-- $x.hmake(user.pass) ; makes and loads hash table for all channels on START ; xbot.admin.mrc, xbot.kd.db.mrc
alias x.hmake {
  var %n = 1
  while ( %n <= $finddir($scriptdir $+ info,*,0) ) {
    var %dir = $finddir($scriptdir $+ info,*,%n)
    var %c = $remove(%dir,$scriptdir $+ info\)
    hmake x. $+ %c $+ . $+ $1
    if ( $exists(%dir $+ \ $+ $1 $+ .txt) == $true ) { hload x. $+ %c $+ . $+ $1 " $+ %dir $+ \ $+ $1 $+ .txt $+ " }
    inc %n
  }
  return xBot: Hash table " $+ $1 $+ " created
}