All pastes #988125 Raw Edit

Something

public text v1 · immutable
#988125 ·published 2008-04-17 08:31 UTC
rendered paste body
on *:LOAD: {
  load -rs scripts\TLK-Script\Array.ini
  load -rs scripts\TLK-Script\Noticing.ini
  load -rs scripts\TLK-Script\Mirroring.ini
  set %mtlkrep mTLKRep
  set %kncrep KnCRep
  set %newschan1 #TLK-News
  set %newschan2 #mTLK-News
  createArray mirrorChannel
  createArray noticeChannel
  createArray autoNoticeChannel
}


on *:START: {
  hmake countryNames 150
  hmake notices 50
  hload -i countryNames scripts\TLK-Script\countrynames.ini
  hload notices scripts\TLK-Script\notices.txt
}


on *:EXIT: {
  hfree countryNames
  hfree notices
}


on *:UNLOAD: {
  hfree countryNames
  hfree notices
  set %counter 1
  while ( %counter <= %mirrorChannelIndex ) {
    delArray %mirrorChannel [ $+ [ %counter ] ]
    %counter = %counter + 1
  }
  set %counter 1
  while ( %counter <= %autoNoticeChannelIndex ) {
    delArray %autoNoticeChannel [ $+ [ %counter ] ]
    %counter = %counter + 1
  }
  unset %counter
  unset %counter1
  unset %counter2
  unset %output
  unset %channel
  unset %channelCheck
  unset %mtlkrep
  unset %kncrep
  unset %newschan1
  unset %newschan2
  unset %index
  unset %index2
  unset %searchFound
  unset %combinedText
  unset %count
  unset %searchIndex
  unset %arrayName
  unset %countryMatchText
  delArray mirrorChannel
  delArray noticeChannel
  delArray autoNoticeChannel
  unload -rs scripts\TLK-Script\Array.ini
  unload -rs scripts\TLK-Script\Mirroring.ini
  unload -rs scripts\TLK-Script\Noticing.ini
}


menu Channel {
  Noticing
  .Noticing on:/noticingOn
  .Noticing off:/noticingOff
  .Autorejoin notice on
  ..KnC:/autoNoticingOn $?="What country are you in?" KnC
  ..mTLK:/autoNoticingOn $?="What country are you in?" mTLK
  .Autorejoin notice off:/autoNoticingOff
  Mirroring
  .Mirror on
  ..KnC:/mirrorOn KnC
  ..mTLK:/mirrorOn mTLK
  .Mirror off:/mirrorOff
  .Add Country
  ..Full mirroring:/addMirrorCountry $?="Battles from what country do you want to be mirrored?" full
  ..Single line mirroring:/addMirrorCountry $?="Battles from what country do you want to be mirrored?" single
  .Del Country:/delMirrorCountry $?="What country do you want to be taken of the mirror list?"
  .Mirroring warstarts
  ..All countries:/mirrorWars full
  ..Countries on mirrorlist:/mirrorWars limited
  ..None:/mirrorWars off
}


; syntax: /textCombiner <space separated text>
; combines space separated tokens into one variable
;
alias textCombiner {
  set %counter 1
  set %combinedText
  while ( %counter <= $0 ) {
    %combinedText = %combinedText $+ $ [ $+ [ %counter ] ]
    inc %counter
  }
}


; syntax: /count <text>
; counts the number of words and puts the number in a variable
;
alias count {
  set %count $0
}


; syntax: /addCountry <Country Name> <Server>
; adds a country to the hashtable 
;
alias addCountry {
  set %countryMatchText $?="Please provide the naming used by the newsbot"
  textCombiner $ [ $+ [ $0 ] ] $1- [ $+ [ $calc($0 - 1) ] ]
  if ( $hget(countryNames,%combinedText) != $null ) {
    echo - Country $1- [ $+ [ $calc($0 - 1) ] ] already exists - 
  }
  else {
    hadd countryNames %combinedtext %countryMatchText
    hsave -i countryNames scripts\TLK-Script\countrynames.ini
    echo - Country $1- [ $+ [ $calc($0 - 1) ] ] added -
  }
}


; syntax: /changeCountry <Country Name> <Server>
; changes a country on the hashtable
;
alias changeCountry {
  set %countryMatchText $?="Please provide the naming used by the newsbot"
  textCombiner $ [ $+ [ $0 ] ] $1- [ $+ [ $calc($0 - 1) ] ]
  if ( $hget(countryNames,%combinedText) == $null ) {
    echo - Country $1- [ $+ [ $calc($0 - 1) ] ] doesn't exists - 
  }
  else {
    hdel countryNames %combinedText
    hadd countryNames %combinedText %countryMatchText
    hsave -i countryNames scripts\TLK-Script\countrynames.ini
    echo - Country $1- [ $+ [ $calc($0 - 1) ] ] changed -
  }
}


; syntax: /delCountry <Country Name> <Server>
; deletes a country from the hashable
;
alias delCountry {
  textCombiner $ [ $+ [ $0 ] ] $1- [ $+ [ $calc($0 - 1) ] ]
  if ( $hget(countryNames,%combinedText) == $null ) {
    echo - Country $1- [ $+ [ $calc($0 - 1) ] ] couldn't be found -
  }
  else {
    hdel countryNames %combinedText
    hsave -i countryNames scripts\TLK-Script\countrynames.ini
    echo - Country $1- [ $+ [ $calc($0 - 1) ] ] deleted -
  }
}