2 Replies - 2527 Views - Last Post: 04 March 2012 - 01:54 AM

#1 cbennett  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 31
  • Joined: 13-February 12

How to relay faster

Posted 03 March 2012 - 09:29 PM

Ok, so a friend of mine gave me this code and asked me how I can make this message relay back faster. It is being ran on an Internet Relay Chat program in order to relay weather updates from an RSS feed. He says around line 160 is where it is told to give an error message if a number less than 120 seconds is entered and would like to make it where it would relay in one second rather than 120. I believe the language is Lisp, but neither he nor I knows if it is or not. Thank you for your time.

Here's the code.


;Version 3.5 of news-tracker by snabbi

;-----------------------events--------------------------------

;on startup the feeds have to be initialized
on *:start: { newsfirststart | news_reset_messages_to_default }

;display info on load
on *:load: {
  if ( $isfile(newstracker-setting.hsh) ) {
    if ( $hget(newstracker-setting) ) { .hfree newstracker-setting }
    .hmake newstracker-setting 100 | .hload newstracker-setting newstracker-setting.hsh 
    news_reset_messages_to_default
    news_help load
  }
  else {
    news_resettodefault
    news_help
    dialog -m newstracker newstracker
  }
  newsfirststart
}
on *:unload: {
  if ( $hget(newstracker-setting,lang) != NL ) { 
    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! }
    echo -s Newstracker is unloaded successfully. 
  }
  if ( $hget(newstracker-setting,lang) != EN ) { 
    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 }
    echo -s Newstracker is uit je scripts verwijdert.
  }
  if ( $hget(newstracker) ) { .hfree newstracker }
  if ( $hget(newstracker-setting) ) { .hfree newstracker-setting }
  if ( $window(@newstracker) ) { .window -c @newstracker }
  .timernews* off
  unset %trackernews*
  unset %tell.room
  unset %newssaid
}
;-----------------------menus--------------------------------
menu @newstracker {
  .$iif($hget(newstracker-setting,window),$newstracker-return-text(menu5),):hadd newstracker-setting window 0 | newstracker-save-settings | window -nh @newstracker
  .$iif(!$hget(newstracker-setting,window),$newstracker-return-text(menu6),):hadd newstracker-setting window 1 | newstracker-save-settings | window -w3n @newstracker
  .$newstracker-return-text(menu11):clear
}

menu menubar,channel {
  $newstrackerversion
  .$iif($hget(newstracker-setting,0).item == 0,Reset to default/Reset naar beginwaarden):news_resettodefault
  .$iif(!$hget(newstracker-setting,off),$newstracker-return-text(menu9)): hadd -m newstracker-setting off 1
  .$iif($hget(newstracker-setting,off),$newstracker-return-text(menu10)): hadd -m newstracker-setting off 0
  .$iif($chan($active) && !$newschannels(isinall,$chan($active)),$newstracker-return-text(menu3)):newstracker-chans add $chan($active)
  .$iif($chan($active) && !$newschannels(isnotinany,$chan($active)),$newstracker-return-text(menu4)):newstracker-chans remove $chan($active)
  .$newstracker-return-text(menu13): news_help
  .-
  .$newstracker-return-text(menu1):dialog -m newstracker newstracker
  .-  
  .$iif($hget(newstracker-setting,window),$newstracker-return-text(menu5),):hadd newstracker-setting window 0 | newstracker-save-settings | window -nh @newstracker
  .$iif(!$hget(newstracker-setting,window),$newstracker-return-text(menu6),):hadd newstracker-setting window 1 | newstracker-save-settings | window -w3n @newstracker
  .$newstracker-return-text(menu12):hfree newstracker | news_reset_messages_to_default
  .$newstracker-return-text(menu2):dialog -m newstracker_lang newstracker_lang
  .$newstracker-return-text(menu7):var %i = $input($newstracker-return-text(menu8),y) | if ( %i ) { news_resettodefault }
}

;-----------------------dialogs-------------------------------

dialog newstracker_lang {
  title "NewsTracker  snabbi"
  size -1 -1 110 50
  option dbu
  text "Which language do you prefer? / Welke taal heeft uw voorkeur?",10,10 10 90 14
  button "English",11,10 30 45 15
  button "Nederlands",12,60 30 45 15
}
on *:dialog:newstracker_lang:sclick:11: { hadd -m newstracker-setting lang EN | dialog -c newstracker_lang }
on *:dialog:newstracker_lang:sclick:12: { hadd -m newstracker-setting lang NL | dialog -c newstracker_lang }

