Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; HeilTec 2015-01-16
- ; simple attempt to manage a query queue though hashtable
- ; Debugging echo's left as comments
- menu status,menubar,channel,query {
- Queries:/showQueue
- }
- on 1:START:hmake ActiveQueries 5
- alias showQueue {
- var %idx = $hget(ActiveQueries, 0).item
- echo QueryCount: %idx
- while (%idx > 0) {
- var %thisNick = $hget(ActiveQueries, %idx).item
- var %thisPos = $hget(ActiveQueries, %idx).data
- echo %thisNick $+ : %thisPos
- dec %idx
- }
- }
- on *:close:?:{
- var %query_counter = $hget(ActiveQueries, 0).item
- var %nickPos = $hget(ActiveQueries, $nick)
- ; echo Closed 1 window - ActiveQueries: %query_counter - nick: $nick - nickPos: %nickPos
- if ( %nickPos != 0 ) {
- hdel ActiveQueries $nick
- var %query_counter = $hget(ActiveQueries, 0).item
- ; echo remaining: %query_counter
- ; nick loop ...
- var %idx = %query_counter
- while ( %idx > 0 ) {
- var %thisNick = $hget(ActiveQueries, %idx).item
- var %thisPos = $hget(ActiveQueries, %thisNick)
- ; echo Loop: thisNick: %thisNick thisPos: %thisPos
- if ( %thisPos > %nickPos ) {
- hdec ActiveQueries %thisNick
- ; echo idx: %idx thisNick: %thisNick $hget(ActiveQueries, %thisNick)
- msg %thisNick Now nr. $hget(ActiveQueries, %thisNick) in queue
- }
- dec %idx
- }
- }
- }
- on *:open:?:*:{
- ; echo on OPEN triggered... target: $target - nick: $nick
- ; if ( $nick != %myBot ) {
- var %query_counter = $hget(ActiveQueries, 0).item
- inc %query_counter
- ; echo % $+ query_counter: %query_counter
- hadd -m ActiveQueries $nick %query_counter
- var %query_counter = $hget(ActiveQueries, 0).item
- ; echo ActiveQueries $nick %query_counter
- msg $nick Welcome to the query queue $nick - Incoming Query Nr. %query_counter $+ . $&
- - Outgoing Querys: $calc($query(0) - %query_counter) - I will reply as soon as possible.
- ; } else {
- ; msg %myBot botstatus
- ; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement