; //-------------- ; FTN //. script ; ; If you know what you're doing, feel free to edit anything below. ; However, please be advised that your changes will be lost the ; next time the script is updated. ; --------------// alias -l ver return 0.5.1 ; ################### ; # channel trigger # ; ################### ; you'd better <3 FTN-BOT! on *:text:*--*:#feedthe.net:{ if ($network === Darknet-IRC.net) && ($nick === FTN-BOT) { ; first we get the category and name if (14-- [ * 14] -* iswm $1-5) { var %cat = $strip($3,b), %name = $gettok($1-,6,2), %c = $chr(1) hadd -mu10 _ftn_tmp next $+($ctime,%c,%cat,%c,%name) } ; and then we get the url elseif (-- [ https://feedthe.net/*] -- iswm $1-) { var %url = $3 if ($hget(_ftn_tmp,next)) { hdel _ftn_tmp next tokenize 1 $v1 var %time = $1, %cat = $2, %name = $3 if (%time) && (%cat) && (%name) && (%url) return $ntfy(%time,%cat,%name,%url) } } } } ; $ntfy(ctime,category,name,url) ; this one calls the other functions alias -l ntfy { var %w = @FTN, %c = @_ftn_cache, %tab = $chr(9) if (!$window(%c)) window -h %c aline %c $1 %tab $+($2,) %tab $3 %tab $4 ; open log window automatically? if ($window(%w)) || ($option_get(log_auto)) { .ftn_log window -g1 %w } if ($option_get($+(cat_,$strip($2)))) { ; show popup notification? if ($option_get(popup_show)) popup $4 $2 $3 ; play sound? if ($option_get(sounds_enable)) { if ($option_get(sounds_beep)) beep elseif ($option_get(sounds_dofile)) && ($isfile($option_get(sounds_file))) splay $option_get(sounds_file) } } } ; ###################### ; # popup notification # ; ###################### ; /popup [url] [category] [release name-] alias -l popup { ; I'm guessing here that the Windows taskbar is 30 pixels high. this ; is bad and will cause overlaps when stacking multiple popups if the ; taskbar is any higher than my estimate, but there is simply no way ; for mIRC to figure out what the actual height is ;_; var %taskbar = 30 var %w = @_ftn_popup, %wi = 200, %hi = 100, %x = $calc($window(-1).w - %wi - 10), %y = $calc($window(-1).h - %hi - %taskbar) ; stacking popups, are we? if ($window(%w)) { var %i = 1 while ($window($+(@_ftn_popup,%i))) inc %i if (%i >= $int($calc(($window(-1).h - %taskbar) / %hi))) return var %w = $+(@_ftn_popup,%i), %y = $calc(%y - (%hi * %i)) } window -hpdBn +Ld %w %x %y %wi %hi titlebar %w $1 ; background drawrect -nrf %w 0 1 0 0 %wi %hi ; top drawtext -nrf %w 15237165 fixedsys 8 5 1 //. drawtext -nrf %w 12829635 arial 10 35 2 NEW UPLOAD drawtext -nrfo %w 16777215 arial 10 $calc(%wi - 12) 2 x drawline -nrf %w 15237165 1 5 17 $calc(%wi - 5) 17 ; category + name var %font = arial, %size = 11 drawtext -nrfpob %w 6974058 0 %font %size 5 25 $chr(91) $2 $+(,]) var %i = 1, %t = $wrap($3-,%font,%size,$calc(%wi - 10),0) while (%i <= %t) { drawtext -nrf %w 16777215 %font %size 5 $calc(30 + (15 * %i)) $wrap($3-,%font,%size,$calc(%wi - 10),%i) inc %i } ; fade in if ($option_get(popup_fade)) { drawdot %w setlayer 0 %w window -o %w var %i = 5, %z = 220 while (%i <= %z) { $+(.timer_ftn_fade.,%w,.,%i) -om 1 $calc(%i * 4) setlayer %i %w inc %i 15 } $+(.timer_ftn_fadeout,.,%w) -o 1 $option_get(popup_delay) fadeout %w } ; ..or not else { drawdot %w window -o %w $+(.timer_ftn_close,.,%w) -o 1 $option_get(popup_delay) window -c %w } } ; /fadeout <@window> ; all this niftyness will only work on win2k+ btw alias -l fadeout { if ($window($1)) { var %i = 220, %z = 15 while (%i >= %z) { $+(.timer_ftn_fade.,$1,.,%i) -om 1 $calc((220 - %i) * 5) setlayer %i $1 dec %i 15 } $+(.timer_ftn_close,.,$1) -om 1 $calc((220 - %i) * 5) window -c $1 } } menu @_ftn_popup* { sclick:{ ; x button: close popup if ($inrect($mouse.x,$mouse.y,$calc($window($active).w - 17),0,20,15)) window -c $active ; anywhere else: follow link elseif ($inrect($mouse.x,$mouse.y,0,20,$window($active).w,$window($active).h)) url -n $window($active).title } } ; ############## ; # log window # ; ############## ; /ftn_log alias ftn_log { var %w = @FTN, %c = @_ftn_cache, %h = _ftn_tmp, %sel = 1, %tab = $chr(9) if (!$window(%w)) { ; try to associate the window with the proper network var %x = 1, %t = $scon(0), %scon while (%x <= %t) { if ($scon(%x).network === Darknet-IRC.net) { %scon = %x break } inc %x } if (!%scon) %scon = $scon($scid($cid)) ; open the window if ($version >= 6.2) scon %scon window $+(-l20k0,$iif($option_get(log_desktop),dh),$iif(!$show,n)) -t5,12,25 %w else scon %scon window $+(-l20k0,$iif($option_get(log_desktop),dh),$iif(!$show,n)) -t10,25 %w if ($option_get(log_desktop)) window -a %w ; set titlebar + font and fill it up! titlebar %w log window font %w 11 tahoma if ($hget(%h)) hdel %h search fill * } ; window's already open else { var %fltr = $hget(%h,filter), %sel = $sline(%w,1).ln .fill -d * hadd -m %h filter %fltr if ($active != %w) && ($show) window -a %w } ; fill category side-list clear -l %w var %total = $line(%c,0) aline -l %w All categories ( $+ %total $+ ) sline -l %w 1 if (%total) { aline -l %w $str(–,99) ; I need to find another way of doing this because this is slow as hell var %x = 1, %t = $gettok($cats,0,32) while (%x <= %t) { var %cat = $gettok($cats,%x,32) ; don't count nr of entries (for slow systems) if ($option_get(log_nocount)) aline -l %w %cat else { filter -wf %c NUL $+(*,%tab,*,%cat,*,%tab,*,%tab https://feedthe.net/*) if ($filtered) aline -l %w %cat ( $+ $v1 $+ ) } inc %x } } aline -l %w $str(–,99) if (!$hget(%h,search)) aline -l %w Search... else aline -l %w Clear search sline -l %w %sel } ; /fill [-d] alias -l fill { ; creating a temporary hidden output window will speed up ; things quite a lot, as watching text get added to a window ; is just terribly, terribly slow in mIRC var %w = @FTN, %c = @_ftn_cache, %o = @_ftn_output, %t = @_ftn_tmp, %h = _ftn_tmp if (!$window(%c)) window -h %c window -h %o clear %o aline %o $sep ; apply previously used filter? if (!$show) && ($1 == -d) && ($2) { window -h %t filter -wwc %c %t $iif($hget(%h,filter),$v1,*) if ($hget(%h,search)) filter -wwc %t %t $+(*,%tab,*,%tab,*,$v1,*,%tab https://feedthe.net/*) %c = %t tokenize 32 $2- } else hadd -m %h filter $1- ; this speeds up things.. a little if ($option_get(log_date) == 1) hadd -m %h date_format dd/mm HH:nn elseif ($option_get(log_date) == 2) hadd -m %h date_format mm/dd HH:nn filter $+(-wkt,$iif($option_get(log_order) == 2,e)) $option_get(log_sort) 9 %c add $1- hdel %h date_format if (!$filtered) { aline %o No results aline %o $sep } ; output everything to main log window filter -wwc %o %w * window -c %o window -c %t } ; returns horizontal line alias -l sep return $+(14,$str(–,200)) ; returns all possible categories, seperated by spaces alias -l cats { return Anime Apps/PC-ISO Apps/PC-RiP DOX Games/DS Games/GBA Games/PC-ISO Games/PC-RiP $& Games/PS2 Games/PSP Games/Wii Games/X-Box Misc Movies/DVDr Movies/HD Movies/PSP Movies/SVCD $& Movies/VCD Movies/XviD Music Mvids TV/HD TV/XviD XXX } ; called by /filter: niftifies log entry alias -l add { var %o = @_ftn_output, %tab = $chr(9) tokenize 9 $1- aline %o $asctime($1,$hget(_ftn_tmp,date_format)) %tab $+(,$2,) %tab $+(,$3,) aline %o %tab %tab $+(,$4,) aline %o $sep } ; menu for log window menu @FTN { dclick:{ var %w = $menu, %c = @_ftn_cache, %h = _ftn_tmp, %tab = $chr(9) if ($1 == 1) fill * elseif ($1 == $line(%w,0,1)) { ; search function (side-list item) if ($line(%w,$1,1) == Search...) { var %q = $$input(Search for...,eq,Search) .fill -d $+(*,%tab,*,%tab,*,%q,*,%tab https://feedthe.net/*) hadd -m %h search %q rline -l %w $1 Clear search return } ; clearing search else { fill * sline -l %w 1 } } ; filtering by category elseif ($line(%w,$1,1) != $str(–,99)) fill $+(*,%tab,*,$gettok($v1,1,32),*,%tab,*,%tab https://feedthe.net/*) if ($line(%w,$1,1) != $str(–,99)) && ($line(%w,$line(%w,0,1),1) == Clear search) { rline -l %w $line(%w,0,1) Search... if ($hget(%h)) hdel %h search } } ; search function (right-click menu item) $iif($hget(_ftn_tmp,search),Clear &search,&Search...):{ var %w = $menu, %h = _ftn_tmp, %tab = $chr(9) ; clearing search if ($hget(_ftn_tmp,search)) { fill * sline -l %w 1 rline -l %w $line(%w,0,1) Search... if ($hget(%h)) hdel %h search } ; new search else { var %q = $$input(Search for...,eq,Search) .fill -d $+(*,%tab,*,%tab,*,%q,*,%tab https://feedthe.net/*) hadd -m %h search %q rline -l %w $line(%w,0,1) Clear search } } &Options...:ftn_options - Sort &by .$iif($option_get(log_sort) == 1,$style(1)) &Date:log_sort 1 $option_get(log_order) .$iif($option_get(log_sort) == 2,$style(1)) &Category:log_sort 2 $option_get(log_order) .$iif($option_get(log_sort) == 3,$style(1)) &Name:log_sort 3 $option_get(log_order) .- .&Order ..$iif($option_get(log_order) == 1,$style(1)) &Ascending:log_sort $option_get(log_sort) 1 ..$iif($option_get(log_order) == 2,$style(1)) &Descending:log_sort $option_get(log_sort) 2 C&lear log:{ if ($input(Are you sure you want to permanently clear the log?,qy,FTN //. Clear Log?)) { var %w = @FTN, %c = @_ftn_cache clear %c ftn_log } } - .&Close log window:window -c $active } ; /log_sort <1|2|3> <1|2> ; ; <1=date|2=cat|3=name> <1=asc|2=desc> alias -l log_sort { var %w = @FTN option_set log_sort $1 option_set log_order $2 if ($window(%w)) .fill -d * } ; ################# ; # self-updating # ; ################# alias ftn_update { var %s = _ftn_update.check if ($sock(%s)) sockclose %s sockopen %s ftn.ohok.nl 80 sockmark %s $show } ; ## update socket events ## on *:sockopen:_ftn_update.*:{ var %s = $sockname, %w = sockwrite -n %s, %g, %show = $sock(%s).mark if ($sockerr) return $iif(%show,$eval($+($,err_update_,$gettok(%s,2,46)),2)) if (*.check iswm %s) %g = $+(/uc.php?ver=,$ver) if (*.changelog iswm %s) %g = /changelog.txt if (*.download iswm %s) %g = /ftn.mrc %w GET %g HTTP/1.0 %w Host: ftn.ohok.nl %w User-Agent: $+(mIRC/,$version) %w Connection: Close %w } on *:sockread:_ftn_update.*:{ var %s = $sockname, %dat, %read = $true, %show = $sock(%s).mark if ($sockerr) return $iif(%show,$eval($+($,err_update_,$gettok(%s,2,46)),2)) ; update check if (*.check iswm %s) { while (%read) { sockread -f %dat tokenize 32 %dat if ($1 == X-FTN-Update:) { sockmark %s %show $true ; we've got the latest version if ($2 == OK) { if (%show) .timer 1 0 return $!input(You are running the latest version of the FTN $+(script.,$str($crlf,2),There) $& are no updates available at this time.,io,FTN //. Update Check) sockclose %s return } ; new version available! else { var %latest = $2, %md5 = $3 .timer 1 0 show_update %latest %md5 sockclose %s return } } if (!$sockbr) %read = $false } } ; downloading changelog or script elseif (*.changelog iswm %s) || (*.download iswm %s) { var %f = $+(",$scriptdir,\_ftn_update_data.tmp") while (%read) { sockread &dat if ($bvar(&dat,0)) bwrite %f -1 -1 &dat if (!$sockbr) %read = $false } } } on *:sockclose:_ftn_update.*:{ var %s = $sockname tokenize 32 $sock(%s).mark ; never got any valid reply! if (*.check iswm %s) && ($1) && (!$2) return $err_update_check ; just finished downloading something? elseif (*.changelog iswm %s) || (*.download iswm %s) { var %f = $+(",$scriptdir,\_ftn_update_data.tmp"), %d = ftn_update bread %f 0 $file(%f).size &file bcopy &file2 1 &file $calc($bfind(&file,1,13 10 13 10) + 4) -1 write -c %f bwrite %f -1 -1 &file2 bunset &file &file2 ; feed changelog to dialog if (*.changelog iswm %s) { if ($dialog(%d)) filter -foc %f %d 2 .remove %f } ; just downloaded script elseif (*.download iswm %s) { tokenize 32 $sock(%s).mark ; md5sums don't match; reject file if ($md5(%f,2) !== $2) { .remove %f return $err_update_download } ; ok let's go: update and reload script else { var %script = $+(",$script,") dialog -x %d filter -ffc %f %script .remove %f .timer -m 1 250 __ftn_update_verif $1 .reload -rs %script } } } } ; ## update error messages ## alias -l err_update_check { .timer 1 0 return $!input(An error occured while attempting to $& check for a new version of the FTN script.,ho,FTN //. Update Check) } alias -l err_update_changelog { if ($dialog(ftn_update)) did -a ftn_update 2 $& $+($str($crlf,2),Failed to retrieve changelog.) } alias -l err_update_download { .timer 1 0 return $!input(An error occured while attempting to $& download the latest version of the FTN script.,ho,FTN //. Update Check) if ($dialog(ftn_update)) dialog -x ftn_update } ; ## update dialog 'n' stuff ## alias -l show_update { var %d = ftn_update, %h = _ftn_tmp if ($dialog(%d)) dialog -x %d hadd -m %h ver_latest $1 hadd %h ver_md5 $2 dialog -m %d %d } dialog -l ftn_update { title "FTN //. Update Check" size -1 -1 210 135 option dbu text "A new version of the FTN script is available.", 1, 5 4 200 8 edit "Changelog:", 2, 5 15 200 90, read multi vsbar text "Update to version x.x.x now? (recommended)", 3, 5 108 200 8 button "&Update", 4, 127 119 37 12, default button "&Cancel", 5, 168 119 37 12, cancel edit "latest", 6, 0 0 0 0, hide autohs edit "md5", 7, 0 0 0 0, hide autohs } on *:dialog:ftn_update:*:*:{ if ($devent == init) { var %h = _ftn_tmp did -ra $dname 6 $hget(%h,ver_latest) did -ra $dname 7 $hget(%h,ver_md5) hdel -w %h ver_* did -a $dname 2 $+($str($crlf,2),Loading..) did -ra $dname 3 $replace($did($dname,3),x.x.x,$did($dname,6)) var %s = _ftn_update.changelog if ($sock(%s)) sockclose %s sockopen %s ftn.ohok.nl 80 } if ($devent == sclick) && ($did == 4) { ; close options dialog if it is open if ($dialog(ftn_options)) dialog -x ftn_options did -ra $dname 2 Now downloading the latest version of the FTN $+(script.,$crlf,Please) wait... did -b $dname 4,5 var %s = _ftn_update.download if ($sock(%s)) sockclose %s sockopen %s ftn.ohok.nl 80 sockmark %s $did($dname,6) $did($dname,7) } } ; ## update verficication ## ; /__ftn_update_verif alias __ftn_update_verif { if ($1 == $ver) return $input(Successfully updated the FTN script to the latest $& $+(version.,$str($crlf,2),You) are now running version $+($ver,.),io,FTN //. Update Complete) else return $input(The update seems to have failed due to reasons $+(unknown.,$str($crlf,2),You) $& may want to ask for $+(support,$chr(44)) or redownload the script.,wo,FTN //. Update Error) } ; ################## ; # options dialog # ; ################## dialog ftn_options { title "FTN //. Options" size -1 -1 175 142 option dbu tab "&Notifications", 1, 5 2 164 120 check "&Enable popup notifications for new uploads", 5, 15 23 130 10, tab 1 check "Use &fade in/out effects", 6, 25 35 80 10, tab 1 text "Show notification for", 7, 26 48 54 8, tab 1 edit "", 8, 80 47 15 10, tab 1 autohs limit 2 text "seconds", 9, 99 48 25 8, tab 1 check "&Play sound when a new upload is announced", 21, 15 62 130 10, tab 1 radio "Use mIRC's /beep command", 22, 25 74 130 10, tab 1 radio "File:", 23, 25 86 25 10, tab 1 edit "", 24, 50 86 70 10, tab 1 read autohs edit "", 29, 50 86 70 10, hide tab 1 read autohs button "&Browse...", 25, 124 85 37 12, tab 1 button "Category settings...", 28, 15 103 60 12, tab 1 tab "&Log window", 2 check "Open log window when a new upload is &announced", 10, 15 23 140 10, tab 2 check "Show log window on &desktop", 11, 15 35 90 10, tab 2 text "Date format:", 12, 15 75 40 8, tab 2 combo 13, 58 74 105 50, tab 2 size drop text "Sort by:", 14, 15 88 40 8, tab 2 combo 15, 58 87 50 50, tab 2 size drop combo 16, 113 87 50 50, tab 2 size drop check "Don't show number of entries per category in sidelist,", 26, 15 47 150 10, tab 2 text "and just show all categories (speeds up processing)", 27, 23 58 140 8, tab 2 tab "&Updates", 17 check "&Automatically check for updates when mIRC starts", 18, 15 23 140 10, tab 17 text "You are running version x.x.x", 19, 15 43 150 8, tab 17 button "&Check for updates", 20, 15 53 60 12, tab 17 button "&Cancel", 3, 132 127 37 12, cancel button "&OK", 4, 92 127 37 12, default ok } on *:dialog:ftn_options:*:*:{ if ($devent == init) { ; popup tab if ($option_get(popup_show)) did -c $dname 5 else did -b $dname 6-9 if ($option_get(popup_fade)) did -c $dname 6 did -ra $dname 8 $option_get(popup_delay) ; sounds stuff if ($option_get(sounds_enable)) did -c $dname 21 else did -b $dname 22-25 if ($option_get(sounds_beep)) { did -c $dname 22 did -b $dname 25 } elseif ($option_get(sounds_dofile)) did -c $dname 23 did -ra $dname 29 $option_get(sounds_file) did -ra $dname 24 $nopath($did($dname,29)) if (!$option_get(popup_show)) && (!$option_get(sounds_enable)) did -b $dname 28 ; log window tab if ($option_get(log_auto)) did -c $dname 10 if ($option_get(log_desktop)) did -c $dname 11 if ($option_get(log_nocount)) did -c $dname 26 didtok $dname 13 44 Day/Month $asctime(HH:nn) , Month/Day $asctime(HH:nn) did -c $dname 13 $option_get(log_date) didtok $dname 15 44 Date,Category,Name did -c $dname 15 $option_get(log_sort) didtok $dname 16 44 Ascending,Descending did -c $dname 16 $option_get(log_order) ; updates tab if ($option_get(update_auto)) did -c $dname 18 did -ra $dname 19 $replace($did($dname,19),x.x.x,$ver) } if ($devent == sclick) { ; enable/disable popup notifications if ($did == 5) { if ($did($dname,5).state) did -e $dname 6-9,28 else { did -b $dname 6-9 if (!$did($dname,21).state) did -b $dname 28 } } ; enable/disable sounds section if ($did == 21) { if ($did($dname,21).state) did -e $dname 22-25,28 else { did -b $dname 22-25 if (!$did($dname,5).state) did -b $dname 28 } } ; enable/disable browse button if ($did == 22) || ($did == 23) { if ($did($dname,23).state) did -e $dname 25 else did -b $dname 25 } ; check for updates if ($did == 20) ftn_update ; browse for sounds if ($did == 25) { if ($sfile($+($nofile($did($dname,29)),*.mp3),Select sound file)) { did -ra $dname 29 $v1 did -ra $dname 24 $nopath($v1) ;splay $+(",$v1,") } } ; category settings if ($did == 28) dialog -m ftn_cats ftn_cats ; ok button if ($did == 4) { var %w = @FTN option_set popup_show $did($dname,5).state option_set popup_fade $did($dname,6).state option_set popup_delay $did($dname,8) option_set sounds_enable $did($dname,21).state option_set sounds_beep $did($dname,22).state option_set sounds_dofile $did($dname,23).state option_set sounds_file $did($dname,29) option_set log_auto $did($dname,10).state ; re-open ftn log window if deemed necessary if ($window(%w)) && (($did($dname,11).state != $option_get(log_desktop)) || $& ($did($dname,26).state != $option_get(log_nocount))) { option_set log_desktop $did($dname,11).state option_set log_nocount $did($dname,26).state window -c %w ftn_log } else { option_set log_desktop $did($dname,11).state option_set log_nocount $did($dname,26).state } option_set log_date $did($dname,13).sel log_sort $did($dname,15).sel $did($dname,16).sel option_set update_auto $did($dname,18).state } } } ; category settings dialog dialog -l ftn_cats { title "FTN //. Category Settings" size -1 -1 137 150 option dbu text "", 1, 6 3 125 21 list 2, 6 40 125 90, size extsel check button "&Cancel", 3, 93 135 37 12, cancel button "&Ok", 4, 53 135 37 12, ok text "", 5, 6 24 125 15 } on *:dialog:ftn_cats:*:*:{ if ($devent == init) { ; adding these lines by /did because I HATE having a horizontal scrollbar in my script editor did -ra $dname 1 For each category below, you can choose whether or not to show popup $& notifications and/or play sounds for new uploads in that category. did -ra $dname 5 Please note: the uploads will still be listed in the log window, and $& these settings obey the main ones. var %x = 1, %t = $gettok($cats,0,32) while (%x <= %t) { var %cat = $gettok($cats,%x,32) did -a $dname 2 %cat if ($option_get($+(cat_,%cat))) did -s $dname 2 %x inc %x } } ; OK button if ($devent == sclick) && ($did == 4) { var %x = 1, %t = $did($dname,2).lines while (%x <= %t) { option_set $+(cat_,$did($dname,2,%x)) $did($dname,2,%x).cstate inc %x } } } ; ## options handling (including default options) ## alias ftn_options { var %d = ftn_options if ($dialog(%d)) dialog -x %d dialog -m %d %d } alias -l option_get { var %i = $hget(ftn_options,$1) if (* iswm %i) return %i ; option defaults else { if ($1 == popup_show) return 1 if ($1 == popup_fade) return 1 if ($1 == popup_delay) return 5 if ($1 == sounds_beep) return 1 if ($1 == log_auto) return 1 if ($1 == log_date) return 1 if ($1 == log_sort) return 1 if ($1 == log_order) return 1 if ($1 == update_auto) return 1 if (cat_* iswm $1) return 1 } } alias -l option_set { var %h = ftn_options if (!$hget(%h)) hmake %h 5 hadd %h $1 $2 } ; ## options loading/loading on start/exit ## on *:exit:{ var %h = ftn_options, %f = $+(",$scriptdir,\,ftn_config.db") if ($hget(%h)) hsave -i %h %f options } on *:start:{ var %h = ftn_options, %f = $+(",$scriptdir,\,ftn_config.db") if ($ini(%f,options)) { hmake %h 5 hload -i %h %f options } ; ## check for updates on start? ## if ($option_get(update_auto)) .ftn_update } ; ################### ; # some lame menus # ; ################### menu channel,menubar { - $iif($active == #feedthe.net,&FTN //. script) .&Log window:ftn_log .&Options...:ftn_options } ; love and kisses, ; - thame^