dialog newstracker {
  size -1 -1 320 153
  option dbu

  tab $newstracker-return-text(dialog150), 150, 5 1 310 125
  text $newstracker-return-text(dialog2),2,10 20 80 7, tab150 
  radio $newstracker-return-text(dialog3),3,135 20 20 10,group, tab150
  radio $newstracker-return-text(dialog4),4,155 20 20 10, tab150
  text $newstracker-return-text(dialog5),5,10 35 120 7, tab150
  edit "",6,135 34 40 10,autohs, tab150
  text $newstracker-return-text(dialog7),7,178 35 40 10, tab150
  text $newstracker-return-text(dialog8),8,10 48 120 7, tab150
  edit "",9,135 47 40 10,autohs, tab150
  text $newstracker-return-text(dialog10),10,179 48 40 7, tab150
  text $newstracker-return-text(dialog11),11,10 61 80 7, tab150
  radio $newstracker-return-text(dialog12),12,135 61 70 10,group, tab150
  radio $newstracker-return-text(dialog13),13,135 71 80 10, tab150

  tab $newstracker-return-text(dialog151), 151, 5 1 310 125
  text $newstracker-return-text(dialog51),51,10 22 70 7, tab151
  list 52,9 31 72 94,hsbar vsbar sort, tab151
  text $newstracker-return-text(dialog64),64,100 31 50 7, tab151
  radio $newstracker-return-text(dialog65),65,160 31 20 10,group, tab151
  radio $newstracker-return-text(dialog66),66,185 31 20 10, tab151
  text $newstracker-return-text(dialog53),53,100 43 50 7, tab151
  edit "",54,160 42 110 10,autohs, tab151
  text $newstracker-return-text(dialog55),55,100 55 50 7, tab151
  button $newstracker-return-text(dialog88),88,273 55 37 8, tab151
  edit "",56,160 54 110 10,autohs, tab151
  text $newstracker-return-text(dialog57),57,100 67 55 7, tab151
  edit "",58,160 66 110 10,autohs, tab151
  text $newstracker-return-text(dialog59),59,275 67 30 7, tab151
  text $newstracker-return-text(dialog60),60,100 79 50 7, tab151
  edit "",61,160 78 110 10,autohs, tab151
  button $newstracker-return-text(dialog89),89,273 78 37 8, tab151
  text $newstracker-return-text(dialog62),62,100 91 50 7, tab151
  edit "",63,160 90 110 10,autohs, tab151
  button $newstracker-return-text(dialog87),87,273 91 37 8, tab151
  button $newstracker-return-text(dialog80),80,100 105 50 15, tab151
  button $newstracker-return-text(dialog81),81,160 105 50 15, tab151
  button $newstracker-return-text(dialog82),82,220 105 50 15, tab151

  button $newstracker-return-text(dialog100),100,120 131 40 15,ok
}

on *:dialog:newstracker:init:*: {
  var %i = $hfind(newstracker-setting,tracker*,0,w)
  while ( %i ) {
    var %settings = $hget(newstracker-setting,$hfind(newstracker-setting,tracker*,%i,w))
    did -a $dname 52 $gettok(%settings,1,32) | dec %i
  } | did -b $dname 80,82

  did -a $dname 9 $iif($hget(newstracker-setting,interval),$ifmatch,30)
  did -a $dname 6 $iif($hget(newstracker-setting,max),$ifmatch,5)
  did -c $dname $iif($hget(newstracker-setting,off),4,3)
  did -c $dname $iif($hget(newstracker-setting,msg) == all,13,12)
}
on *:dialog:newstracker:sclick:*: { goto $did
  :3 | hadd newstracker-setting off 0 | halt
  :4 | hadd newstracker-setting off 1 | halt
  :12 | hadd newstracker-setting msg chans | halt
  :13 | hadd newstracker-setting msg all | halt
  :52 | if ( $did($dname,52).seltext != $null ) {
    var %options = $hget(newstracker-setting,trackersetting. [ $+ [ $v1 ] ])
    did -ra $dname 54 $v1 | did -ra $dname 56 $gettok(%options,2,32)
    did -ra $dname 58 $gettok(%options,3,32)
    did -ri $dname 61 1 $hget(newstracker-setting,newsbanner. [ $+ [ $v1 ] ])
    did -ri $dname 63 1 $gettok(%options,5-,32)
    did -u $dname 65,66 | did -c $dname $iif($gettok(%options,4,32),65,66)
    did -e $dname 80,82
  } | halt
  :80 | remove-newstracker 
  did -d $dname 52 $did($dname,52,1).sel | did -r $dname 54,56,58,61,63
  did -b $dname 82,80 
  halt
  :82 | :81 | var %name = $replace($did($dname,54),$chr(32),_)
  if ( (!$did($dname,52).sel && $did != 81) || %name == $null || $did($dname,58) == $null || $did($dname,56) == $null ) {
    var %i = $input($newstracker-return-text(error1),o,Error) | halt
  }
  if ( ( $did == 81 && $hget(newstracker-setting,trackersetting. [ $+ [ %name ] ]) ) || $&
    ( $did == 82 && $did($dname,52).seltext != %name ) && $hget(newstracker-setting,trackersetting. [ $+ [ %name ] ]) ) {
    var %i = $input($newstracker-return-text(error2),o,Error) | halt 
  }
  if ( $did($dname,58) !isnum || $did($dname,58) < 1 ) { var %i = $input($newstracker-return-text(error3),o) | halt }
  if ( $did == 82 ) { remove-newstracker } | did -b $dname 82,80
  hadd newstracker-setting newsbanner. [ $+ [ %name ] ] $iif($did($dname,61),$v1,&title - 12&link)
  var %reg = /((?:,|\s)+)/g | var %rooms = $regsubex($did($dname,63),%reg,$chr(44)) | var %i = 1 
  while ( %i <= $numtok(%rooms,44) ) {
    var %room = $addtok(%room,$iif($+($chr(35),*) iswm $gettok(%rooms,%i,44),$v2,$+($chr(35),$v2)),44)
    inc %i
  }
  hadd newstracker-setting trackersetting. [ $+ [ %name ] ] %name $did($dname,56) $did($dname,58) $iif($did(65).state,1,0) %room
  if ( $did == 81 ) { checknews %name echo }
  if ( $did == 82 ) { did -d $dname 52 $did($dname,52,1).sel }
  did -a $dname 52 %name | did -r $dname 54,56,58,61,63 | did -u $dname 65,66,52 | halt
  :89 | if ( $did(61) ) { echo -a ---------- | echo -a $did(61) | echo -a ---------- } | halt
  :88 | newstracker_check_url $did(56) | halt
  :65 | :66 | if ( !$did($dname,52).sel ) { halt } | did -e $dname 82 | halt
  :87 | if ( $chan($active) == $window($active) ) {
    did -ra $dname 63 $addtok($did($dname,63),$chan($active),44)
    if ( $did == 6 || $did == 9 || !$did($dname,52).sel ) { return }
    did -e $dname 82
  }
  halt
  :100 | hadd newstracker-setting interval $iif($did(9),$ifmatch,30) 
  hadd newstracker-setting max $iif($did(6),$ifmatch,5)
  newstracker-save-settings 
  dialog -x $dname | newstracker-save-settings | news_start
  :0 | :150 | :151
}

on *:dialog:newstracker:edit:*: {
  if ( $did == 6 || $did == 9 || !$did($dname,52).sel ) { halt }
  did -e $dname 82
}

;-----------------------aliases-------------------------------
alias newstrackerversion { return Newstracker 3.5 }
alias news_help {
  .timer 1 1 echo -s -----------------------
  .timer 1 1 echo -s $newstracker-return-text(welkom1) 
  .timer 1 4 echo -s $newstracker-return-text(welkom2)
  .timer 1 7 echo -s $newstracker-return-text(welkom3) 
  .timer 1 10 echo -s $newstracker-return-text(welkom4)
  .timer 1 13 echo -s $newstracker-return-text(welkom5) 
  .timer 1 16 echo -s $newstracker-return-text(welkom6)
  if ( $1 == load ) { .timer 1 19 echo -s $newstracker-return-text(welkom7) }
  .timer 1 22 echo -a -----------------------
}
alias newstracker-save-settings { .hsave -o newstracker-setting newstracker-setting.hsh }

;returns the text in the language what was choosen $1 = number for event
alias newstracker-return-text { return $hget(newstracker,$+($hget(newstracker-setting,lang),-,$1)) }

;$1 = isinall of isnotinany $2 = channame
alias newschannels {
  var %i = $hfind(newstracker-setting,tracker*,0,w)
  while ( %i ) {
    var %name = $hfind(newstracker-setting,tracker*,%i,w)
    var %settings = $hget(newstracker-setting,%name)
    if ( $istok($gettok(%settings,5,32),$2,44) ) {
      if ( $1 == isnotinany ) { return $false }
    }
    else {
      if ( $1 == isinall ) { return $false }
    }
    dec %i
  }
  return $true
}
alias news_reset_messages_to_default {
  if ( !$hget(newstracker) ) { .hmake newstracker 100 }
  hadd newstracker NL-welkom1 U heeft zojuist news-tracker geinstalleerd op uw mIRC versie  snabbi
  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 kunt u via de instellingen het script aanpassen. 
  hadd newstracker NL-welkom3 Op het eerste tabblad ziet u de algemene instellingen. Deze instellingen hebben betrekking op alle feeds. Zo kunt 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 kunt u instellen dat er een bepaalde tijd is tussen het downloaden van 2 sites.
  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 kunt u ook elk kanaal apart informeren.
  hadd newstracker NL-welkom5 Het tweede tabblad heet "Feed instellingen". Hier kunt u per site de instellingen voor de feed wijzigen. U kunt 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 kunt gebruiken in het veld "Tekst banner"
  hadd newstracker NL-welkom6 Speel maar gerust met het script. Heeft u nog vragen dan kunt u mij mailen op newstracker@snirc.nl. Vergeet overigens niet om kamers toe te voegen aan uw feeds, want anders ziet u ze niet!
  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
  hadd newstracker EN-welkom1 You just installed news-tracker on your mIRC client  snabbi
  hadd newstracker EN-welkom2 The menu "newstracker 3.5" 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.
  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.
  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.
  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.
  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.
  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
  hadd newstracker NL-dialog2 Tracker gebruiken? | hadd newstracker EN-dialog2 Use newstracker?
  hadd newstracker NL-dialog3 Ja | hadd newstracker EN-dialog3 Yes
  hadd newstracker NL-dialog4 Nee | hadd newstracker EN-dialog4 No
  hadd newstracker NL-dialog5 Max aantal teksten per feed (flood bescherming)
  hadd newstracker EN-dialog5 Max number of msgs for each feed (flood prot)
  hadd newstracker NL-dialog7 (0=oneindig) | hadd newstracker EN-dialog7 (0=indefinitely)
  hadd newstracker NL-dialog8 Minimum tijd tussen 2 downloads
  hadd newstracker EN-dialog8 Minimum time between downloading 2 feeds
  hadd newstracker NL-dialog10 seconden | hadd newstracker EN-dialog10 seconds
  hadd newstracker EN-dialog11 How to send channel messages: | hadd newstracker EN-dialog12 each chan individually
  hadd newstracker EN-dialog13 single message to all chans | hadd newstracker NL-dialog11 Berichten versturen:
  hadd newstracker NL-dialog12 elk kanaal apart | hadd newstracker NL-dialog13 als 1 bericht naar alle kanalen
  hadd newstracker NL-dialog51 Feed namen | hadd newstracker EN-dialog51 Feed names
  hadd newstracker NL-dialog53 Naam tracker | hadd newstracker EN-dialog53 Name tracker
  hadd newstracker NL-dialog55 URL RSS feed | hadd newstracker EN-dialog55 URL RSS feed
  hadd newstracker NL-dialog57 Download feed elke | hadd newstracker EN-dialog57 Download feed each
  hadd newstracker NL-dialog59 seconden | hadd newstracker EN-dialog59 seconds
  hadd newstracker NL-dialog60 Tekst banner | hadd newstracker EN-dialog60 Text banner
  hadd newstracker NL-dialog62 Zeg op kamers | hadd newstracker EN-dialog62 Say on rooms
  hadd newstracker NL-dialog64 Gebruik feed | hadd newstracker EN-dialog64 Use feed
  hadd newstracker NL-dialog65 Ja | hadd newstracker EN-dialog65 Yes
  hadd newstracker NL-dialog66 Nee | hadd newstracker EN-dialog66 No
  hadd newstracker NL-dialog80 &Verwijder Feed | hadd newstracker EN-dialog80 &Remove Feed
  hadd newstracker NL-dialog81 &Nieuwe Feed | hadd newstracker EN-dialog81 &New Feed
  hadd newstracker NL-dialog82 Op&slaan | hadd newstracker EN-dialog82 &Save changes
  hadd newstracker NL-dialog87 huidige kamer | hadd newstracker EN-dialog87 active room
  hadd newstracker NL-dialog88 check URL | hadd newstracker EN-dialog88 check URL
  hadd newstracker NL-dialog89 voorbeeld | hadd newstracker EN-dialog89 example
  hadd newstracker NL-dialog100 &Oke | hadd newstracker EN-dialog100 &OK
  hadd newstracker NL-dialog150 Algemene instellingen | hadd newstracker EN-dialog150 General settings
  hadd newstracker NL-dialog151 Instellingen per feed | hadd newstracker EN-dialog151 Feed settings
  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
  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
  hadd newstracker NL-error2 Naam is niet uniek | hadd newstracker EN-error2 Name already in use
  hadd newstracker NL-error3 De tijd voor elke download moet minimaal 2 minuten zijn (=120 seconden)
  hadd newstracker EN-error3 The time between downloading a feed has to be at least 2 minutes (=120 seconds)
  hadd newstracker NL-error4 Download mislukt van | hadd newstracker EN-error4 Could not download news from 
  hadd newstracker NL-error5 Fout tijdens het download van het nieuws. Site reageerde te traag: 
  hadd newstracker EN-error5 Error while downloading news. Site was responding to slowly:
  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
  hadd newstracker EN-error6 Error in newstracker. Please consult your @newstracker window or contact snabbi at newstracker@snirc.nl
  hadd newstracker NL-error7 Fout tijdens het parsen van | hadd newstracker EN-error7 Error while parsing
  hadd newstracker NL-error8 foutcode is: | hadd newstracker EN-error8 message is:

  hadd newstracker NL-error9 Geef een URL in het daarvoor bedoelde veld op.
  hadd newstracker EN-error9 Please specify a URL.
  hadd newstracker NL-error10 Het script is nog bezig met het verwerken van uw vorige verzoek.
  hadd newstracker EN-error10 The script is still processing your previous request.
  hadd newstracker NL-error11 De URL is in het verkeerde formaat.
  hadd newstracker EN-error11 Invalid format of URL:
  hadd newstracker NL-error12 verwacht:
  hadd newstracker EN-error12 expect:
  hadd newstracker NL-error13 Fout bij het downloaden van de site
  hadd newstracker EN-error13 Error while downloading from site

  hadd newstracker NL-menu1 Instellingen 
  hadd newstracker NL-menu2 Verander taal/Change language
  hadd newstracker NL-menu3 Voeg kamer toe aan alle trackers
  hadd newstracker NL-menu4 Verwijder kamer van alle trackers
  hadd newstracker NL-menu5 Verberg scherm @newstracker
  hadd newstracker NL-menu6 Toon scherm @newstracker
  hadd newstracker NL-menu7 Reset naar beginwaarden
  hadd newstracker NL-menu8 Weet u zeker dat u de huidige instellingen wilt wissen
  hadd newstracker NL-menu9 Schakel script uit
  hadd newstracker NL-menu10 Schakel script in
  hadd newstracker NL-menu11 Leeg maken
  hadd newstracker NL-menu12 Wis berichtgeschiedenis
  hadd newstracker NL-menu13 Help

  hadd newstracker EN-menu1 Settings
  hadd newstracker EN-menu2 Change language/Verander taal
  hadd newstracker EN-menu3 Add chan to all trackers
  hadd newstracker EN-menu4 Remove chan from all trackers
  hadd newstracker EN-menu5 Hide @newstracker
  hadd newstracker EN-menu6 Unhide @newstracker
  hadd newstracker EN-menu7 Reset to default
  hadd newstracker EN-menu8 Are you sure you want to reset to defaults
  hadd newstracker EN-menu9 Turn off script
  hadd newstracker EN-menu10 Turn on script
  hadd newstracker EN-menu11 Clear
  hadd newstracker EN-menu12 Clear news memory
  hadd newstracker EN-menu13 Help

  hadd newstracker EN-test0 Please wait 5 seconds to allow the script to download the requested file
  hadd newstracker EN-test1 The script was able to download a file from your URL:
  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.
  hadd newstracker EN-test3 The tag 12
  hadd newstracker EN-test4 should be entered as 12
  hadd newstracker EN-test5 to display the following message 12
  hadd newstracker NL-test0 Wacht 5 seconden aub om het script in staat te stellen het gevraagde bestand te downloaden
  hadd newstracker NL-test1 Het script was in staat om een bestand te downloaden vanaf de opgegeven URL: 12
  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.
  hadd newstracker NL-test3 De tag 12
  hadd newstracker NL-test4 moet ingevoerd worden als 12
  hadd newstracker NL-test5 om het volgende weer te geven 12
}
alias news_resettodefault {
  if ( $isfile(newstracker-setting.hsh) ) { .remove newstracker-setting.hsh }
  if ( $hget(newstracker-setting) ) { hfree newstracker-setting }
  if ( $hget(newstracker) ) { hfree newstracker }
  hadd -m newstracker-setting lang NL 
  hadd newstracker-setting interval 30
  hadd newstracker-setting max 5 | hadd newstracker-setting window $true | hadd newstracker-setting off 0 | hadd newstracker-setting msg all
  news_reset_messages_to_default
  var %i = $dialog(newstracker_lang,newstracker_lang) 
  newstracker_reset_to_default_2
  newstracker-save-settings
}
alias newstracker_reset_to_default_2 {
  if ( $hget(newstracker-setting,lang) == NL ) {
    var %trackers = AD,Fok,NOS-Nieuws,NOS-Sport,NuAlg,NuEco,NuInternet | var %names = AD,Fok!,NOS,NOS,Nu.nl,Nu.nl,Nu.nl
    var %info = http://www.ad.nl/?service=rss,http://rss.fok.nl/feeds/nieuws,http://feeds.nos.nl/nosnieuws,http://feeds.nos.nl/nossport, $&
      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
  }
  else if ( $v1 == EN ) {
    var %trackers = BBC,CNN | var %names = BBC,CNN
    var %info = http://newsrss.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml,http://rss.cnn.com/rss/cnn_latest.rss
  }
  var %i = $numtok(%trackers,44)
  while ( %i ) {
    hadd newstracker-setting newsbanner. [ $+ [ $gettok(%trackers,%i,44) ] ] $+(4,$gettok(%names,%i,44), &title - 12&link 4,$gettok(%names,%i,44))
    hadd newstracker-setting trackersetting. [ $+ [ $gettok(%trackers,%i,44) ] ] $gettok(%trackers,%i,44) $gettok(%info,%i,44) 360 1
    dec %i
  }
  newstracker-save-settings | newsfirststart
}
alias newsfirststart {
  if ( !$hget(newstracker-setting) ) { .hmake newstracker-setting 100 | .hload newstracker-setting newstracker-setting.hsh }
  var %i = $hfind(newstracker-setting,tracker*,0,w)
  while ( %i ) {
    var %feed = $hfind(newstracker-setting,tracker*,%i,w) | checknews $gettok($hget(newstracker-setting,%feed),1,32) echo
    dec %i
  }
  news_start 
}
alias news_start {
  var %i = $hfind(newstracker-setting,tracker*,0,w)
  while ( %i ) {
    var %options = $hget(newstracker-setting,$hfind(newstracker-setting,tracker*,%i,w))
    var %feed = $gettok(%options,1,32)
    if ( $gettok(%options,4,32) && !$timer(news $+ %feed) ) { 
      .timernews [ $+ [ %feed ] ] -io 1 $gettok(%options,3,32) checknews %feed say
    }
    dec %i
  }
}

alias remove-newstracker {
  if ( !$dialog(newstracker) ) { return }
  var %name = $did(newstracker,52).seltext 
  hdel $+(newstracker-setting newsbanner.,%name) | hdel $+(newstracker-setting trackersetting.,%name)
  if ( $timer(news $+ %name) ) { .timernews. [ $+ [ %name ] ] off }
}

;$1 = naam feed, $2 say of echo
alias checknews {
  var %settings = $hget(newstracker-setting,trackersetting. [ $+ [ $1 ] ])
  if ( $hget(newstracker-setting,off) == 1 || !$2 || !%settings ) { return }
  if ( $gettok(%settings,4,32) != 1 ) { return }
  if ( $2 == echo ) { goto over }
  if ( %newssaid ) { .timernews [ $+ [ $1 ] ] -io 1 $v1 checknews $1 say | .timernewssaid 1 $calc($v1 - 1) unset % $+ newssaid | halt }
  .timernews [ $+ [ $1 ] ] -io 1 $gettok(%settings,3,32) checknews $1 say
  set -z %newssaid $hget(newstracker-setting,interval)

  :over
  var %i = 1 | while ( $sock(news $+ %i).name ) { inc %i }
  var %site = $gettok(%settings,2,32)
  set -u60 %trackernews [ $+ [ %i ] ] $+($1,$chr(44),%site,$chr(44),$2)
  var %j = $regex(%site,/^(?:http:\/\/)?([^\/]+)(.*)$/)
  if ( $regml(0) != 2 ) { echo @newstracker $newstracker-return-text(error4) %site | halt }
  .sockopen news $+ %i $regml(1) 80
}

alias newstracker-chans {
  var %i = $hfind(newstracker-setting,tracker*,0,w)
  while ( %i ) {
    var %options = $hget(newstracker-setting,$hfind(newstracker-setting,tracker*,%i,w))
    var %feed = $gettok(%options,1,32)
    if ( $1 == add ) { hadd newstracker-setting trackersetting. [ $+ [ %feed ] ] $gettok(%options,1-4,32) $addtok($gettok(%options,5-,32),$2,44) }
    if ( $1 == remove ) { hadd newstracker-setting trackersetting. [ $+ [ %feed ] ] $gettok(%options,1-4,32) $remtok($gettok(%options,5-,32),$2,1,44) }
    dec %i
  }
  newstracker-save-settings
}
alias newstracker_check_url { 
  echo -a -----------
  echo -a $newstracker-return-text(test0)
  var %newstracker_testurl = $did(newstracker,56)
  if ( !%newstracker_testurl ) { echo -a $newstracker-return-text(error9) | return }
  if ( $sock(newstrackertest) ) { echo -a $newstracker-return-text(error10) | return }
  var %site = $regex(%newstracker_testurl,/^(?:http:\/\/)?([^\/]+)(.*)$/)
  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 }
  .timernewstrackertest off
  .sockopen newstrackertest $regml(1) 80
}
alias newstracker_endtest {
  if ( $sock($1) ) { .sockclose $1 }
  if ( $fopen($1) ) { var %i = $fopen($1).pos | .fseek -l $1 1 | var %i = $fread($1,%i,&fullline) | .fclose $1 }
  .remove $+($1,.tmp) 
  var %i = $news.tag.locate(fullline,$gettok($news.tag.locate(fullline,1).item,2,32)).item
  var %j = $gettok(%i,1,32) | var %k = $gettok(%i,2,32)
  while ( %j < %k ) {
    var %j = $bfind(&fullline,%j,</) | inc %j 2 | var %l = $bfind(&fullline,%j,>)
    if ( %j <= %k && $calc(%l - %j) < 20 ) { var %tags = $addtok(%tags,$bvar(&fullline,%j,$calc(%l - %j)).text,44) }
  }
  echo -a $newstracker-return-text(test1) 12 $+ $did(newstracker,56)
  echo -a $newstracker-return-text(test2)
  var %j = $numtok(%tags,44)
  while ( %j ) {
    var %text = $news.parse.line(fullline,$gettok(%i,1,32),$gettok(%i,2,32),$gettok(%tags,%j,44))
    ;length stripped to 150    
    if ( $bvar(&currentline,0) > 153 ) { 
      bcopy &newstrackertemp 1 &currentline 1 150
      bunset &currentline
      bcopy &currentline 1 &newstrackertemp 1 -1
      bset -t &currentline 150 ... 
    }
    echo -a $newstracker-return-text(test3) $+ $gettok(%tags,%j,44) $&
      $newstracker-return-text(test4) $+ & $+ $gettok(%tags,%j,44) $&
      $newstracker-return-text(test5) $+ $bvar(&currentline,1-).text
    dec %j
  }
  echo -a -----------
}
;-----------------------sockets-------------------------------
on *:sockopen:newstrackertest: {
  if ($sockerr) { return }
  .timernewstrackertest 1 7 newstracker_endtest $sockname
  .fopen -on $sockname $sockname $+ .tmp
  var %site = $regex($did(newstracker,56),/^(?:http:\/\/)?([^\/]+)(.*)$/)
  if ( $regml(0) != 2 ) { echo @newstracker $newstracker-return-text(error4) $gettok(%tracker [ $+ [ $sockname ] ],2,44) | halt }
  sockwrite -n $sockname GET $regml(2) HTTP/1.1 
  sockwrite -n $sockname Host: $regml(1)
  sockwrite -n $sockname Connection: Close $+ $crlf $+ $crlf
  sockwrite -n $sockname
}
on *:sockopen:news*: {
  if ($sockerr ) { return }
  if ( $sockname == newstrackertest) { return }
  if ( $fopen($sockname) ) { .fclose $sockname }
  .fopen -on $sockname $sockname $+ .txt
  .timer [ $+ [ $sockname ] ] 1 5 news.parse $sockname close
  var %site = $regex($gettok(%tracker [ $+ [ $sockname ] ],2,44),/^(?:http:\/\/)?([^\/]+)(.*)$/)
  if ( $regml(0) != 2 ) { echo @newstracker $newstracker-return-text(error4) $gettok(%tracker [ $+ [ $sockname ] ],2,44) | halt }
  sockwrite -n $sockname GET $regml(2) HTTP/1.1 
  sockwrite -n $sockname Host: $regml(1) $+ $crlf $+ $crlf
  sockwrite -n $sockname Connection: Close
  sockwrite -n $sockname
}


