Advertisement
HeilTec

Query Queue 0.1.1

Jan 15th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.93 KB | None | 0 0
  1. ; HeilTec 2015-01-16
  2. ; simple attempt to manage a query queue though hashtable
  3. ; Debugging echo's left as comments
  4.  
  5. menu status,menubar,channel,query {
  6.   Queries:/showQueue
  7. }
  8. on 1:START:hmake ActiveQueries 5
  9.  
  10. alias showQueue {
  11.   var %idx = $hget(ActiveQueries, 0).item
  12.   echo QueryCount: %idx
  13.   while (%idx > 0) {
  14.     var %thisNick = $hget(ActiveQueries, %idx).item
  15.     var %thisPos = $hget(ActiveQueries, %idx).data
  16.     echo %thisNick $+ : %thisPos
  17.     dec %idx
  18.   }
  19. }
  20.  
  21. on *:close:?:{
  22.   var %query_counter = $hget(ActiveQueries, 0).item
  23.   var %nickPos = $hget(ActiveQueries, $nick)
  24.   ; echo Closed 1 window - ActiveQueries: %query_counter - nick: $nick - nickPos: %nickPos
  25.   if ( %nickPos != 0 ) {
  26.     hdel ActiveQueries $nick
  27.     var %query_counter = $hget(ActiveQueries, 0).item
  28.     ; echo remaining: %query_counter  
  29.     ; nick loop ...
  30.     var %idx  = %query_counter
  31.     while ( %idx > 0 ) {
  32.       var %thisNick = $hget(ActiveQueries, %idx).item
  33.       var %thisPos = $hget(ActiveQueries, %thisNick)
  34.       ; echo Loop: thisNick: %thisNick thisPos: %thisPos
  35.       if ( %thisPos > %nickPos ) {  
  36.         hdec ActiveQueries %thisNick
  37.         ; echo idx: %idx thisNick: %thisNick $hget(ActiveQueries, %thisNick)
  38.         msg %thisNick Now nr. $hget(ActiveQueries, %thisNick) in queue
  39.       }
  40.       dec %idx
  41.     }
  42.   }
  43. }
  44.  
  45. on *:open:?:*:{
  46.   ; echo on OPEN triggered...  target: $target -  nick: $nick
  47.   ; if ( $nick != %myBot ) {
  48.   var %query_counter = $hget(ActiveQueries, 0).item
  49.   inc %query_counter
  50.   ; echo % $+ query_counter: %query_counter
  51.   hadd -m ActiveQueries $nick %query_counter
  52.   var %query_counter = $hget(ActiveQueries, 0).item
  53.  
  54.   ; echo ActiveQueries $nick %query_counter
  55.   msg $nick Welcome to the query queue $nick - Incoming Query Nr. %query_counter $+ . $&
  56.     - Outgoing Querys: $calc($query(0) - %query_counter) - I will reply as soon as possible.
  57.   ; } else {
  58.   ;   msg %myBot botstatus
  59.   ; }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement