All pastes #189182 Raw Edit

Unnamed

public text v1 · immutable
·published 2006-10-02 21:49 UTC
rendered paste body
; Useless facts - by Jagfire
; (@#helpdesk @#scripting DALnet\Undernet)
; /facts to start
; Total Fact Count: 561

dialog facts {
  title "Random Facts"
  size -1 -1 242 218
  option pixels
  edit "", 1, 8 12 222 120, read multi autohs autovs center
  check "Enable !getfact", 2, 8 144 100 20
  box "", 3, 2 -2 236 140
  button "&Refresh", 4, 6 194 54 22
  button "E&xit", 5, 180 194 54 22, cancel
  button "&Clipboard", 6, 64 194 54 22
  button "&Announce", 7, 122 194 54 22
  check "Log outgoing notices", 8, 8 166 124 20
  box "", 9, 2 130 236 60
  text "Total:", 10, 157 168 75 16, disable
}
dialog announce {
  title "Announce Fact"
  size -1 -1 188 154
  option pixels
  list 1, 8 14 112 126, sort size hsbar vsbar
  box "Channels", 2, 2 0 125 148
  button "&Announce", 3, 129 32 56 24
  button "E&xit", 4, 129 59 56 24, cancel
  button "/a&msg", 5, 129 5 56 24
}
on *:dialog:facts:sclick:8:{
  if ($did($dname,8).state == 1) { 
    set %fax.log on 
  }
  else {
    set %fax.log off
  }
}
on *:dialog:announce:sclick:3:{
  var %i = $did($dname,1).seltext
  if ($me !ison %i) {
    var %' = $input(Either you're currently not on %i $+ $chr(44) or there's no channel selected.,wo,Error...)
    halt
  }
  else {
    msg %i $$read($scriptdirfacts.txt,%fax.current)
  }
}
on *:dialog:announce:sclick:5:{
  amsg $$read($scriptdirfacts.txt,%fax.current)
}

;; Wildcard match alias below
alias fw {
  if (!$1) || ($chr(42) !isin $1) { echo -a -- Invalid syntax. Use a wildcard match: /fw *wildcard* }
  else {
    if (!$read(facts.txt,w,$1)) { echo -a -- Sorry, no wildcards matched in the facts file. }
    elseif ($read(facts.txt,w,$1)) { msg $active $read(facts.txt,w,$1) }
  }
}
on *:dialog:facts:sclick:6:clipboard $read($scriptdirfacts.txt,%fax.current)
on *:dialog:facts:sclick:7:{ 
  dialog -m announce announce
}
on *:dialog:announce:init:0:{
  var %i = 1
  while (%i <= $chan(0)) {
    .did -a announce 1 $chan(%i)
    inc %i
  }
}
on *:dialog:facts:init:0:{
  var %` = $read($scriptdirfacts.txt)
  set %fax.current $readn
  did -ra facts 1 $read($scriptdirfacts.txt,%fax.current)
  dialog -t facts Fact $+($eval(#,0),$readn)
  did -ra facts 10 Total: $lines($scriptdirfacts.txt)
  if (%fax.trigger == on) {
    did -c facts 2
  }
  if (%fax.log == on) {
    did -c facts 8
  }
}

; "Authorization"

on *:load:{ 
  if (!$exists($scriptdirfacts.txt)) { 
    echo -a Facts file not found. Unloading... 
    .unload -rs $+(",$script,")
  }
  else { 
    echo -a Loaded successfully. To run, type 4/facts, or access from channel popups.
  }
}

; Popups

menu channel,menu,status {
  F&acts
  .Run:/facts
  .Unload:if ($input(Unload addon?,yo,You sure?) != $false) { echo -a Unloading... | echo -a Unsetting variables... | echo -a Done. | .unset %fax.* | .unload -rs $+(",$script,") }
}
alias facts { dialog -m facts facts }

; Dialog events

on *:dialog:facts:sclick:4:{
  var %` = $read($scriptdirfacts.txt)
  set %fax.current $readn
  did -ra facts 1 $read($scriptdirfacts.txt,%fax.current)
  dialog -t facts Fact $+($eval(#,0),$readn)
}
on *:dialog:facts:sclick:2:{
  if ($did($dname,2).state == 1) { 
    set %fax.trigger on 
    .enable #fax
    .did -e facts 8
  }
  else {
    set %fax.trigger off 
    .disable #fax 
    .did -u facts 8
    .did -b facts 8

  }
}
#fax on
on *:text:!getfact:#:{
  set -u6 %fax. [ $+ [ $chan ] $+ . $+ [ $nick ] ] $calc( %fax. [ $+ [ $chan ] $+ . $+ [ $nick ] ] + 1)
  if (%fax. [ $+ [ $chan ] $+ . $+ [ $nick ] ] >= 4) { 
    halt
  }
  elseif (%fax.trigger == on) { 
    var %` = $read($scriptdirfacts.txt)
    .notice $nick 14[rfact14] %`
    if (%fax.log == on) {
      window @factlog
      echo -t @factlog 14>Sent to $nick $+ : %`
    } 
  }
}
#fax end