on *:sockclose:news*: {
  if ( $sockname == newstrackertest) { return }
  news.parse $sockname
}
on *:sockread:newstrackertest: {
  if ($sockerr) { echo -a $newstracker-return-text(error13) | return }
  if (!$fopen($sockname)) { .sockclose $sockname | .timer [ $+ [ $sockname ] ] off | .remove $+($sockname,.tmp) }
  sockread &line
  while ( $sockbr != 0 ) {
    .fwrite -b $sockname &line
    sockread &line
  }
}

on *:sockread:news*: {
  if ($sockerr || $sockname == newstrackertest) { return }
  if (!$fopen($sockname)) { 
    echo @newstracker $newstracker-return-text(error5) $gettok(%tracker [ $+ [ $sockname ] ],1,44) 
    .sockclose $sockname 
    .timer [ $+ [ $sockname ] ] off
    .remove $+($sockname,.txt)
    return
  }
  sockread &news.read 
  while ( $sockbr ) { .fwrite -b $sockname &news.read | bunset &news.read | sockread &news.read }
}

;-----------------------socket aliases----------------------------
;The newsfile has been saved to a temp file on disk
;this alias reads the temp file and puts it in a binvar called &newstext
;arguments: $1 = name temp file
alias news.set.var { 
  var %i = $file($1).size
  if ( %i ) { bread $1 0 %i &newstext | breplace &newstext 10 32 13 32 }
}

