Advertisement
westor

Multi-Network & Channels AUTOTALK for xi0noNifaDa v1.0

Oct 6th, 2020
2,445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 4.98 KB | None | 0 0
  1. ON *:START: { load_db }
  2. ON *:JOIN:#: {
  3.   if ($nick !== $me) { return }
  4.  
  5.   var %h = $hget(AUTOTALK_ $+ $network,$chan)
  6.  
  7.   if (%h) { .timer[AUTOTALK_ $+ $network $+ _ $+ $chan $+ _NOW] 0 %h autotalk $network $chan }
  8. }
  9.  
  10. ON *:PART:#: {
  11.   if ($nick !== $me) { return }
  12.  
  13.   var %h = $hget(AUTOTALK_ $+ $network,$chan)
  14.  
  15.   if (%h) { .timer[AUTOTALK_ $+ $network $+ _ $+ $chan $+ _NOW] off }
  16. }
  17.  
  18. ON *:KICK:#: {
  19.   if ($knick !== $me) { return }
  20.  
  21.   var %h = $hget(AUTOTALK_ $+ $network,$chan)
  22.  
  23.   if (%h) { .timer[AUTOTALK_ $+ $network $+ _ $+ $chan $+ _NOW] off }
  24. }
  25.  
  26. ON *:TEXT:*:?: {
  27.   if ($1 == !autotalk) {
  28.     var %o = add del list
  29.  
  30.     if (!$2) { msg $nick ( $+ $nick $+ ): Error, Enter one of these values $qt(%o) to proceed! | return }
  31.     if (!$istok(%o,$2,32)) { msg $nick ( $+ $nick $+ ): Error, Enter one valid option from $qt(%o) options! | return }
  32.  
  33.     if ($2 == add) {
  34.       var %f = autotalk.db
  35.  
  36.       if (!$3) { msg $nick ( $+ $nick $+ ): Error, Enter a network name! | return }
  37.       if (!$4) { msg $nick ( $+ $nick $+ ): Error, Enter a channel name! | return }
  38.       if ($left($4,1) !== $chr(35)) { msg $nick ( $+ $nick $+ ): Error, Enter a valid channel name! | return }
  39.  
  40.       var %h = $hget(AUTOTALK_ $+ $3,$4)
  41.       if (%h) { msg $nick ( $+ $nick $+ ): Error, $4 channel is already exists on $3 network! | return }
  42.  
  43.       if ($5) && ($5 isnum) { var %n = $5 }
  44.       else { var %n = $rands(900,1200) }
  45.  
  46.       hadd -m AUTOTALK_ $+ $3 $4 %n
  47.  
  48.       save_db
  49.  
  50.       .timer[AUTOTALK_ $+ $3 $+ _ $+ $4 $+ _NOW] 0 %n autotalk $3 $4
  51.  
  52.       msg $nick ( $+ $nick $+ ): Added the $4 channel on $3 network list with %n random autotalk seconds.
  53.     }
  54.  
  55.     if ($2 == del) {
  56.       var %f = autotalk.db
  57.  
  58.       if (!$3) { msg $nick ( $+ $nick $+ ): Error, Enter a network name! | return }      
  59.       if (!$4) { msg $nick ( $+ $nick $+ ): Error, Enter a channel name! | return }
  60.       if ($left($4,1) !== $chr(35)) { msg $nick ( $+ $nick $+ ): Error, Enter a valid channel name! | return }
  61.  
  62.       var %h = $hget(AUTOTALK_ $+ $3,$4)
  63.       if (!%h) { msg $nick ( $+ $nick $+ ): Error, $4 channel does NOT exists on $3 network! | return }
  64.  
  65.       hdel AUTOTALK_ $+ $3 $4
  66.  
  67.       if (!$hget(AUTOTALK_ $+ $3,0).item) { hfree AUTOTALK_ $+ $3 }
  68.  
  69.       save_db
  70.  
  71.       .timer[AUTOTALK_ $+ $3 $+ _ $+ $4 $+ _NOW] off
  72.  
  73.       msg $nick ( $+ $nick $+ ): Removed the $4 channel from $3 network list with %h random autotalk seconds.
  74.     }
  75.  
  76.     if ($2 == list) {
  77.       var %t = $hget(0)
  78.  
  79.       var %i = 1
  80.       while (%i <= %t) {
  81.         var %h = $hget(%i)
  82.         var %m = $hget(%h,0).item
  83.  
  84.         if (!%h) || (!%m) || (AUTOTALK_* !iswm %h) { goto list_next }
  85.  
  86.         var %z = 1
  87.         while (%z <= %m) {
  88.           var %c = $hget(%h,%z).item
  89.           var %d = $hget(%h,%z).data
  90.  
  91.           if (%c) && (%d) { msg $nick ( $+ $nick $+ ): $gettok(%h,2-,95) - %c - %d }
  92.  
  93.           inc %z
  94.         }
  95.  
  96.         :list_next
  97.         inc %i
  98.       }
  99.  
  100.       msg $nick ( $+ $nick $+ ): End of autotalk list.
  101.     }
  102.   }
  103. }
  104.  
  105.  
  106. alias load_db {
  107.   ; /load_db
  108.  
  109.   var %f = autotalk.db
  110.   var %t = $ini(%f,0)
  111.  
  112.   if (!%t) { return }
  113.  
  114.   var %i = 1
  115.   while (%i <= %t) {
  116.     var %n = $ini(%f,%i)
  117.     var %m = $ini(%f,%n,0)
  118.  
  119.     if (!%n) || (!%m) { goto next }
  120.  
  121.     var %z = 1
  122.     while (%z <= %m) {
  123.       var %c = $ini(%f,%n,%z)
  124.       var %v = $readini(%f,n,%n,%c)
  125.  
  126.       if (%c) && (%v) { hadd -m %n %c %v }
  127.  
  128.       inc %z
  129.     }
  130.  
  131.     :next
  132.     inc %i
  133.   }
  134.  
  135. }
  136.  
  137. alias save_db {
  138.   ; /save_db
  139.  
  140.   var %f = autotalk.db
  141.  
  142.   if ($isfile(%f)) { .remove $qt(%f) }
  143.  
  144.   var %t = $hget(0)
  145.  
  146.   var %i = 1
  147.   while (%i <= %t) {
  148.     var %h = $hget(%i)
  149.     var %m = $hget(%h,0).item
  150.  
  151.     if (!%h) || (!%m) || (AUTOTALK_* !iswm %h) { goto next }
  152.  
  153.     var %z = 1
  154.     while (%z <= %m) {
  155.       var %c = $hget(%h,%z).item
  156.       var %d = $hget(%h,%z).data
  157.  
  158.       if (%c) && (%d) { writeini -n $qt(%f) %h Channel_ $+ %c %d }
  159.  
  160.       inc %z
  161.     }
  162.  
  163.     :next
  164.     inc %i
  165.   }
  166.  
  167. }
  168.  
  169. alias autotalk {
  170.   ; /autotalk Network #Channel
  171.  
  172.   if (!$1) || (!$2) { return }
  173.  
  174.   var %f = msgrandom.txt
  175.   var %r = $read(%f,n)
  176.  
  177.   if (!$file(%f)) { return }
  178.   if (!$check_network_channel($1,$2)) { return }
  179.   if (!%r) { return }
  180.  
  181.   var %cid = $get_network_cid($1)
  182.  
  183.   if (!%cid) { return }
  184.  
  185.   scid %cid
  186.  
  187.   msg $2 %r
  188. }
  189.  
  190. alias -l check_network_channel {
  191.   ; $check_network_channel(Network,#Channel)
  192.  
  193.   if (!$1) && (!$2) { return }
  194.  
  195.   var %t = $scon(0)
  196.  
  197.   var %i = 1
  198.   while (%i <= %t) {
  199.     var %n = $scon(%i).network
  200.     var %u = $scon(%i).status
  201.     var %d = $scon(%i).cid
  202.  
  203.     if ($1 == %n) && (%u == connected) && (%d) {
  204.       scid %d
  205.       if ($me ison $2) { return 1 }
  206.     }
  207.  
  208.     inc %i
  209.   }
  210.  
  211.   return 0
  212. }
  213.  
  214. alias -l get_network_cid {
  215.   ; $get_network_cid(Network)
  216.  
  217.   if (!$1) { return }
  218.  
  219.   var %t = $scon(0)
  220.  
  221.   var %i = 1
  222.   while (%i <= %t) {
  223.     var %n = $scon(%i).network
  224.     var %d = $scon(%i).cid
  225.  
  226.     if ($1 == %n) && (%d) { return %d }
  227.  
  228.     inc %i
  229.   }
  230.  
  231.   return 0
  232. }
  233.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement