changeset 650:80db2b265c5f

Remove obsolete scripts.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 17 Feb 2021 10:55:52 +0200
parents 92aefade4466
children ecd8fb2b9ad3
files fetch_food.tcl ruoka.tcl
diffstat 2 files changed, 0 insertions(+), 363 deletions(-) [+]
line wrap: on
line diff
--- a/fetch_food.tcl	Wed Feb 17 10:29:41 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,151 +0,0 @@
-#!/usr/bin/tclsh
-#
-# NOTICE! Change above path to correct tclsh binary path!
-#
-##########################################################################
-#
-# RuokaLista fetcher v1.0 by Matti 'ccr' Hamalainen <ccr@tnsp.org>
-# (C) Copyright 2010-2011 Tecnic Software productions (TNSP)
-#
-# This script is freely distributable under GNU GPL (version 2) license.
-#
-##########################################################################
-
-# Path and filename of the data file, MUST BE SAME as in "ruoka.tcl"
-set datafile "/home/niinuska/bot/data.ruoka"
-
-# Use a HTTP proxy? (1 = yes, 0 = no)
-set http_proxy 0
-
-# HTTP proxy host address and port (only needed if use_proxy = 1)
-set http_proxy_host "cache.inet.fi"
-set http_proxy_port 800
-
-
-##########################################################################
-set html_ent [split "\n| |\r| |<br />| |&nbsp;| |&#160;| |&raquo;|>>|&quot;|\"|&auml;|ä|&ouml;|ö|&Auml;|Ä|&Ouml;|Ö|&amp;|&|&lt;|<|&gt;|>|ä|ä|ö|ö|Ä|Ä" "|"]
-
-package require http
-::http::config -urlencoding iso8859-1 -useragent "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.0) Opera 9.5"
-if {$http_proxy != 0} {
-  ::http::config -proxyhost $http_proxy_host -proxyport $http_proxy_port
-}
-
-
-proc convert_ent {udata} {
-  global html_ent
-  return [string map $html_ent $udata]
-}
-
-
-proc add_entry {uname uday udate udesc} {
-  global entries
-  set utest "$uname:$udate"
-  if {[catch {set utmp $entries($utest)}]} {
-    set entries($utest) [list $uname $uday $udate $udesc]
-  }
-}
-
-
-proc add_amica {datauri dataname} {
-  if {[catch {set utoken [::http::geturl $datauri -binary true -timeout 5000]} uerrmsg]} {
-    puts "Error getting $datauri: $uerrmsg"
-    return 1
-  }
-
-  set upage [::http::data $utoken]
-  ::http::cleanup $utoken
-
-  set nmatches 1
-  while {$nmatches > 0} {
-    set umatches [regexp -nocase -inline -- "<strong>(Maanantai|Tiistai|Keskiviikko|Torstai|Perjantai|Lauantai|Sunnuntai)</strong></td>.?.?<td colspan=\"2\"><strong>(\[^<\]+)</strong></td>(.*)\$" $upage]
-    set nmatches [llength $umatches]
-    if {$nmatches > 3} {
-      set umat [regexp -nocase -inline -- "^(.+?)(<td colspan=\"3\">|</tbody>)" [lindex $umatches 3]]
-      set umat [regexp -all -nocase -inline -- "<td colspan=\"\[78\]\">(.\*\?)</td>" [lindex $umat 1]]
-      set tmp ""
-      foreach {ukey udata} $umat {
-        set item [string trim [convert_ent $udata]]
-        if {[string length $item] > 0} {
-          lappend tmp $item
-        }
-      }
-      add_entry $dataname [lindex $umatches 1] [lindex $umatches 2] [join $tmp "; "]
-    }
-    set upage [lindex $umatches 3]
-  }
-
-  return 0
-}
-
-proc add_uniresta {datauri dataname} {
-  if {[catch {set utoken [::http::geturl $datauri -binary true -timeout 5000]} uerrmsg]} {
-    puts "Error getting $datauri: $uerrmsg"
-    return 1
-  }
-
-  set upage [::http::data $utoken]
-  ::http::cleanup $utoken
-
-  set nmatches 1
-  while {$nmatches > 0} {
-#    set umatches [regexp -nocase -inline -- "<span class='otsikko'><b>(Maanantai|Tiistai|Keskiviikko|Torstai|Perjantai|Lauantai|Sunnuntai) \[0-9\]+\.\[0-9\]+</b></span><P>(\[^<\]+)</span>(.*)\$" $upage]
-    set umatches [regexp -nocase -inline -- "<span class='otsikko'><b>(Maanantai|Tiistai|Keskiviikko|Torstai|Perjantai|Lauantai|Sunnuntai) +\[0-9\]+\.\[0-9\]+</b></span>(.*?)</span>(.*)$" $upage]
-    set nmatches [llength $umatches]
-    puts "[lindex $umatches 1]"
-    if {$nmatches > 3} {
-#      set umat [regexp -nocase -inline -- "^(.+?)<br>" [lindex $umatches 3]]
-      set umat [regexp -all -nocase -inline -- "(.\*\?)<br>" [lindex $umatches 2]]
-      set tmp ""
-      foreach {ukey udata} $umat {
-        set item [string trim [convert_ent $udata]]
-        if {[string length $item] > 0} {
-          lappend tmp $item
-        }
-      }
-      add_entry $dataname [lindex $umatches 1] [lindex $umatches 2] [join $tmp "; "]
-    }
-    set upage [lindex $umatches 3]
-  }
-
-  return 0
-}
-
-
-##########################################################################
-set kello [clock seconds]
-set viikko [expr [clock format $kello -format "%W"] + 1]
-set vuosi [clock format $kello -format "%Y"]
-
-# Amica/OAMK tekniikan yksikkö
-add_amica "http://www.amica.fi/kotkanpoika" "OAMK"
-
-# Oulun yliopiston Unirestat
-set str "http://www.uniresta.fi/2010/ruokalista_tulostettava.php?viikko=$viikko&vuosi=$vuosi&ravintola"
-
-add_uniresta "$str=2"  "Aularavintola"
-add_uniresta "$str=3"  "Discus"
-add_uniresta "$str=4"  "Julinia"
-add_uniresta "$str=5"  "Kastari"
-add_uniresta "$str=6"  "Snellmania"
-add_uniresta "$str=7"  "Pruxis"
-add_uniresta "$str=10" "Vanilla"
-add_uniresta "$str=11" "Minttu"
-
-
-##########################################################################
-### Open result datafile and save data
-set tmpfname "$datafile.tmp"
-if {[catch {set outfile [open $tmpfname w 0600]} uerrmsg]} {
-  puts "Error opening $tmpfname for writing: $uerrmsg"
-  return 1
-}
-
-foreach {ukey udata} [array get entries] {
-  puts $outfile [join $udata "½"]
-}
-
-close $outfile
-if {[catch {file rename -force -- $tmpfname $datafile} uerrmsg]} {
-  puts "Error renaming $tmpfname to $datafile: $uerrmsg"
-}
--- a/ruoka.tcl	Wed Feb 17 10:29:41 2021 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,212 +0,0 @@
-##########################################################################
-#
-# RuokaLista v1.1 by Matti 'ccr' Hamalainen <ccr@tnsp.org>
-# (C) Copyright 2004-2010 Tecnic Software productions (TNSP)
-#
-# Requires hae_ruoka.tcl to be run as a cronjob, for example
-# 15 * * * *     /absolute/path/to/hae_ruoka.tcl
-#
-# This script is freely distributable under GNU GPL (version 2) license.
-#
-##########################################################################
-
-# Vakioravintola, jos muuta ei annettu/asetettu
-set ruoka_restaurant "OAMK"
-
-# Datatiedosto, oltava sama kuin hae_ruoka.tcl:n vastaava asetus
-set ruoka_datafile "/home/niinuska/bot/data.ruoka"
-
-# Kellonaika, jolloin default-päivä vaihtuu seuraavaksi vuorokaudeksi
-# -1 = Ei vaihdeta
-# esim. 15 = klo 15 jälkeen näytetään vakiona seuraavan päivän ruokalista
-set ruoka_threshold 15
-
-# Yleiset asetukset
-set ruoka_log_enable 1
-set ruoka_preferredmsg "PRIVMSG"
-
-
-##########################################################################
-# No need to look below this line
-##########################################################################
-set ruoka_name "RuokaLista"
-set ruoka_version "1.1"
-
-### Binding initializations
-bind pub - !ruoka ruoka_get_pub
-bind msg - !ruoka ruoka_get_msg
-bind pub - !ruokaset ruoka_set_pub
-
-### Initialization messages
-set ruoka_message "$ruoka_name v$ruoka_version by ccr/TNSP"
-putlog "$ruoka_message"
-
-set ruoka_days {Sunnuntai Maanantai Tiistai Keskiviikko Torstai Perjantai Lauantai}
-
-#-------------------------------------------------------------------------
-proc ruoka_log {arg} {
-  global ruoka_log_enable ruoka_name
-  if {$ruoka_log_enable != 0} {
-    putlog "$ruoka_name: $arg"
-  }
-}
-
-
-proc ruoka_msg {apublic anick achan amsg} {
-  global ruoka_preferredmsg
-  if {$apublic == 1} {
-    putserv "$ruoka_preferredmsg $achan :$amsg"
-  } else {
-    putserv "$ruoka_preferredmsg $anick :$amsg"
-  }
-}
-
-
-proc ruoka_get_restaurants {urestaurants} {
-  global ruoka_datafile
-  upvar $urestaurants restaurants
-
-  if {![catch {set ufile [open "$ruoka_datafile" r 0600]} uerrmsg]} {
-    while {![eof $ufile]} {
-      gets $ufile uline
-      set urec [split $uline "½"]
-      if {[llength $urec] == 4} {
-        set restaurants([lindex $urec 0]) 1
-      }
-    }
-  }
-}
-
-
-proc ruoka_match_day {umatch} {
-  global ruoka_days
-  if {$umatch == "" || $umatch == "{}"} { return "" }
-  set udate ""
-  foreach i $ruoka_days {
-    if {[string match "$umatch*" [string tolower $i]]} { set udate $i }
-  }
-  return $udate
-}
-
-
-proc ruoka_match_restaurant {urestaurants umatch} {
-  upvar $urestaurants restaurants
-  if {$umatch == "" || $umatch == "{}"} { return "" }
-  foreach {nimi arvo} [array get restaurants] {
-    if {[string match "$umatch*" [string tolower $nimi]]} {
-      return $nimi
-    }
-  }
-  return ""
-}
-
-
-#-------------------------------------------------------------------------
-proc ruoka_get {unick uhand uchan uargs upublic} {
-  global ruoka_restaurant ruoka_datafile ruoka_days ruoka_threshold
-
-  # Get list of restaurants
-  ruoka_get_restaurants restaurants
-
-  # Check and handle arguments
-  set ulist [split [string tolower $uargs] " "]
-  set rarg1 [lindex $ulist 0]
-  set rarg2 [lindex $ulist 1]
-
-  if {$rarg1 == "?" || $rarg1 == "help"} {
-    set tmp [join [array names restaurants] ", "]
-    ruoka_msg $upublic $unick $uchan "Käyttö: <!>ruoka \[ravintola\] \[päivä\]"
-    ruoka_msg $upublic $unick $uchan "Huom! Jos päivää ei anneta, tiedot haetaan tältä päivältä."
-    ruoka_msg $upublic $unick $uchan "Käyttö: <!>ruokaset <ravintola>"
-    ruoka_msg $upublic $unick $uchan "Jossa ravintola on yksi seuraavista: $tmp"
-    return 0
-  }
-
-  # Try to parse arguments, if any
-  set urestaurant ""
-  set udate ""
-  if {$rarg1 != ""} {
-    set udate [ruoka_match_day $rarg1]
-    if {$udate == ""} {
-      set udate [ruoka_match_day $rarg2]
-      set urestaurant [ruoka_match_restaurant restaurants $rarg1]
-    } else {
-      set urestaurant [ruoka_match_restaurant restaurants $rarg2]
-    }
-  }
-
-  # Default date to today
-  if {$udate == ""} {
-    set sstamp [unixtime]
-
-    # Check if threshold setting is active and act accordingly
-    if {$ruoka_threshold > 0 && [clock format $sstamp -format "%H"] > $ruoka_threshold} {
-      set sstamp [expr $sstamp + 60*60*(24 - $ruoka_threshold)+30]
-    }
-
-    set udate [lindex $ruoka_days [clock format $sstamp -format "%w"]]
-  }
-
-  # If no restaurant given, try to get one from user settings
-  if {$urestaurant == ""} {
-    set urestaurant [getuser $uhand XTRA "restaurant"]
-    # If still no known/set restaurant, use global default
-    if {$urestaurant == ""} {
-      set urestaurant $ruoka_restaurant
-    }
-  }
-
-  # Read datafile
-  if {![catch {set ufile [open "$ruoka_datafile" r 0600]} uerrmsg]} {
-    set found 0
-    while {![eof $ufile]} {
-      gets $ufile uline
-      set urec [split $uline "½"]
-      if {[llength $urec] == 4 && [lindex $urec 1] == $udate && [lindex $urec 0] == $urestaurant} {
-        ruoka_msg $upublic $unick $uchan "\002[lindex $urec 0]\002, [lindex $urec 1] \002[lindex $urec 2]\002: [lindex $urec 3]"
-        set found 1
-        break
-      }
-    }
-    close $ufile
-    if {$found == 0} {
-      ruoka_msg $upublic $unick $uchan "Ei tietoja ($udate, $urestaurant)"
-    }
-  } else {
-    ruoka_log "Could not open datafile: $uerrmsg"
-  }
-}
-
-
-
-#-------------------------------------------------------------------------
-proc ruoka_get_pub {unick uhost uhand uchan uargs} {
-  ruoka_get $unick $uhand $uchan $uargs 1
-  return 0
-}
-
-#-------------------------------------------------------------------------
-proc ruoka_get_msg {unick uhost uhand uargs} {
-  ruoka_get $unick $uhand "PRIV" $uargs 0
-  return 0
-}
-
-#-------------------------------------------------------------------------
-proc ruoka_set_pub {unick uhost uhand uchan uargs} {
-  array unset restaurants
-  ruoka_get_restaurants restaurants
-  set rav ""
-  if {$uargs != "{}" && $uargs != ""} {
-    set rav [ruoka_match_restaurant restaurants $uargs]
-  }
-  if {$rav != ""} {
-    ruoka_msg 1 $unick $uchan "Vakioravintolaksi asetettu: $rav"
-    setuser $uhand XTRA "restaurant" "$rav"
-  } else {
-    set tmp [join [array names restaurants] ", "]
-    ruoka_msg 1 $unick $uchan "Ravintolan oltava yksi seuraavista: $tmp"
-  }
-  return 0
-}
-
-# end of script