;This alias assumes that there is binvar called &newstext
;It returns the starting byte and the end byte of a <tag></tag> the tags themselves excluded.
;arguments: $1 = name of binvar $2 = search from this bit, $prop = tag
alias news.tag.locate {
  if ( !$2 ) { return 0 }
  var %startingbyte = $bfind(& [ $+ [ $1 ] ],$2,$+(<,$prop))
  if ( %startingbyte == 0 ) { return 0 }
  var %endstart = $bfind(& [ $+ [ $1 ] ],%startingbyte,>)
  var %len = $calc(%endstart - %startingbyte + 1) | var %tag = $bvar(& [ $+ [ $1 ] ],%startingbyte,%len).text
  inc %startingbyte %len
  if ( !$regex(%tag,/^<[^<]+>/) ) { return 0 }
  var %endbyte = $bfind(& [ $+ [ $1 ] ],%startingbyte,$+(</,$prop,>))

  return %startingbyte %endbyte
  :error | reseterror | return 0
}
;Returns the ascii text from the binvar &newstext
;arguments: $1 = name of binvar $2 = startingbit $3 = endbit
alias news.return.content {
  tokenize 32 $1-
  if ( $1 == 0 ) { return $null }
  var %start = $2 | var %end = $3 | var %len = $calc(%end - %start)
  return $bvar(& [ $+ [ $1 ] ],%start,%len).text
}
;This alias will initialize the parsing process for the downloaded rss feed.
;Arguments: $1 = sockname and filename rss feed
alias news.parse {
  if ( $sock($1) ) { .sockclose $1 }
  .timer [ $+ [ $1 ] ] off
  if ( $fopen($1) ) { .fclose $1 }
  var %name = $gettok(%tracker [ $+ [ $1 ] ],1,44)
  var %sayorecho = $gettok(%tracker [ $+ [ $1 ] ],3,44)
  news.set.var $+($1,.txt) 
  .remove $+($1,.txt) 
  var %pos = $news.tag.locate(newstext,1).item | var %index = link
  while ( %pos ) {
    var %location = $news.tag.locate(newstext,%pos). [ $+ [ %index ] ]
    var %indexcontent = $news.return.content(newstext,%location)
    if ( !$hget(newstracker,$crc(%indexcontent,0) $+ $md5(%indexcontent)) ) {
      hadd -m newstracker $crc(%indexcontent,0) $+ $md5(%indexcontent) 1
      news.tell %sayorecho %name %pos 
    }
    var %pos = $news.tag.locate(newstext,$gettok(%location,2,32)).item
  }
  return
  :error
  echo @newstracker Error $error
  reseterror
}

;This alias creates the line which is mentioned in the rooms and @newstracker window.
;It will only allow %newssets.max lines within 5 seconds and calls that the text is mentioned in all rooms
;arguments: $1 = say/echo, $2 = name tracker, $3 = starting byte and $4 = endbyte in &newstext
alias news.tell {
  tokenize 32 $1-
  var %regex = $regex($hget(newstracker-setting,newsbanner. [ $+ [ $2 ] ]),/&(.+?)\b/ig)
  var %i = $regml(0) | bset -t &newsline 1 $hget(newstracker-setting,newsbanner. [ $+ [ $2 ] ])
  var %j = 1 
  while ( %j <= %i ) { var %regml = %regml $regml(%j) | inc %j }
  while ( %i ) {
    var %start = $pos($hget(newstracker-setting,newsbanner. [ $+ [ $2 ] ]),$chr(38),%i)
    var %len = $calc($len($gettok(%regml,%i,32))+1)
    var %total = $calc(%start + %len)
    bcopy &temp 1 &newsline 1 $calc(%start - 1)
    ;tag has contents
    if ( $news.parse.line(newstext,$3,$4,$gettok(%regml,%i,32)) == $true ) { 
      ;length stripped to 150    
      if ( $bvar(&currentline,0) > 153 ) { 
        bcopy &newstrackertemp 1 &currentline 1 150
        bunset &currentline
        bcopy &currentline 1 &newstrackertemp 1 -1
        bset -t &currentline 150 ... 
      }
      bcopy &temp $calc($bvar(&temp,0) + 1) &currentline 1 -1
    }
    if ( %total < $bvar(&newsline,0) ) { bcopy &temp $calc($bvar(&temp,0) + 1) &newsline %total -1 }
    bunset &newsline
    bcopy &newsline 1 &temp 1 -1
    bunset &temp
    dec %i
  }
  inc -u5 %tell.room
  if ( !$window(@newstracker) ) { 
    if ( $hget(newstracker-setting,window) ) { window -n @newstracker }
    else { window -hn @newstracker }
  }
  if ( $1 == echo || %tell.room > $hget(newstracker-setting,max) || !%tell.room ) { echo @newstracker in_memory: $bvar(&newsline,1-).text }
  else { echo @newstracker saying: $bvar(&newsline,1-).text | scon -a news.tellrooms $2 $bvar(&newsline,1-).text }
  bunset &newsline
  return
  :error
  echo -s $newstracker-return-text(error6)
  echo @newstracker $newstracker-return-text(error7) %name $newstracker-return-text(error8) $error
  echo @newstracker Level: news-tell: $1- \ %start \ %len \ %total
  echo @newstracker Tekst: $bvar(&newstext,$3,$calc($4 - $3)).text
  reseterror
}

