changeset 265:908edc54005a

feeds: Move configuration to separate file.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 23 Jan 2015 10:15:38 +0200
parents d2f65cd528c6
children 8f5daf6631d9
files config.feeds.example feeds.tcl fetch_feeds.tcl
diffstat 3 files changed, 71 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config.feeds.example	Fri Jan 23 10:15:38 2015 +0200
@@ -0,0 +1,44 @@
+##########################################################################
+##########################################################################
+
+# SQLite3 database
+set feeds_dbfile "/home/niinuska/bot/feeds.sqlite"
+
+
+# How often to check for newly added feed items from the database?
+# (in minutes) This has nothing to do how often the backend script
+# is run and actually scans / pulls the feeds, that is done in CRON.
+# See get_feeds.tcl for more information.
+set feeds_check_period 5
+
+
+# Set channels and feed filters here:
+# "#channel" "feedname|feedname2"
+# feednames can use matching, e.g. "mtv3*" would match all beginning with "mtv3"
+array set feeds_channels {
+  "#mazmlame" "the adventurers|oots|mestari|blastwave"
+  "#fireball" "mestari"
+  "#tnsp" "the adventurers|oots|mestari"
+}
+
+
+set feeds_preferredmsg "PRIVMSG"
+
+
+###
+### HTTP options
+###
+# Set to 1 if you want to enable use of HTTP proxy.
+# If you do, you MUST set the proxy settings below too.
+set http_use_proxy 0
+
+# Proxy host and port number (only used if enabled above)
+set http_proxy_host ""
+set http_proxy_port 8080
+
+# Enable TLS/SSL support. You need to set http_tls_cadir.
+set http_tls_support 1
+set http_tls_cadir "/usr/share/ca-certificates/mozilla"
+
+# Set 'user agent' string for HTTP. If empty or not set, default will be used.
+#set http_user_agent "Mozilla"
--- a/feeds.tcl	Fri Jan 23 10:07:15 2015 +0200
+++ b/feeds.tcl	Fri Jan 23 10:15:38 2015 +0200
@@ -1,10 +1,10 @@
 ##########################################################################
 #
-# FeedCheck v0.8 by Matti 'ccr' Hamalainen <ccr@tnsp.org>
-# (C) Copyright 2008-2013 Tecnic Software productions (TNSP)
+# FeedCheck v0.9 by Matti 'ccr' Hamalainen <ccr@tnsp.org>
+# (C) Copyright 2008-2015 Tecnic Software productions (TNSP)
 #
-# Requires get_feeds.tcl to be run as a cronjob, for example
-# 15 * * * *     /absolute/path/to/get_feeds.tcl
+# Requires fetch_feeds.tcl to be run as a cronjob, for example
+# 15 * * * *     /absolute/path/to/fetch_feeds.tcl
 #
 # See also create_feeds_db.tcl OR convert_feeds_db.tcl, as you will
 # need to either create a SQLite3 database or convert old text flat
@@ -14,33 +14,17 @@
 #
 ##########################################################################
 
-# SQLite3 database, MUST be set to same as in feeds.tcl
-set feeds_dbfile "/home/niinuska/bot/feeds.sqlite"
-
-# How often to check for newly added feed items from the database?
-# (in minutes) This has nothing to do how often the backend script
-# is run and actually scans / pulls the feeds, that is done in CRON.
-# See get_feeds.tcl for more information.
-set feeds_check_period 5
-
-# Set channels and feed filters here:
-# "#channel" "feedname|feedname2"
-# feednames can use matching, e.g. "mtv3*" would match all beginning with "mtv3"
-array set feeds_channels {
-  "#mazmlame" "the adventurers|oots|mestari|blastwave"
-  "#fireball" "mestari"
-  "#tnsp" "the adventurers|oots|mestari"
-}
-
-
-set feeds_preferredmsg "PRIVMSG"
+### The configuration should be in config.feeds in same directory
+### as this script. Or change the line below to point where ever
+### you wish. See "config.feeds.example" for an example config file.
+source [file dirname [info script]]/config.feeds
 
 
 ##########################################################################
 # No need to look below this line
 ##########################################################################
 set feeds_name "FeedCheck"
-set feeds_message "$feeds_name v0.8 by ccr/TNSP"
+set feeds_message "$feeds_name v0.9 by ccr/TNSP"
 
 putlog "$feeds_message"
 bind pub - !feeds feeds_pubfetch
--- a/fetch_feeds.tcl	Fri Jan 23 10:07:15 2015 +0200
+++ b/fetch_feeds.tcl	Fri Jan 23 10:15:38 2015 +0200
@@ -4,24 +4,19 @@
 #
 ##########################################################################
 #
-# FeedCheck fetcher v0.8 by Matti 'ccr' Hamalainen <ccr@tnsp.org>
-# (C) Copyright 2008-2013 Tecnic Software productions (TNSP) 
+# FeedCheck fetcher v0.9 by Matti 'ccr' Hamalainen <ccr@tnsp.org>
+# (C) Copyright 2008-2015 Tecnic Software productions (TNSP) 
 #
 # This script is freely distributable under GNU GPL (version 2) license.
 #
 ##########################################################################
 package require sqlite3
-source [file dirname [info script]]/util_convert.tcl
-
-# SQLite3 database, MUST be set to same as in feeds.tcl
-set feeds_dbfile "/home/niinuska/bot/feeds.sqlite"
+source [file dirname [info script]]/utillib.tcl
 
-# Use a HTTP proxy? 1 = yes, 0 = no
-set http_proxy 0
-
-# HTTP proxy address and port
-set http_proxy_host "cache.inet.fi"
-set http_proxy_port 800
+### The configuration should be in config.feeds in same directory
+### as this script. Or change the line below to point where ever
+### you wish. See "config.feeds.example" for an example config file.
+source [file dirname [info script]]/config.feeds
 
 
 ##########################################################################
@@ -36,11 +31,20 @@
 set html_ent [split [encoding convertfrom "utf-8" $feeds_ent_str] "|"]
 
 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} {
+if {[info exists http_user_agent] && $http_user_agent != ""} {
+  ::http::config -urlencoding iso8859-1 -useragent $http_user_agent
+} else {
+  ::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_use_proxy != 0} {
   ::http::config -proxyhost $http_proxy_host -proxyport $http_proxy_port
 }
 
+if {$http_tls_support != 0} {
+  package require tls
+  ::http::register https 443 [list ::tls::socket -request 1 -require 1 -tls1 1 -cadir $http_tls_cadir]
+}
+
 
 proc convert_ent {udata} {
   global html_ent