Advertisement
HeilTec

Query Queue 0.1.2

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