;This alias replaces html entities from &currentline and also deletes all <..> sections within a tag
;arguments: $1 = name binvar, $2 = startbyte, $3 = endbyte, $4 = tag
;other binvars used are: &temp and &htmlentity
;result &currentline
alias news.parse.line { 
  var %bytes = $news.tag.locate($1,$2). [ $+ [ $4 ] ]
  if (!$calc($gettok(%bytes,2,32) - $gettok(%bytes,1,32)) ) { return $false }
  if ( $bvar(&currentline,0) ) { bunset &currentline }
  bcopy &currentline 1 & [ $+ [ $1 ] ] $gettok(%bytes,1,32) $calc($gettok(%bytes,2,32) - $gettok(%bytes,1,32))

  ;here we replace html entiies and delete <..>
  var %pos = 1
  while ( $bfind(&currentline,%pos,&) ) {
    var %pos = $v1
    var %posend = $bfind(&currentline,%pos,;)/>
    if ( !%posend ) { break }
    inc %posend
    if ( $calc(%posend - %pos) <= 8 ) {
      var %entity = $bvar(&currentline,%pos,$calc(%posend - %pos)).text
      ;if the entity is < then it could start a html tag. If a > is found then we delete the <..> section
      if ( %entity == &lt; ) { 
        ;if we find the > then we do the delete, else it will be replaced to < in the next section
        var %next = $bfind(&currentline,%pos,&gt;)
        if ( %next ) { 
          bcopy &temp 1 &currentline 1 $calc(%pos -1)
          bcopy &temp $calc($bvar(&temp,0) + 1) &currentline $calc(%next + 4) -1
          bunset &currentline | bcopy -c &currentline 1 &temp 1 $bvar(&temp,0)
          bunset &temp | inc %pos | continue
        }
      }
      ;here we set the &htmlentity to the replace value
      htmlentities %entity
      bcopy &temp $iif($bvar(&temp,0),$calc($v1 +1),1) &currentline 1 $calc(%pos -1) 
      bcopy &temp $calc($bvar(&temp,0) + 1) &htmlentity 1 -1
      if ( %posend <= $bvar(&currentline,0) ) { bcopy &temp $calc($bvar(&temp,0) + 1) &currentline %posend -1 }
      bunset &currentline | bcopy -c &currentline 1 &temp 1 $bvar(&temp,0)
      bunset &temp
    }
    inc %pos
  }
  ;echo -a result: $bvar(&currentline,1,$bvar(&currentline,0)).text
  return $true
  :error
  echo -s $newstracker-return-text(error6)
  echo @newstracker $newstracker-return-text(error7) %name $newstracker-return-text(error8) $error
  echo @newstracker Level: news-parse-line: $1- \ %start \ %len \ %total
  echo @newstracker Tekst: $bvar(&newstext,$3,$calc($4 - $3)).text
  reseterror
}

;This alias actually announces the texts in the rooms
;$1 = name | $2- = text
alias -l news.tellrooms {
  var %chans = $gettok($hget(newstracker-setting,trackersetting. [ $+ [ $1 ] ]),5-,32)
  var %i = $numtok(%chans,44)
  if ( $hget(newstracker-setting,msg) == all ) {
    while ( %i ) {
      if ( $me ison $gettok(%chans,%i,44) ) { echo -t $v2 $+(<,$me,>) $2- | var %channels = $addtok(%channels,$v2,44) }
      dec %i
    }
    if ( %channels ) { .msg %channels $2- }
  }
  if ( $hget(newstracker-setting,msg) == chans ) {
    if (!$window(@newstrackersay)) { window -h @newstrackersay } 
    while ( %i ) {
      if ( $me ison $gettok(%chans,%i,44) ) { aline @newstrackersay $cid msg $v2 $2- }
      dec %i
    }
    if ( !$timer(newstrackersay) ) { .timernewstrackersay 0 3 news_execute }
  }
}
alias news_execute {
  if (!$window(@newstrackersay)) { return | .timernewstrackersay off }
  if ( $line(@newstrackersay,0) > 0 ) {
    var %line = $line(@newstrackersay,1)
    dline @newstrackersay 1
    if ( $gettok(%line,2,32) != msg ) { return }
    scid $gettok(%line,1,32)
    $gettok(%line,2-,32)
  }
}
;translates html entities to their ascii value and sets it in &htmlentities
alias htmlentities {
  if ( $bvar(&htmlentity,0) ) { bunset &htmlentity }
  var %text = $1-
  if ( $regex(%text,/&[^#]\w+;/) ) { 
    var %text = $replace(%text,&nbsp;,160,&iexcl;,161,&cent;,162,&pound;,163,&curren;,164,&yen;,165,&brvbar;,166,&sect;,167,&uml;,168)
    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)
    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)
    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)
    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)
    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)
    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)
    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)
    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)
    var %text = $replacecs(%text,&Egrave;,200,&egrave;,232)
  }
  var %text = $regsubex(%text,/&#(\d+);/g,$chr(\t))
  if ( %text == $1- ) { bset -t &htmlentity 1 %text }
  else { bset &htmlentity 1 %text }
}




Is This A Good Question/Topic? 0
  • +

Replies To: How to relay faster

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2117
  • View blog
  • Posts: 3,242
  • Joined: 21-June 11

Re: How to relay faster

Posted 04 March 2012 - 12:43 AM

That is most certainly not a Lisp. Nor is it any other functional programming language.

It looks like a custom-made scripting language to me (based on the fact that it doesn't look very familiar and that I don't think it's very common for general purpose languages to have a "menu" keyword).
Was This Post Helpful? 0
  • +
  • -

#3 cbennett  Icon User is offline

  • New D.I.C Head

Reputation: 6
  • View blog
  • Posts: 31
  • Joined: 13-February 12

Re: How to relay faster

Posted 04 March 2012 - 01:54 AM

View Postsepp2k, on 04 March 2012 - 12:43 AM, said:

That is most certainly not a Lisp. Nor is it any other functional programming language.

It looks like a custom-made scripting language to me (based on the fact that it doesn't look very familiar and that I don't think it's very common for general purpose languages to have a "menu" keyword).



Well then, that makes changing it next to impossible without any API or Documentation. Drat.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1