SHARE
TWEET

Untitled

a guest Mar 9th, 2013 28 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;RSS Original news-tracker (old)code by snabbi
  2. ;RSS New Version 4.0 final by wazer #cspromod @ quakenet
  3. ;Thanks alot to mlky & bindi @ quakenet for helping me out.
  4.  
  5.  
  6.  
  7. ;-----------------------events--------------------------------
  8. ;mod_wazer
  9. ;alias removecdata return $gettok($gettok($1-,1,93),3,91)
  10. ;alias removecdata return $regsubex($1,/<\!\[CDATA\[(.*)\]\]>/iU,\1)
  11. alias shrinklinks {
  12.   if ($regex($1,/^[\.]?(echo|msg|notice)/Si)) && ($3) {
  13.     if ($wildtok($strip($3-),http://*.*,0,32) == $wildtok($strip($3-),*http://tinyurl.com*,0,32)) {
  14.       $1-
  15.       return
  16.     }
  17.     var %count $wildtok($strip($3-),http://*.*,0,32), %text $strip($3-)
  18.     while %count {
  19.       if ($left($wildtok(%text,http://*.*,%count,32),18) != http://tinyurl.com) {
  20.         tiny $1-2 $wildtok(%text,http://*.*,%count,32) $3-
  21.         %count = 0
  22.         return
  23.       }
  24.       dec %count
  25.     }
  26.   }
  27.   else { echo -st ShrinkLinks error -- must start with msg #chan - msg nickname - notice nickname or echo -a }
  28. }
  29. alias -l Tiny {
  30.   var %sockname $+(Tiny,$network,$ticks,$r(1,$ticks))
  31.   sockopen %sockname tinyurl.com 80
  32.   sockmark %sockname $1-2 $+(/create.php?url=,$3) $3 $4-
  33. }
  34. On *:sockopen:Tiny*: {
  35.   if (!$sockerr) {
  36.     sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
  37.     sockwrite -n $sockname Host: tinyurl.com
  38.     sockwrite -n $sockname $crlf
  39.   }
  40.   else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  41. }
  42. On *:sockread:Tiny*: {
  43.   if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  44.   else {
  45.     var %Tiny | sockread %Tiny
  46.     if ($regex(%Tiny,/<blockquote><b>(.*)<\/b><br><small>/i)) {
  47.       tokenize 32 $sock($sockname).mark
  48.       shrinklinks $1-2 $replace($5-,$4,$regml(1))
  49.       sockclose $sockname
  50.       return
  51.     }
  52.   }
  53. }
  54. alias removecdata return $regsubex($remove($1,$chr(124)),/<\!\[CDATA\[(.*)\]\]>/iU,\1)
  55.  
  56. ;on startup the feeds have to be initialized
  57. on *:start: { newsfirststart | news_reset_messages_to_default }
  58.  
  59. ;display info on load
  60. on *:load: {
  61.   if ( $isfile(newstracker-setting.hsh) ) {
  62.     if ( $hget(newstracker-setting) ) { .hfree newstracker-setting }
  63.     .hmake newstracker-setting 100 | .hload newstracker-setting newstracker-setting.hsh
  64.     news_reset_messages_to_default
  65.     news_help load
  66.   }
  67.   else {
  68.     news_resettodefault
  69.     news_help
  70.     dialog -m newstracker newstracker
  71.   }
  72.   newsfirststart
  73. }
  74. on *:unload: {
  75.   if ( $hget(newstracker-setting,lang) != NL ) {
  76.     if ( $exists(newstracker-setting.hsh) ) { echo -s The file newstracker-setting.hsh can be removed manually if you don't want to keep your settings! }
  77.     echo -s Newstracker is unloaded successfully.
  78.   }
  79.   if ( $hget(newstracker-setting,lang) != EN ) {
  80.     if ( $exists(newstracker-setting.hsh) ) { echo -s Het bestand newstracker-setting.hsh kan met de hand verwijderd worden wanneer je je instellingen niet wilt bewaren }
  81.     echo -s Newstracker is uit je scripts verwijdert.
  82.   }
  83.   if ( $hget(newstracker) ) { .hfree newstracker }
  84.   if ( $hget(newstracker-setting) ) { .hfree newstracker-setting }
  85.   if ( $window(@newstracker) ) { .window -c @newstracker }
  86.   .timernews* off
  87.   unset %trackernews*
  88.   unset %tell.room
  89.   unset %newssaid
  90. }
  91. ;-----------------------menus--------------------------------
  92. menu @newstracker {
  93.   .$iif($hget(newstracker-setting,window),$newstracker-return-text(menu5),):hadd newstracker-setting window 0 | newstracker-save-settings | window -nh @newstracker
  94.   .$iif(!$hget(newstracker-setting,window),$newstracker-return-text(menu6),):hadd newstracker-setting window 1 | newstracker-save-settings | window -w3n @newstracker
  95.   .$newstracker-return-text(menu11):clear
  96. }
  97.  
  98. menu menubar,channel {
  99.   $newstrackerversion
  100.   .$iif($hget(newstracker-setting,0).item == 0,Reset to default/Reset naar beginwaarden):news_resettodefault
  101.   .$iif(!$hget(newstracker-setting,off),$newstracker-return-text(menu9)): hadd -m newstracker-setting off 1
  102.   .$iif($hget(newstracker-setting,off),$newstracker-return-text(menu10)): hadd -m newstracker-setting off 0
  103.   .$iif($chan($active) && !$newschannels(isinall,$chan($active)),$newstracker-return-text(menu3)):newstracker-chans add $chan($active)
  104.   .$iif($chan($active) && !$newschannels(isnotinany,$chan($active)),$newstracker-return-text(menu4)):newstracker-chans remove $chan($active)
  105.   .$newstracker-return-text(menu13): news_help
  106.   .-
  107.   .$newstracker-return-text(menu1):dialog -m newstracker newstracker
  108.   .-  
  109.   .$iif($hget(newstracker-setting,window),$newstracker-return-text(menu5),):hadd newstracker-setting window 0 | newstracker-save-settings | window -nh @newstracker
  110.   .$iif(!$hget(newstracker-setting,window),$newstracker-return-text(menu6),):hadd newstracker-setting window 1 | newstracker-save-settings | window -w3n @newstracker
  111.   .$newstracker-return-text(menu12):hfree newstracker | news_reset_messages_to_default
  112.   .$newstracker-return-text(menu2):dialog -m newstracker_lang newstracker_lang
  113.   .$newstracker-return-text(menu7):var %i = $input($newstracker-return-text(menu8),y) | if ( %i ) { news_resettodefault }
  114. }
  115.  
  116. ;-----------------------dialogs-------------------------------
  117.  
  118. dialog newstracker_lang {
  119.   title "NewsTracker © snabbi"
  120.   size -1 -1 110 50
  121.   option dbu
  122.   text "Which language do you prefer? / Welke taal heeft uw voorkeur?",10,10 10 90 14
  123.   button "English",11,10 30 45 15
  124.   button "Nederlands",12,60 30 45 15
  125. }
  126. on *:dialog:newstracker_lang:sclick:11: { hadd -m newstracker-setting lang EN | dialog -c newstracker_lang }
  127. on *:dialog:newstracker_lang:sclick:12: { hadd -m newstracker-setting lang NL | dialog -c newstracker_lang }
  128.  
  129. dialog newstracker {
  130.   size -1 -1 320 153
  131.   option dbu
  132.  
  133.   tab $newstracker-return-text(dialog150), 150, 5 1 310 125
  134.   text $newstracker-return-text(dialog2),2,10 20 80 7, tab150
  135.   radio $newstracker-return-text(dialog3),3,135 20 20 10,group, tab150
  136.   radio $newstracker-return-text(dialog4),4,155 20 20 10, tab150
  137.   text $newstracker-return-text(dialog5),5,10 35 120 7, tab150
  138.   edit "",6,135 34 40 10,autohs, tab150
  139.   text $newstracker-return-text(dialog7),7,178 35 40 10, tab150
  140.   text $newstracker-return-text(dialog8),8,10 48 120 7, tab150
  141.   edit "",9,135 47 40 10,autohs, tab150
  142.   text $newstracker-return-text(dialog10),10,179 48 40 7, tab150
  143.   text $newstracker-return-text(dialog11),11,10 61 80 7, tab150
  144.   radio $newstracker-return-text(dialog12),12,135 61 70 10,group, tab150
  145.   radio $newstracker-return-text(dialog13),13,135 71 80 10, tab150
  146.  
  147.   tab $newstracker-return-text(dialog151), 151, 5 1 310 125
  148.   text $newstracker-return-text(dialog51),51,10 22 70 7, tab151
  149.   list 52,9 31 72 94,hsbar vsbar sort, tab151
  150.   text $newstracker-return-text(dialog64),64,100 31 50 7, tab151
  151.   radio $newstracker-return-text(dialog65),65,160 31 20 10,group, tab151
  152.   radio $newstracker-return-text(dialog66),66,185 31 20 10, tab151
  153.   text $newstracker-return-text(dialog53),53,100 43 50 7, tab151
  154.   edit "",54,160 42 110 10,autohs, tab151
  155.   text $newstracker-return-text(dialog55),55,100 55 50 7, tab151
  156.   button $newstracker-return-text(dialog88),88,273 55 37 8, tab151
  157.   edit "",56,160 54 110 10,autohs, tab151
  158.   text $newstracker-return-text(dialog57),57,100 67 55 7, tab151
  159.   edit "",58,160 66 110 10,autohs, tab151
  160.   text $newstracker-return-text(dialog59),59,275 67 30 7, tab151
  161.   text $newstracker-return-text(dialog60),60,100 79 50 7, tab151
  162.   edit "",61,160 78 110 10,autohs, tab151
  163.   button $newstracker-return-text(dialog89),89,273 78 37 8, tab151
  164.   text $newstracker-return-text(dialog62),62,100 91 50 7, tab151
  165.   edit "",63,160 90 110 10,autohs, tab151
  166.   button $newstracker-return-text(dialog87),87,273 91 37 8, tab151
  167.   button $newstracker-return-text(dialog80),80,100 105 50 15, tab151
  168.   button $newstracker-return-text(dialog81),81,160 105 50 15, tab151
  169.   button $newstracker-return-text(dialog82),82,220 105 50 15, tab151
  170.  
  171.   button $newstracker-return-text(dialog100),100,120 131 40 15,ok
  172. }
  173.  
  174. on *:dialog:newstracker:init:*: {
  175.   var %i = $hfind(newstracker-setting,tracker*,0,w)
  176.   while ( %i ) {
  177.     var %settings = $hget(newstracker-setting,$hfind(newstracker-setting,tracker*,%i,w))
  178.     did -a $dname 52 $gettok(%settings,1,32) | dec %i
  179.   } | did -b $dname 80,82
  180.  
  181.   did -a $dname 9 $iif($hget(newstracker-setting,interval),$ifmatch,30)
  182.   did -a $dname 6 $iif($hget(newstracker-setting,max),$ifmatch,5)
  183.   did -c $dname $iif($hget(newstracker-setting,off),4,3)
  184.   did -c $dname $iif($hget(newstracker-setting,msg) == all,13,12)
  185. }
  186. on *:dialog:newstracker:sclick:*: { goto $did
  187.   :3 | hadd newstracker-setting off 0 | halt
  188.   :4 | hadd newstracker-setting off 1 | halt
  189.   :12 | hadd newstracker-setting msg chans | halt
  190.   :13 | hadd newstracker-setting msg all | halt
  191.   :52 | if ( $did($dname,52).seltext != $null ) {
  192.     var %options = $hget(newstracker-setting,trackersetting. [ $+ [ $v1 ] ])
  193.     did -ra $dname 54 $v1 | did -ra $dname 56 $gettok(%options,2,32)
  194.     did -ra $dname 58 $gettok(%options,3,32)
  195.     did -ri $dname 61 1 $hget(newstracker-setting,newsbanner. [ $+ [ $v1 ] ])
  196.     did -ri $dname 63 1 $gettok(%options,5-,32)
  197.     did -u $dname 65,66 | did -c $dname $iif($gettok(%options,4,32),65,66)
  198.     did -e $dname 80,82
  199.   } | halt
  200.   :80 | remove-newstracker
  201.   did -d $dname 52 $did($dname,52,1).sel | did -r $dname 54,56,58,61,63
  202.   did -b $dname 82,80
  203.   halt
  204.   :82 | :81 | var %name = $replace($did($dname,54),$chr(32),_)
  205.   if ( (!$did($dname,52).sel && $did != 81) || %name == $null || $did($dname,58) == $null || $did($dname,56) == $null ) {
  206.     var %i = $input($newstracker-return-text(error1),o,Error) | halt
  207.   }
  208.   if ( ( $did == 81 && $hget(newstracker-setting,trackersetting. [ $+ [ %name ] ]) ) || $&
  209.     ( $did == 82 && $did($dname,52).seltext != %name ) && $hget(newstracker-setting,trackersetting. [ $+ [ %name ] ]) ) {
  210.     var %i = $input($newstracker-return-text(error2),o,Error) | halt
  211.   }
  212.   if ( $did($dname,58) !isnum || $did($dname,58) < 120 ) { var %i = $input($newstracker-return-text(error3),o) | halt }
  213.   if ( $did == 82 ) { remove-newstracker } | did -b $dname 82,80
  214.   hadd newstracker-setting newsbanner. [ $+ [ %name ] ] $iif($did($dname,61),$v1,&title - 12&link)
  215.   var %reg = /((?:,|\s)+)/g | var %rooms = $regsubex($did($dname,63),%reg,$chr(44)) | var %i = 1
  216.   while ( %i <= $numtok(%rooms,44) ) {
  217.     var %room = $addtok(%room,$iif($+($chr(35),*) iswm $gettok(%rooms,%i,44),$v2,$+($chr(35),$v2)),44)
  218.     inc %i
  219.   }
  220.   hadd newstracker-setting trackersetting. [ $+ [ %name ] ] %name $did($dname,56) $did($dname,58) $iif($did(65).state,1,0) %room
  221.   if ( $did == 81 ) { checknews %name echo }
  222.   if ( $did == 82 ) { did -d $dname 52 $did($dname,52,1).sel }
  223.   did -a $dname 52 %name | did -r $dname 54,56,58,61,63 | did -u $dname 65,66,52 | halt
  224.   :89 | if ( $did(61) ) { echo -a ---------- | echo -a $did(61) | echo -a ---------- } | halt
  225.   :88 | newstracker_check_url $did(56) | halt
  226.   :65 | :66 | if ( !$did($dname,52).sel ) { halt } | did -e $dname 82 | halt
  227.   :87 | if ( $chan($active) == $window($active) ) {
  228.     did -ra $dname 63 $addtok($did($dname,63),$chan($active),44)
  229.     if ( $did == 6 || $did == 9 || !$did($dname,52).sel ) { return }
  230.     did -e $dname 82
  231.   }
  232.   halt
  233.   :100 | hadd newstracker-setting interval $iif($did(9),$ifmatch,15)
  234.   hadd newstracker-setting max $iif($did(6),$ifmatch,2)
  235.   newstracker-save-settings
  236.   dialog -x $dname | newstracker-save-settings | news_start
  237.   :0 | :150 | :151
  238. }
  239.  
  240. on *:dialog:newstracker:edit:*: {
  241.   if ( $did == 6 || $did == 9 || !$did($dname,52).sel ) { halt }
  242.   did -e $dname 82
  243. }
  244.  
  245. ;-----------------------aliases-------------------------------
  246. alias newstrackerversion { return Newstracker 4.0 by wazer }
  247. alias news_help {
  248.   .timer 1 1 echo -s -----------------------
  249.   .timer 1 1 echo -s $newstracker-return-text(welkom1)
  250.   .timer 1 4 echo -s $newstracker-return-text(welkom2)
  251.   .timer 1 7 echo -s $newstracker-return-text(welkom3)
  252.   .timer 1 10 echo -s $newstracker-return-text(welkom4)
  253.   .timer 1 13 echo -s $newstracker-return-text(welkom5)
  254.   .timer 1 16 echo -s $newstracker-return-text(welkom6)
  255.   if ( $1 == load ) { .timer 1 19 echo -s $newstracker-return-text(welkom7) }
  256.   .timer 1 22 echo -a -----------------------
  257. }
  258. alias newstracker-save-settings { .hsave -o newstracker-setting newstracker-setting.hsh }
  259.  
  260. ;returns the text in the language what was choosen $1 = number for event
  261. alias newstracker-return-text { return $hget(newstracker,$+($hget(newstracker-setting,lang),-,$1)) }
  262.  
  263. ;$1 = isinall of isnotinany $2 = channame
  264. alias newschannels {
  265.   var %i = $hfind(newstracker-setting,tracker*,0,w)
  266.   while ( %i ) {
  267.     var %name = $hfind(newstracker-setting,tracker*,%i,w)
  268.     var %settings = $hget(newstracker-setting,%name)
  269.     if ( $istok($gettok(%settings,5,32),$2,44) ) {
  270.       if ( $1 == isnotinany ) { return $false }
  271.     }
  272.     else {
  273.       if ( $1 == isinall ) { return $false }
  274.     }
  275.     dec %i
  276.   }
  277.   return $true
  278. }
  279. alias news_reset_messages_to_default {
  280.   if ( !$hget(newstracker) ) { .hmake newstracker 100 }
  281.   hadd newstracker NL-welkom1 U heeft zojuist news-tracker geinstalleerd op uw mIRC versie © snabbi
  282.   hadd newstracker NL-welkom2 Wanneer u met de rechter muistoets in de kamer klikt ziet u een menu verschijnen "newstracker 3.5". In dit menu @#$! u via de instellingen het script aanpassen.
  283.   hadd newstracker NL-welkom3 Op het eerste tabblad ziet u de algemene instellingen. Deze instellingen hebben betrekking op alle feeds. Zo @#$! u bijvoorbeeld het maximum aantal berichten ingeven dat er per feed gezegd mag worden. Hiermee voorkomt u dat u de kamer overspoelt met nieuwsberichten. Ook @#$! u instellen dat er een bepaalde tijd is tussen het downloaden van 2 sites.
  284.   hadd newstracker NL-welkom4 De laatste instelling van de algemene instellingen gaat over het versturen van berichten. Het heeft de voorkeur om de berichten in 1 keer naar alle kamers te sturen, echter niet elke server ondersteunt deze optie en daarom @#$! u ook elk kanaal apart informeren.
  285.   hadd newstracker NL-welkom5 Het tweede tabblad heet "Feed instellingen". Hier @#$! u per site de instellingen voor de feed wijzigen. U @#$! hierbij denken aan hoe de tekst in de kamer getoond moet worden, hoe vaak het getoond moet worden, in welke kamers enzovoorts. Gebruik de knop "check URL" om uw opgegeven URL te controleren en om te zien welke commando's u @#$! gebruiken in het veld "Tekst banner"
  286.   hadd newstracker NL-welkom6 Speel maar gerust met het script. Heeft u nog vragen dan @#$! u mij mailen op newstracker@snirc.nl. Vergeet overigens niet om kamers toe te voegen aan uw feeds, want anders ziet u ze niet!
  287.   hadd newstracker NL-welkom7 Overigens zijn de instellingen van de vorige keer bewaard gebleven. Wilt u deze wissen klik dan met uw rechter muistoets in de kamer en kies voor Newstracker en vervolgens voor Reset naar beginwaarden
  288.   hadd newstracker EN-welkom1 You just installed news-tracker on your mIRC client © snabbi
  289.   hadd newstracker EN-welkom2 The menu "newstracker 4.0 by wazer" appears after right clicking a channel. This menu enables you to edit the script's settings. The config dialog can be opened by clicking settings. This dialog consists of two tabs. The first tab contains the general settings. These settings apply to all feeds.
  290.   hadd newstracker EN-welkom3 You can for example change the max number of messages that are displayed for each feed to prevent flooding and set a timer to pause downloading from a second newssite.
  291.   hadd newstracker EN-welkom4 You can change the way the message are sent to the server at the bottom of the dialog. The default setting is to send 1 message to all channels, however, this feature is not supported by all servers and therefor you are also able to send the messages to each chan individually.
  292.   hadd newstracker EN-welkom5 The second tab is called "Feed settings". This tab allows you to change the settings for each RSS feed like layout and frequency. The button "check URL" enables you to test your URL and shows which tags are available at that feed. Add the tags to the Text banner line to display the contents of a tag in your channel.
  293.   hadd newstracker EN-welkom6 If you have any suggestions or questions you can mail me at newstracker@snirc.nl  Please don't forget to add channels to your feed, or else you will not see any news.
  294.   hadd newstracker EN-welkom7 BTW the previous settings have been loaded. You can reset to default settings by right clicking in a chan and selecting Newstracker -> Reset to default
  295.   hadd newstracker NL-dialog2 Tracker gebruiken? | hadd newstracker EN-dialog2 Use newstracker?
  296.   hadd newstracker NL-dialog3 Ja | hadd newstracker EN-dialog3 Yes
  297.   hadd newstracker NL-dialog4 Nee | hadd newstracker EN-dialog4 No
  298.   hadd newstracker NL-dialog5 Max aantal teksten per feed (flood bescherming)
  299.   hadd newstracker EN-dialog5 Max number of msgs for each feed (flood prot)
  300.   hadd newstracker NL-dialog7 (0=oneindig) | hadd newstracker EN-dialog7 (0=indefinitely)
  301.   hadd newstracker NL-dialog8 Minimum tijd tussen 2 downloads
  302.   hadd newstracker EN-dialog8 Minimum time between downloading 2 feeds
  303.   hadd newstracker NL-dialog10 seconden | hadd newstracker EN-dialog10 seconds
  304.   hadd newstracker EN-dialog11 How to send channel messages: | hadd newstracker EN-dialog12 each chan individually
  305.   hadd newstracker EN-dialog13 single message to all chans | hadd newstracker NL-dialog11 Berichten versturen:
  306.   hadd newstracker NL-dialog12 elk kanaal apart | hadd newstracker NL-dialog13 als 1 bericht naar alle kanalen
  307.   hadd newstracker NL-dialog51 Feed namen | hadd newstracker EN-dialog51 Feed names
  308.   hadd newstracker NL-dialog53 Naam tracker | hadd newstracker EN-dialog53 Name tracker
  309.   hadd newstracker NL-dialog55 URL RSS feed | hadd newstracker EN-dialog55 URL RSS feed
  310.   hadd newstracker NL-dialog57 Download feed elke | hadd newstracker EN-dialog57 Download feed each
  311.   hadd newstracker NL-dialog59 seconden | hadd newstracker EN-dialog59 seconds
  312.   hadd newstracker NL-dialog60 Tekst banner | hadd newstracker EN-dialog60 Text banner
  313.   hadd newstracker NL-dialog62 Zeg op kamers | hadd newstracker EN-dialog62 Say on rooms
  314.   hadd newstracker NL-dialog64 Gebruik feed | hadd newstracker EN-dialog64 Use feed
  315.   hadd newstracker NL-dialog65 Ja | hadd newstracker EN-dialog65 Yes
  316.   hadd newstracker NL-dialog66 Nee | hadd newstracker EN-dialog66 No
  317.   hadd newstracker NL-dialog80 &Verwijder Feed | hadd newstracker EN-dialog80 &Remove Feed
  318.   hadd newstracker NL-dialog81 &Nieuwe Feed | hadd newstracker EN-dialog81 &New Feed
  319.   hadd newstracker NL-dialog82 Op&slaan | hadd newstracker EN-dialog82 &Save changes
  320.   hadd newstracker NL-dialog87 huidige kamer | hadd newstracker EN-dialog87 active room
  321.   hadd newstracker NL-dialog88 check URL | hadd newstracker EN-dialog88 check URL
  322.   hadd newstracker NL-dialog89 voorbeeld | hadd newstracker EN-dialog89 example
  323.   hadd newstracker NL-dialog100 &Oke | hadd newstracker EN-dialog100 &OK
  324.   hadd newstracker NL-dialog150 Algemene instellingen | hadd newstracker EN-dialog150 General settings
  325.   hadd newstracker NL-dialog151 Instellingen per feed | hadd newstracker EN-dialog151 Feed settings
  326.   hadd newstracker NL-error1 Sommige vereiste velden zijn leeg (kamers en banners zijn niet vereist). Een nieuwe feed voeg je toe via Nieuwe feed en anders gebruik je Opslaan
  327.   hadd newstracker EN-error1 Some required are empty (channels and banners are not required). Add a new feed with the New Feed button else use Save
  328.   hadd newstracker NL-error2 Naam is niet uniek | hadd newstracker EN-error2 Name already in use
  329.   hadd newstracker NL-error3 De tijd voor elke download moet minimaal 2 minuten zijn (=120 seconden)
  330.   hadd newstracker EN-error3 The time between downloading a feed has to be at least 2 minutes (=120 seconds)
  331.   hadd newstracker NL-error4 Download mislukt van | hadd newstracker EN-error4 Could not download news from
  332.   hadd newstracker NL-error5 Fout tijdens het download van het nieuws. Site reageerde te traag:
  333.   hadd newstracker EN-error5 Error while downloading news. Site was responding to slowly:
  334.   hadd newstracker NL-error6 Fout tijdens het downloaden van de nieuwstracker. Zie de fout in het scherm @newstracker of neem contact op met snabbi op newstracker@snirc.nl
  335.   hadd newstracker EN-error6 Error in newstracker. Please consult your @newstracker window or contact snabbi at newstracker@snirc.nl
  336.   hadd newstracker NL-error7 Fout tijdens het parsen van | hadd newstracker EN-error7 Error while parsing
  337.   hadd newstracker NL-error8 foutcode is: | hadd newstracker EN-error8 message is:
  338.  
  339.   hadd newstracker NL-error9 Geef een URL in het daarvoor bedoelde veld op.
  340.   hadd newstracker EN-error9 Please specify a URL.
  341.   hadd newstracker NL-error10 Het script is nog bezig met het verwerken van uw vorige verzoek.
  342.   hadd newstracker EN-error10 The script is still processing your previous request.
  343.   hadd newstracker NL-error11 De URL is in het verkeerde formaat.
  344.   hadd newstracker EN-error11 Invalid format of URL:
  345.   hadd newstracker NL-error12 verwacht:
  346.   hadd newstracker EN-error12 expect:
  347.   hadd newstracker NL-error13 Fout bij het downloaden van de site
  348.   hadd newstracker EN-error13 Error while downloading from site
  349.  
  350.   hadd newstracker NL-menu1 Instellingen
  351.   hadd newstracker NL-menu2 Verander taal/Change language
  352.   hadd newstracker NL-menu3 Voeg kamer toe aan alle trackers
  353.   hadd newstracker NL-menu4 Verwijder kamer van alle trackers
  354.   hadd newstracker NL-menu5 Verberg scherm @newstracker
  355.   hadd newstracker NL-menu6 Toon scherm @newstracker
  356.   hadd newstracker NL-menu7 Reset naar beginwaarden
  357.   hadd newstracker NL-menu8 Weet u zeker dat u de huidige instellingen wilt wissen
  358.   hadd newstracker NL-menu9 Schakel script uit
  359.   hadd newstracker NL-menu10 Schakel script in
  360.   hadd newstracker NL-menu11 Leeg maken
  361.   hadd newstracker NL-menu12 Wis berichtgeschiedenis
  362.   hadd newstracker NL-menu13 Help
  363.  
  364.   hadd newstracker EN-menu1 Settings
  365.   hadd newstracker EN-menu2 Change language/Verander taal
  366.   hadd newstracker EN-menu3 Add chan to all trackers
  367.   hadd newstracker EN-menu4 Remove chan from all trackers
  368.   hadd newstracker EN-menu5 Hide @newstracker
  369.   hadd newstracker EN-menu6 Unhide @newstracker
  370.   hadd newstracker EN-menu7 Reset to default
  371.   hadd newstracker EN-menu8 Are you sure you want to reset to defaults
  372.   hadd newstracker EN-menu9 Turn off script
  373.   hadd newstracker EN-menu10 Turn on script
  374.   hadd newstracker EN-menu11 Clear
  375.   hadd newstracker EN-menu12 Clear news memory
  376.   hadd newstracker EN-menu13 Help
  377.  
  378.   hadd newstracker EN-test0 Please wait 5 seconds to allow the script to download the requested file
  379.   hadd newstracker EN-test1 The script was able to download a file from your URL:
  380.   hadd newstracker EN-test2 The downloaded file has been parsed. The newsfeed contains some tags. The contents of those tags can be displayed in the channel by entering their names like &tagname. The tags that have been found at your URL are shown below with an example of one of the downloaded messages.
  381.   hadd newstracker EN-test3 The tag 12
  382.   hadd newstracker EN-test4 should be entered as 12
  383.   hadd newstracker EN-test5 to display the following message 12
  384.   hadd newstracker NL-test0 Wacht 5 seconden aub om het script in staat te stellen het gevraagde bestand te downloaden
  385.   hadd newstracker NL-test1 Het script was in staat om een bestand te downloaden vanaf de opgegeven URL: 12
  386.   hadd newstracker NL-test2 Het gedownloadde bestand is verwerkt. Het bevatte een aantal tags. De inhoud tussen deze tags kan je in de kamer(s) weergeven. Dit doe je door het in te geven als een &tag. De tags die gevonden zijn in het bestand worden hier onder weergegeven met een voorbeeld van een van de berichten.
  387.   hadd newstracker NL-test3 De tag 12
  388.   hadd newstracker NL-test4 moet ingevoerd worden als 12
  389.   hadd newstracker NL-test5 om het volgende weer te geven 12
  390. }
  391. alias news_resettodefault {
  392.   if ( $isfile(newstracker-setting.hsh) ) { .remove newstracker-setting.hsh }
  393.   if ( $hget(newstracker-setting) ) { hfree newstracker-setting }
  394.   if ( $hget(newstracker) ) { hfree newstracker }
  395.   hadd -m newstracker-setting lang NL
  396.   hadd newstracker-setting interval 15
  397.   hadd newstracker-setting max 2 | hadd newstracker-setting window $true | hadd newstracker-setting off 0 | hadd newstracker-setting msg chans
  398.   news_reset_messages_to_default
  399.   var %i = $dialog(newstracker_lang,newstracker_lang)
  400.   newstracker_reset_to_default_2
  401.   newstracker-save-settings
  402. }
  403. alias newstracker_reset_to_default_2 {
  404.   if ( $hget(newstracker-setting,lang) == NL ) {
  405.     var %trackers = AD,Fok,NOS-Nieuws,NOS-Sport,NuAlg,NuEco,NuInternet | var %names = AD,Fok!,NOS,NOS,Nu.nl,Nu.nl,Nu.nl
  406.     var %info = http://www.ad.nl/?service=rss,http://rss.fok.nl/feeds/nieuws,http://feeds.nos.nl/nosnieuws,http://feeds.nos.nl/nossport, $&
  407.       http://www.nu.nl/deeplink_rss2/index.jsp?r=Algemeen,http://www.nu.nl/deeplink_rss2/index.jsp?r=Economie,http://www.nu.nl/deeplink_rss2/index.jsp?r=Internet
  408.   }
  409.   else if ( $v1 == EN ) {
  410.     var %trackers = CSPROMOD,STEAM,HLTV,CSGO | var %names = CSPROMOD,STEAM,HLTV,CSGO
  411.     var %info = http://cspromod.com/community/external.php?type=RSS2,http://store.steampowered.com/feeds/news.xml,http://www.hltv.org/news.rss.php,http://blog.counter-strike.net/index.php/feed/
  412.   }
  413.   var %i = $numtok(%trackers,44)
  414.   while ( %i ) {
  415.     hadd newstracker-setting newsbanner. [ $+ [ $gettok(%trackers,%i,44) ] ] $+(4,$gettok(%names,%i,44), &title - 12&link 4,$gettok(%names,%i,44))
  416.     hadd newstracker-setting trackersetting. [ $+ [ $gettok(%trackers,%i,44) ] ] $gettok(%trackers,%i,44) $gettok(%info,%i,44) 121 1
  417.     dec %i
  418.   }
  419.   newstracker-save-settings | newsfirststart
  420. }
  421. alias newsfirststart {
  422.   if ( !$hget(newstracker-setting) ) { .hmake newstracker-setting 100 | .hload newstracker-setting newstracker-setting.hsh }
  423.   var %i = $hfind(newstracker-setting,tracker*,0,w)
  424.   while ( %i ) {
  425.     var %feed = $hfind(newstracker-setting,tracker*,%i,w) | checknews $gettok($hget(newstracker-setting,%feed),1,32) echo
  426.     dec %i
  427.   }
  428.   news_start
  429. }
  430. alias news_start {
  431.   var %i = $hfind(newstracker-setting,tracker*,0,w)
  432.   while ( %i ) {
  433.     var %options = $hget(newstracker-setting,$hfind(newstracker-setting,tracker*,%i,w))
  434.     var %feed = $gettok(%options,1,32)
  435.     if ( $gettok(%options,4,32) && !$timer(news $+ %feed) ) {
  436.       .timernews [ $+ [ %feed ] ] -io 1 $gettok(%options,3,32) checknews %feed say
  437.     }
  438.     dec %i
  439.   }
  440. }
  441.  
  442. alias remove-newstracker {
  443.   if ( !$dialog(newstracker) ) { return }
  444.   var %name = $did(newstracker,52).seltext
  445.   hdel $+(newstracker-setting newsbanner.,%name) | hdel $+(newstracker-setting trackersetting.,%name)
  446.   if ( $timer(news $+ %name) ) { .timernews. [ $+ [ %name ] ] off }
  447. }
  448.  
  449. ;$1 = naam feed, $2 say of echo
  450. alias checknews {
  451.   var %settings = $hget(newstracker-setting,trackersetting. [ $+ [ $1 ] ])
  452.   if ( $hget(newstracker-setting,off) == 1 || !$2 || !%settings ) { return }
  453.   if ( $gettok(%settings,4,32) != 1 ) { return }
  454.   if ( $2 == echo ) { goto over }
  455.   if ( %newssaid ) { .timernews [ $+ [ $1 ] ] -io 1 $v1 checknews $1 say | .timernewssaid 1 $calc($v1 - 1) unset % $+ newssaid | halt }
  456.   .timernews [ $+ [ $1 ] ] -io 1 $gettok(%settings,3,32) checknews $1 say
  457.   set -z %newssaid $hget(newstracker-setting,interval)
  458.  
  459.   :over
  460.   var %i = 1 | while ( $sock(news $+ %i).name ) { inc %i }
  461.   var %site = $gettok(%settings,2,32)
  462.   set -u60 %trackernews [ $+ [ %i ] ] $+($1,$chr(44),%site,$chr(44),$2)
  463.   var %j = $regex(%site,/^(?:http:\/\/)?([^\/]+)(.*)$/)
  464.   if ( $regml(0) != 2 ) { echo @newstracker $newstracker-return-text(error4) %site | halt }
  465.   .sockopen news $+ %i $regml(1) 80
  466. }
  467.  
  468. alias newstracker-chans {
  469.   var %i = $hfind(newstracker-setting,tracker*,0,w)
  470.   while ( %i ) {
  471.     var %options = $hget(newstracker-setting,$hfind(newstracker-setting,tracker*,%i,w))
  472.     var %feed = $gettok(%options,1,32)
  473.     if ( $1 == add ) { hadd newstracker-setting trackersetting. [ $+ [ %feed ] ] $gettok(%options,1-4,32) $addtok($gettok(%options,5-,32),$2,44) }
  474.     if ( $1 == remove ) { hadd newstracker-setting trackersetting. [ $+ [ %feed ] ] $gettok(%options,1-4,32) $remtok($gettok(%options,5-,32),$2,1,44) }
  475.     dec %i
  476.   }
  477.   newstracker-save-settings
  478. }
  479. alias newstracker_check_url {
  480.   echo -a -----------
  481.   echo -a $newstracker-return-text(test0)
  482.   var %newstracker_testurl = $did(newstracker,56)
  483.   if ( !%newstracker_testurl ) { echo -a $newstracker-return-text(error9) | return }
  484.   if ( $sock(newstrackertest) ) { echo -a $newstracker-return-text(error10) | return }
  485.   var %site = $regex(%newstracker_testurl,/^(?:http:\/\/)?([^\/]+)(.*)$/)
  486.   if ( $regml(0) != 2 ) { echo -a $newstracker-return-text(error11) $+(4[,$regml(1),4] [,$regml(2),4]) $newstracker-return-text(error12) 4[www.test.com4] [/test4] | halt }
  487.   .timernewstrackertest off
  488.   .sockopen newstrackertest $regml(1) 80
  489. }
  490. alias newstracker_endtest {
  491.   if ( $sock($1) ) { .sockclose $1 }
  492.   if ( $fopen($1) ) { var %i = $fopen($1).pos | .fseek -l $1 1 | var %i = $fread($1,%i,&fullline) | .fclose $1 }
  493.   .remove $+($1,.tmp)
  494.   var %i = $news.tag.locate(fullline,$gettok($news.tag.locate(fullline,1).item,2,32)).item
  495.   var %j = $gettok(%i,1,32) | var %k = $gettok(%i,2,32)
  496.   while ( %j < %k ) {
  497.     var %j = $bfind(&fullline,%j,</) | inc %j 2 | var %l = $bfind(&fullline,%j,>)
  498.     if ( %j <= %k && $calc(%l - %j) < 20 ) { var %tags = $addtok(%tags,$bvar(&fullline,%j,$calc(%l - %j)).text,44) }
  499.   }
  500.   echo -a $newstracker-return-text(test1) 12 $+ $did(newstracker,56)
  501.   echo -a $newstracker-return-text(test2)
  502.   var %j = $numtok(%tags,44)
  503.   while ( %j ) {
  504.     var %text = $news.parse.line(fullline,$gettok(%i,1,32),$gettok(%i,2,32),$gettok(%tags,%j,44))
  505.     ;length stripped to 150    
  506.     if ( $bvar(&currentline,0) > 153 ) {
  507.       bcopy &newstrackertemp 1 &currentline 1 150
  508.       bunset &currentline
  509.       bcopy &currentline 1 &newstrackertemp 1 -1
  510.       bset -t &currentline 150 ...
  511.     }
  512.     echo -a $newstracker-return-text(test3) $+ $gettok(%tags,%j,44) $&
  513.       $newstracker-return-text(test4) $+ & $+ $gettok(%tags,%j,44) $&
  514.       $newstracker-return-text(test5) $+ $bvar(&currentline,1-).text
  515.     dec %j
  516.   }
  517.   echo -a -----------
  518. }
  519. ;-----------------------sockets-------------------------------
  520. on *:sockopen:newstrackertest: {
  521.   if ($sockerr) { return }
  522.   .timernewstrackertest 1 7 newstracker_endtest $sockname
  523.   .fopen -on $sockname $sockname $+ .tmp
  524.   var %site = $regex($did(newstracker,56),/^(?:http:\/\/)?([^\/]+)(.*)$/)
  525.   if ( $regml(0) != 2 ) { echo @newstracker $newstracker-return-text(error4) $gettok(%tracker [ $+ [ $sockname ] ],2,44) | halt }
  526.   sockwrite -n $sockname GET $regml(2) HTTP/1.1
  527.   sockwrite -n $sockname Host: $regml(1)
  528.   sockwrite -n $sockname Connection: Close $+ $crlf $+ $crlf
  529.   sockwrite -n $sockname
  530. }
  531. on *:sockopen:news*: {
  532.   if ($sockerr ) { return }
  533.   if ( $sockname == newstrackertest) { return }
  534.   if ( $fopen($sockname) ) { .fclose $sockname }
  535.   .fopen -on $sockname $sockname $+ .txt
  536.   .timer [ $+ [ $sockname ] ] 1 5 news.parse $sockname close
  537.   var %site = $regex($gettok(%tracker [ $+ [ $sockname ] ],2,44),/^(?:http:\/\/)?([^\/]+)(.*)$/)
  538.   if ( $regml(0) != 2 ) { echo @newstracker $newstracker-return-text(error4) $gettok(%tracker [ $+ [ $sockname ] ],2,44) | halt }
  539.   sockwrite -n $sockname GET $regml(2) HTTP/1.1
  540.   sockwrite -n $sockname Host: $regml(1) $+ $crlf $+ $crlf
  541.   sockwrite -n $sockname Connection: Close
  542.   sockwrite -n $sockname
  543. }
  544.  
  545.  
  546. on *:sockclose:news*: {
  547.   if ( $sockname == newstrackertest) { return }
  548.   news.parse $sockname
  549. }
  550. on *:sockread:newstrackertest: {
  551.   if ($sockerr) { echo -a $newstracker-return-text(error13) | return }
  552.   if (!$fopen($sockname)) { .sockclose $sockname | .timer [ $+ [ $sockname ] ] off | .remove $+($sockname,.tmp) }
  553.   sockread &line
  554.   while ( $sockbr != 0 ) {
  555.     .fwrite -b $sockname &line
  556.     sockread &line
  557.   }
  558. }
  559.  
  560. on *:sockread:news*: {
  561.   if ($sockerr || $sockname == newstrackertest) { return }
  562.   if (!$fopen($sockname)) {
  563.     echo @newstracker $newstracker-return-text(error5) $gettok(%tracker [ $+ [ $sockname ] ],1,44)
  564.     .sockclose $sockname
  565.     .timer [ $+ [ $sockname ] ] off
  566.     .remove $+($sockname,.txt)
  567.     return
  568.   }
  569.   sockread &news.read
  570.   while ( $sockbr ) { .fwrite -b $sockname &news.read | bunset &news.read | sockread &news.read }
  571. }
  572.  
  573. ;-----------------------socket aliases----------------------------
  574. ;The newsfile has been saved to a temp file on disk
  575. ;this alias reads the temp file and puts it in a binvar called &newstext
  576. ;arguments: $1 = name temp file
  577. alias news.set.var {
  578.   var %i = $file($1).size
  579.   if ( %i ) { bread $1 0 %i &newstext | breplace &newstext 10 32 13 32 }
  580. }
  581.  
  582. ;This alias assumes that there is binvar called &newstext
  583. ;It returns the starting byte and the end byte of a <tag></tag> the tags themselves excluded.
  584. ;arguments: $1 = name of binvar $2 = search from this bit, $prop = tag
  585. alias news.tag.locate {
  586.   if ( !$2 ) { return 0 }
  587.   var %startingbyte = $bfind(& [ $+ [ $1 ] ],$2,$+(<,$prop))
  588.   if ( %startingbyte == 0 ) { return 0 }
  589.   var %endstart = $bfind(& [ $+ [ $1 ] ],%startingbyte,>)
  590.   var %len = $calc(%endstart - %startingbyte + 1) | var %tag = $bvar(& [ $+ [ $1 ] ],%startingbyte,%len).text
  591.   inc %startingbyte %len
  592.   if ( !$regex(%tag,/^<[^<]+>/) ) { return 0 }
  593.   var %endbyte = $bfind(& [ $+ [ $1 ] ],%startingbyte,$+(</,$prop,>))
  594.  
  595.   return %startingbyte %endbyte
  596.   :error | reseterror | return 0
  597. }
  598. ;Returns the ascii text from the binvar &newstext
  599. ;arguments: $1 = name of binvar $2 = startingbit $3 = endbit
  600. alias news.return.content {
  601.   tokenize 32 $1-
  602.   if ( $1 == 0 ) { return $null }
  603.   var %start = $2 | var %end = $3 | var %len = $calc(%end - %start)
  604.   return $bvar(& [ $+ [ $1 ] ],%start,%len).text
  605. }
  606. ;This alias will initialize the parsing process for the downloaded rss feed.
  607. ;Arguments: $1 = sockname and filename rss feed
  608. alias news.parse {
  609.   if ( $sock($1) ) { .sockclose $1 }
  610.   .timer [ $+ [ $1 ] ] off
  611.   if ( $fopen($1) ) { .fclose $1 }
  612.   var %name = $gettok(%tracker [ $+ [ $1 ] ],1,44)
  613.   var %sayorecho = $gettok(%tracker [ $+ [ $1 ] ],3,44)
  614.   news.set.var $+($1,.txt)
  615.   .remove $+($1,.txt)
  616.   var %pos = $news.tag.locate(newstext,1).item | var %index = link
  617.   while ( %pos ) {
  618.     var %location = $news.tag.locate(newstext,%pos). [ $+ [ %index ] ]
  619.     var %indexcontent = $news.return.content(newstext,%location)
  620.     if ( !$hget(newstracker,$crc(%indexcontent,0) $+ $md5(%indexcontent)) ) {
  621.       hadd -m newstracker $crc(%indexcontent,0) $+ $md5(%indexcontent) 1
  622.       news.tell %sayorecho %name %pos
  623.     }
  624.     var %pos = $news.tag.locate(newstext,$gettok(%location,2,32)).item
  625.   }
  626.   return
  627.   :error
  628.   echo @newstracker Error $error
  629.   reseterror
  630. }
  631.  
  632. ;This alias creates the line which is mentioned in the rooms and @newstracker window.
  633. ;It will only allow %newssets.max lines within 5 seconds and calls that the text is mentioned in all rooms
  634. ;arguments: $1 = say/echo, $2 = name tracker, $3 = starting byte and $4 = endbyte in &newstext
  635. alias news.tell {
  636.  
  637.   ;mod_wazer
  638.   ;tokenize 32 $1- $removecdata($2-)
  639.   ;tokenize 32 $1-; original
  640.   tokenize 32 $removecdata($1-)
  641.  
  642.   var %regex = $regex($hget(newstracker-setting,newsbanner. [ $+ [ $2 ] ]),/&(.+?)\b/ig)
  643.   var %i = $regml(0) | bset -t &newsline 1 $hget(newstracker-setting,newsbanner. [ $+ [ $2 ] ])
  644.   var %j = 1
  645.   while ( %j <= %i ) { var %regml = %regml $regml(%j) | inc %j }
  646.   while ( %i ) {
  647.     var %start = $pos($hget(newstracker-setting,newsbanner. [ $+ [ $2 ] ]),$chr(38),%i)
  648.     var %len = $calc($len($gettok(%regml,%i,32))+1)
  649.     var %total = $calc(%start + %len)
  650.     bcopy &temp 1 &newsline 1 $calc(%start - 1)
  651.     ;tag has contents
  652.     if ( $news.parse.line(newstext,$3,$4,$gettok(%regml,%i,32)) == $true ) {
  653.       ;length stripped to 150    
  654.       if ( $bvar(&currentline,0) > 153 ) {
  655.         bcopy &newstrackertemp 1 &currentline 1 150
  656.         bunset &currentline
  657.         bcopy &currentline 1 &newstrackertemp 1 -1
  658.         bset -t &currentline 150 ...
  659.       }
  660.       bcopy &temp $calc($bvar(&temp,0) + 1) &currentline 1 -1
  661.     }
  662.     if ( %total < $bvar(&newsline,0) ) { bcopy &temp $calc($bvar(&temp,0) + 1) &newsline %total -1 }
  663.     bunset &newsline
  664.     bcopy &newsline 1 &temp 1 -1
  665.     bunset &temp
  666.     dec %i
  667.   }
  668.   inc -u5 %tell.room
  669.   if ( !$window(@newstracker) ) {
  670.     if ( $hget(newstracker-setting,window) ) { window -n @newstracker }
  671.     else { window -hn @newstracker }
  672.   }
  673.   if ( $1 == echo || %tell.room > $hget(newstracker-setting,max) || !%tell.room ) { echo @newstracker in_memory: $removecdata($bvar(&newsline,1-).text) }
  674.   else { echo @newstracker saying: $removecdata($bvar(&newsline,1-).text) | scon -a news.tellrooms $2 $removecdata($bvar(&newsline,1-).text) }
  675.   bunset &newsline
  676.   return
  677.   :error
  678.   echo -s $newstracker-return-text(error6)
  679.   echo @newstracker $newstracker-return-text(error7) %name $newstracker-return-text(error8) $error
  680.   echo @newstracker Level: news-tell: $1- \ %start \ %len \ %total
  681.   echo @newstracker Tekst: $bvar(&newstext,$3,$calc($4 - $3)).text
  682.   reseterror
  683. }
  684.  
  685. ;This alias replaces html entities from &currentline and also deletes all <..> sections within a tag
  686. ;arguments: $1 = name binvar, $2 = startbyte, $3 = endbyte, $4 = tag
  687. ;other binvars used are: &temp and &htmlentity
  688. ;result &currentline
  689. alias news.parse.line {
  690.   var %bytes = $news.tag.locate($1,$2). [ $+ [ $4 ] ]
  691.   if (!$calc($gettok(%bytes,2,32) - $gettok(%bytes,1,32)) ) { return $false }
  692.   if ( $bvar(&currentline,0) ) { bunset &currentline }
  693.   bcopy &currentline 1 & [ $+ [ $1 ] ] $gettok(%bytes,1,32) $calc($gettok(%bytes,2,32) - $gettok(%bytes,1,32))
  694.  
  695.   ;here we replace html entiies and delete <..>
  696.   var %pos = 1
  697.   while ( $bfind(&currentline,%pos,&) ) {
  698.     var %pos = $v1
  699.     var %posend = $bfind(&currentline,%pos,;)
  700.     if ( !%posend ) { break }
  701.     inc %posend
  702.     if ( $calc(%posend - %pos) <= 8 ) {
  703.       var %entity = $bvar(&currentline,%pos,$calc(%posend - %pos)).text
  704.       ;if the entity is < then it could start a html tag. If a > is found then we delete the <..> section
  705.       if ( %entity == &lt; ) {
  706.         ;if we find the > then we do the delete, else it will be replaced to < in the next section
  707.         var %next = $bfind(&currentline,%pos,&gt;)
  708.         if ( %next ) {
  709.           bcopy &temp 1 &currentline 1 $calc(%pos -1)
  710.           bcopy &temp $calc($bvar(&temp,0) + 1) &currentline $calc(%next + 4) -1
  711.           bunset &currentline | bcopy -c &currentline 1 &temp 1 $bvar(&temp,0)
  712.           bunset &temp | inc %pos | continue
  713.         }
  714.       }
  715.       ;here we set the &htmlentity to the replace value
  716.       htmlentities %entity
  717.       bcopy &temp $iif($bvar(&temp,0),$calc($v1 +1),1) &currentline 1 $calc(%pos -1)
  718.       bcopy &temp $calc($bvar(&temp,0) + 1) &htmlentity 1 -1
  719.       if ( %posend <= $bvar(&currentline,0) ) { bcopy &temp $calc($bvar(&temp,0) + 1) &currentline %posend -1 }
  720.       bunset &currentline | bcopy -c &currentline 1 &temp 1 $bvar(&temp,0)
  721.       bunset &temp
  722.     }
  723.     inc %pos
  724.   }
  725.   ;echo -a result: $bvar(&currentline,1,$bvar(&currentline,0)).text
  726.   return $true
  727.   :error
  728.   echo -s $newstracker-return-text(error6)
  729.   echo @newstracker $newstracker-return-text(error7) %name $newstracker-return-text(error8) $error
  730.   echo @newstracker Level: news-parse-line: $1- \ %start \ %len \ %total
  731.   echo @newstracker Tekst: $bvar(&newstext,$3,$calc($4 - $3)).text
  732.   reseterror
  733. }
  734.  
  735. ;This alias actually announces the texts in the rooms
  736. ;$1 = name | $2- = text
  737. alias -l news.tellrooms {
  738.  
  739.   ;echo -ag $1-
  740.   ;mod_wazer
  741.   ;tokenize 32 $1 $removecdata($2-)
  742.   tokenize 32 $removecdata($1-)
  743.  
  744.   var %chans = $gettok($hget(newstracker-setting,trackersetting. [ $+ [ $1 ] ]),5-,32)
  745.   var %i = $numtok(%chans,44)
  746.   if ( $hget(newstracker-setting,msg) == all ) {
  747.     while ( %i ) {
  748.       if ( $me ison $gettok(%chans,%i,44) ) { echo -t $v2 $+(<,$me,>) $2- | var %channels = $addtok(%channels,$v2,44) }
  749.       dec %i
  750.     }
  751.     if ( %channels ) { shrinklinks .msg %channels $2- }
  752.   }
  753.   if ( $hget(newstracker-setting,msg) == chans ) {
  754.     if (!$window(@newstrackersay)) { window -h @newstrackersay }
  755.     while ( %i ) {
  756.       if ( $me ison $gettok(%chans,%i,44) ) { aline @newstrackersay $cid msg $v2 $2- }
  757.       dec %i
  758.     }
  759.     if ( !$timer(newstrackersay) ) { .timernewstrackersay 0 3 news_execute }
  760.   }
  761. }
  762. alias news_execute {
  763.   if (!$window(@newstrackersay)) { return | .timernewstrackersay off }
  764.   if ( $line(@newstrackersay,0) > 0 ) {
  765.     var %line = $line(@newstrackersay,1)
  766.     dline @newstrackersay 1
  767.     if ( $gettok(%line,2,32) != msg ) { return }
  768.     scid $gettok(%line,1,32)
  769.     $gettok(%line,2-,32)
  770.   }
  771. }
  772. ;translates html entities to their ascii value and sets it in &htmlentities
  773. alias htmlentities {
  774.   if ( $bvar(&htmlentity,0) ) { bunset &htmlentity }
  775.   var %text = $1-
  776.   if ( $regex(%text,/&[^#]\w+;/) ) {
  777.     var %text = $replace(%text,&nbsp;,160,&iexcl;,161,&cent;,162,&pound;,163,&curren;,164,&yen;,165,&brvbar;,166,&sect;,167,&uml;,168)
  778.     var %text = $replace(%text,&copy;,169,&ordf;,170,&laquo;,171,&not;,172,&shy;,173,&reg;,174,&macr;,175,&deg;,176,&plusmn;,177,&sup2;,178,&sup3;,179)
  779.     var %text = $replace(%text,&acute;,180,&micro;,181,&para;,182,&middot;,183,&cedil;,184,&sup1;,185,&ordm;,186,&raquo;,187,&frac14;,188,&frac12;,189,&frac34;,190)
  780.     var %text = $replace(%text,&iquest;,191,&Agrave;,192,&Aacute;,193,&Acirc;,194,&Atilde;,195,&Auml;,196,&Aring;,197,&AElig;,198,&Ccedil;,199,&Eacute;,201,&Ecirc;,202)
  781.     var %text = $replace(%text,&Euml;,203,&Igrave;,204,&Iacute;,205,&Icirc;,206,&Iuml;,207,&ETH;,208,&Ntilde;,209,&Ograve;,210,&Oacute;,211,&Ocirc;,212,&Otilde;,213)
  782.     var %text = $replace(%text,&Ouml;,214,&times;,215,&Oslash;,216,&Ugrave;,217,&Uacute;,218,&Ucirc;,219,&Uuml;,220,&Yacute;,221,&THORN;,222,&szlig;,223,&agrave;,224)
  783.     var %text = $replace(%text,&aacute;,225,&acirc;,226,&atilde;,227,&auml;,228,&aring;,229,&aelig;,230,&ccedil;,231,&egrave;,232,&eacute;,233,&ecirc;,234,&euml;,235)
  784.     var %text = $replace(%text,&igrave;,236,&iacute;,237,&icirc;,238,&iuml;,239,&eth;,240,&ntilde;,241,&ograve;,242,&oacute;,243,&ocirc;,244,&otilde;,245,&ouml;,246)
  785.     var %text = $replace(%text,&divide;,247,&oslash;,248,&ugrave;,249,&uacute;,250,&ucirc;,251,&uuml;,252,&yacute;,253,&thorn;,254,&yuml;,255,&apos;,39,&amp;,38,&lt;,60,&gt;,62,&quot;,34)
  786.     var %text = $replacecs(%text,&Egrave;,200,&egrave;,232)
  787.   }
  788.   var %text = $regsubex(%text,/&#(\d+);/g,$chr(\t))
  789.   if ( %text == $1- ) { bset -t &htmlentity 1 %text }
  790.   else { bset &htmlentity 1 %text }
  791. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top