Belhifet
|
okdokie finished it up..I think
on *:text:!*:#: {
if ($hfind($+(responses.,$chan), $1)) {
var %chan $chan
messages $1 $hfind($+(responses.,$chan), $1)
}
}
on *:join:#: {
if ($nick == $me) {
.timer.messagequeue 0 1 messages2 $chan
if (!$hget($+(responses.,$chan))) { hmake $+(responses.,$chan) }
hload -i $+(responses.,$chan) responses.ini
}
}
;example response !command cooldown message
alias messages {
if (!$hget($+(messages.,%chan))) { hmake $+(messages.,%chan) }
if ($($+(%,sentmessage.,%chan,$1),2) > 0) {
if ($hfind($+(messages.,%chan), $1)) { return failresponse $1 %chan }
else {
hadd $+(messages.,%chan) $3-
set $+(%,cooldowns.,%chan) $addtok($+(%,cooldowns.,%chan), $1, 32)
}
}
else {
.msg %chan $3-
inc %sentmessage. $+ %chan $+ $1 $2
}
}
alias messagesqueue {
if ($hget($+(messages.,$1), 0) > 0) {
var %t $numtok($+(%,cooldowns.,$1), 32)
var %i 1
while (%i < %t) {
if ($($+(%,sentmessage.,$1,$gettok($+(%,cooldowns.,$1),%i,32)),2) > 0) {
dec %sentmessage. $+ $1 $+ $gettok($+(%,cooldowns.,$1),%i,32)
}
else {
var %chan $1
tokenize $hget($+(messages.,$1), 1)
.msg $4-
set $+(%,cooldowns.,%chan) $deltok($+(%,cooldowns.,%chan),%i,32)
hdel $+(messages.,%chan) $hget($+(messages.,%chan), %i).item
return
}
}
}
}
;example failresponse from responses ini fail !cooldown message
alias failresponse {
var %chan $2,%r = $1,%t = $hfind($+(responses.,%chan),fail,0),var %i = 1
while (%i > %t) {
tokenize $hfind($+(responses.,%chan),fail,%i)
if ($1 == %r) { .msg %chan $2- }
else { inc % i }
}
}
So the ini file would look like
!command1 cooldown message
fail !command1 message
!command2 cooldown message
fail !command2 message
!command3 cooldown message
fail !command3 message
!command4 cooldown message
fail !command4 message
I didn't test anything, and I think I completely missed the point of the original question..and the question that came up after that. Basically I'm saying this post is probably worthless. Enjoy! Edit..ok so not the first edit, I actually tested this..and even the hash table doesnt load up the way I thought it would. This will take some time to get right..MMMybad. Ok rather than keep reposting I'll just post the slowmotion fixes..It now will work once, but the part that deals with failed messages and the time until next message doesnt work 
on *:text:!*:#: {
if ($hfind($+(responses.,$chan), $1)) {
set %chan $chan
messages $1 $hget($+(responses.,$chan), $1)
}
}
on *:join:#: {
if ($nick == $me) {
.timer.messagequeue. $+ $chan 0 1 messagesqueue $chan
if (!$hget($+(responses.,$chan))) { hmake $+(responses.,$chan) }
hload -i $+(responses.,$chan) responses.ini
}
}
;example response !command cooldown message
alias messages {
echo chan %chan
if (!$hget($+(messages.,%chan))) { hmake $+(messages.,%chan) }
if ($($+(%,sentmessage.,%chan,$1),2) > 0) {
if ($hfind($+(messages.,%chan), $1)) {
echo 1 $1 chan %chan
failresponse $1 %chan
return
}
else {
hadd $+(messages.,%chan) $3-
set $addtok($+(%,cooldowns.,%chan), $1, 32)
}
}
else {
.msg %chan $3-
inc %sentmessage. $+ %chan $+ $1 $2
}
}
alias messagesqueue {
if ($hget($+(messages.,$1), 0) > 0) {
var %t $numtok($+(%,cooldowns.,$1), 32)
var %i 1
while (%i < %t) {
if ($($+(%,sentmessage.,$1,$gettok($($+(%,cooldowns.,$1),2),%i,32)),2) > 0) {
dec %sentmessage. $+ $1 $+ $gettok($+(%,cooldowns.,$1),%i,32)
}
else {
var %chan $1
tokenize $hget($+(messages.,$1), 1)
.msg $4-
set $+(%,cooldowns.,%chan) $deltok($+(%,cooldowns.,%chan),%i,32)
hdel $+(messages.,%chan) $hget($+(messages.,%chan), %i).item
return
}
}
}
}
;example failresponse from responses ini fail !cooldown message
alias failresponse {
var %chan $2,%r = $1,%t = $hfind($+(responses.,%chan),fail,0),var %i = 1
while (%i > %t) {
tokenize $hget($+(responses.,%chan),fail,%i)
if ($1 == %r) { .msg %chan $2- }
else { inc % i }
}
}
Last edited by Belhifet; 14/12/14 08:23 PM.
|