menu channel {
$iif($dialog(rand),$style(7)) Msg/Describe: { dialog -dm rand rand }
}
On *:Text:*match text*:#: {
rand $r(a,b)
}
on 1:Start: {
hmake message 1000
hmake describe 1000
if ($isfile(msg.hsh)) {
hload -o message msg.hsh
}
if ($isfile(desc.hsh)) {
hload -o describe desc.hsh
}
}
dialog rand {
title "Random Msg / Describe"
size -1 -1 154 163
option dbu
combo 1, 4 14 70 98, size
combo 2, 77 14 70 98, size
text " /msg /describe", 3, 3 3 149 8
button "Add", 4, 16 113 22 12
button "Del", 5, 39 113 22 12
button "Del", 6, 113 113 22 12
button "Add", 7, 90 113 22 12
button "Close", 8, 61 142 37 12
}
alias getmsg {
if (($hget(message) && $hget(message,0).item) > 0) {
var %msg = $hget(message,0).item
while (%msg) {
if ($dialog(rand)) {
did -a rand 1 $hget(message,%msg).data
dec %msg
}
}
}
elseif (($hget(message) && !$hget(message,0).item)) { return }
}
alias getdesc {
if (($hget(describe) && $hget(describe,0).item) > 0) {
var %desc = $hget(describe,0).item
while (%desc) {
if ($dialog(rand)) {
did -a rand 2 $hget(describe,%desc).data
dec %desc
}
}
}
elseif (($hget(describe) && !$hget(describe,0).item)) { return }
}
on 1:dialog:rand:init:0: {
did -b rand 5
did -b rand 6
getmsg
getdesc
}
on 1:dialog:rand:close:0: {
hsave -o message msg.hsh
hsave -o describe desc.hsh
}
on 1:dialog:rand:sclick:1: {
if ($did(rand,1).sel) {
did -e rand 5
}
}
on 1:dialog:rand:sclick:2: {
if ($did(rand,2).sel) {
did -e rand 7
}
}
on 1:dialog:rand:sclick:4: {
if ($hget(message)) {
if ($did($dname,1).text) {
did -a rand 1 $did($dname,1).text
hadd message $didwm(rand, 1,$did(rand,1).text) $did($dname,1).text
}
}
}
on 1:dialog:rand:sclick:5: {
if ($did($dname,1).sel) {
if ($hget(message)) {
hdel message $didwm(rand, 1,$did(rand,1).seltext)
did -d rand 1 $didwm(rand, 1,$did(rand,1).seltext)
did -b rand 5
}
}
}
on 1:dialog:rand:sclick:6: {
if ($did($dname,2).sel) {
if ($hget(describe)) {
hdel describe $didwm(rand, 2,$did(rand,2).seltext)
did -d rand 2 $didwm(rand, 2,$did(rand,2).seltext)
did -b rand 6
}
}
}
on 1:dialog:rand:sclick:7: {
if ($hget(describe)) {
if ($did($dname,2).text) {
did -a rand 2 $did($dname,2).text
hadd describe $didwm(rand, 2,$did(rand,2).text) $did($dname,2).text
}
}
}
on 1:dialog:rand:close:0: {
hsave -o describe desc.hsh
hsave -o message msg.hsh
}
alias rand {
if ($1 == a) { msg $target $hget(message,$r($hget(message,0).item,1)) }
if ($1 == b) { describe $target $hget(describe,$r($hget(describe,0).item,1)) }
}