Explorar el Código

v1.3
Added readme, separate settings file for TCL script, SQL script, rearranged dir structure

James Seward hace 15 años
padre
commit
cce5c1d011

+ 38 - 0
QuoteEngine/QuoteEngine-settings.sample.tcl

@@ -0,0 +1,38 @@
+# Settings file for QuoteEngine
+#
+# Edit this file and save it as QuoteEngine-settings.tcl in 
+# your eggdrop's scripts/ directory
+
+# The mysql hostname to connect to
+set quote_db(host) "localhost"
+
+# The mysql account to connect as
+set quote_db(user) "bot"
+set quote_db(password) "verysecret"
+
+# The name of the database to use
+set quote_db(database) "quotes"
+
+# The URL of the webpage
+# If you're not using it, set this to ""
+set quote_webpage "http://servername/~bot/quotes/"
+
+# automatically spew "relevant" quotes?
+# Done by looking for quotes containing a word someone said in the channel
+# 1 to enable, 0 to disable
+set quote_automatic 1
+
+# minimum number of seconds between automatic quotes
+# default is 10800 (3 hours)
+set quote_automatic_minimum 10800
+
+# a user with this flag(s) can't use the script at all
+set quote_noflags "Q|Q"
+
+# maximum number of quotes to show in channel when searching before switching
+# to /msg'ing the user
+set quote_chanmax 5
+
+# shrink multiple spaces to single spaces when fetching a quote?
+# 0 to disable, 1 to enable
+set quote_shrinkspaces 1

+ 27 - 50
QuoteEngine/QuoteEngine.tcl

@@ -9,39 +9,13 @@
 ###############################################################################
 
 # load the extension
-# CHANGE ME: My main bot's server has broken TCL, so I need the line below:
-#load /usr/local/lib/mysqltcl-2.12/libmysqltcl2.12.so
-#load /home/notopic/lib/mysqltcl-2.50/libmysqltcl2.50.so
-# BUT most people should get away with this if their server's setup right:
 package require mysqltcl
 
-# Use only one or other of the above!
+# Make sure you edit the sample settings file and save it as "QuoteEngine-settings.tcl"
+# in the eggdrop scripts directory!
+source "scripts/QuoteEngine-settings.tcl"
 
-# connect to database
-# CHANGE ME
-proc quote_connect { } {
-	global db_handle
-		
-	set db_handle [mysqlconnect -host localhost -user notopic -password moo -db quotes]
-
-	if {$db_handle != ""} {
-		return 1
-	} else {
-		return 0
-	}
-}
-
-# url to site
-# CHANGE ME (use blank if you're not using the PHP script)
-set php_page "http://sakaki.jamesoff.net/~notopic/"
-
-# automatically spew "relevant" quotes?
-set quote_automatic 1
-
-# minimum number of seconds between automatic quotes
-set quote_automatic_minimum [expr 3 * 3600]
-
-# bind commands CHANGE as needed
+# bind commands CHANGE as needed to set who can use
 # use ".chanset #channel [+/-]quoteengine" to enable/disable individual
 # channels
 bind pub "m|fov" !addquote quote_add
@@ -59,25 +33,28 @@ bind pub "-|-" !quoteversion quote_version
 bind pub "-|-" !quotehelp quote_help
 bind pubm "-|ov" * quote_auto
 
-# a user with this flag(s) can't use the script at all
-set quote_noflags "Q|Q"
-
-# maximum number of quotes to show in channel when searching before switching
-# to /msg'ing the user
-set quote_chanmax 5
-
-# shrink multiple spaces to single spaces when fetching a quote?
-set quote_shrinkspaces 1
+################################################################################
+#No need to edit beyond this point
+################################################################################
 
-### code starts here (no need to edit stuff below currently)
-#1.00
-set quote_version "cvs"
+set quote_version "1.3"
 set quote_auto_last(blah) 0
 
 #add setting to channel
 setudef flag quoteengine
 
-### procedures start here
+# connect to database
+proc quote_connect { } {
+	global db_handle quote_db
+		
+	set db_handle [mysqlconnect -host $quote_db(host) -user $quote_db(user) -password $quote_db(password) -db $quote_db(database)]
+
+	if {$db_handle != ""} {
+		return 1
+	} else {
+		return 0
+	}
+}
 
 ################################################################################
 # quote_ping
@@ -274,7 +251,7 @@ proc quote_fetch { nick host handle channel text } {
 #   The script automatically puts %s around your text when searching.
 ################################################################################
 proc quote_search { nick host handle channel text } {
-  global db_handle php_page quote_noflags quote_chanmax
+  global db_handle quote_webpage quote_noflags quote_chanmax
 
   if {![channel get $channel quoteengine]} {
     return 0
@@ -347,8 +324,8 @@ proc quote_search { nick host handle channel text } {
 			}
 
       regsub "#" $channel "" chan
-      if {$php_page != ""} {
-        puthelp "${command}(Plus $remaining more matches: $php_page?filter=${text}&channel=${chan}&search=search)"
+      if {$quote_webpage != ""} {
+        puthelp "${command}(Plus $remaining more matches: $quote_webpage?filter=${text}&channel=${chan}&search=search)"
       } else {
         puthelp "${command}Plus $remaining other matches"
       }
@@ -376,7 +353,7 @@ proc quote_search { nick host handle channel text } {
 #   Gives the web of the web interface
 ################################################################################
 proc quote_url { nick host handle channel text } {
-  global php_page quote_noflags
+  global quote_webpage quote_noflags
 
   if {![channel get $channel quoteengine]} {
     return 0
@@ -384,9 +361,9 @@ proc quote_url { nick host handle channel text } {
 
   if [matchattr $handle $quote_noflags] { return 0 }
 
-  if {$php_page != ""} {
+  if {$quote_webpage != ""} {
 # changed for better url by dubkat
-  puthelp "PRIVMSG $channel :${php_page}?channel=[string range $channel 1 end]"
+  puthelp "PRIVMSG $channel :${quote_webpage}?channel=[string range $channel 1 end]"
   } else {
     puthelp "PRIVMSG $channel :Not available."
   }
@@ -614,7 +591,7 @@ proc quote_auto { nick host handle channel text } {
 			set quote [stripcodes bcruag $quote]
 		}
 
-		putlog "RANDOM QUOTE: $quote ($id)"
+		putloglev d * "RANDOM QUOTE: $quote ($id)"
 		puthelp "PRIVMSG $channel :\[\002$id\002\] $quote"
 		set quote_auto_last($channel) [clock seconds]
 	}

+ 29 - 0
QuoteEngine/README

@@ -0,0 +1,29 @@
+QuoteEngine by JamesOff
+http://jamesoff.net
+
+
+Quick start, because I can't be arsed writing a full one ;)
+
+SQL setup
+---------
+
+1. Create a user and database in your mysql server for the bot to use
+2. Populate the database using the .sql script
+
+
+TCL setup
+---------
+
+1. Install mysqltcl package
+2. Put the QuoteEngine.tcl file in your eggdrop's scripts/ directory
+3. Edit the QuoteEngine-settings.sample.tcl file and save it as
+   QuoteEngine-settings.tcl in your scripts/ directory
+4. Put "source scripts/QuoteEngine.tcl" in your bot's config file
+
+
+Webpage setup
+-------------
+
+1. Put the files in the www directory in the right place in your webserver
+2. Edit settings.sample.inc to have the right details, and rename to settings.inc
+3. Profit

+ 35 - 0
QuoteEngine/sql/quotes.sql

@@ -0,0 +1,35 @@
+-- MySQL dump 10.11
+--
+-- Host: localhost    Database: quotes
+-- ------------------------------------------------------
+-- Server version	5.0.90
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Table structure for table `quotes`
+--
+
+DROP TABLE IF EXISTS `quotes`;
+/*!40101 SET @saved_cs_client     = @@character_set_client */;
+/*!40101 SET character_set_client = utf8 */;
+CREATE TABLE `quotes` (
+  `id` bigint(20) NOT NULL auto_increment,
+  `nick` varchar(20) NOT NULL default '',
+  `host` varchar(100) NOT NULL default '',
+  `quote` text NOT NULL,
+  `channel` varchar(50) NOT NULL default '',
+  `timestamp` bigint(20) default NULL,
+  PRIMARY KEY  (`id`)
+) ENGINE=MyISAM AUTO_INCREMENT DEFAULT CHARSET=latin1;
+/*!40101 SET character_set_client = @saved_cs_client */;
+

+ 0 - 0
QuoteEngine/index.php → QuoteEngine/www/index.php


+ 0 - 0
QuoteEngine/ocean.css → QuoteEngine/www/ocean.css


+ 0 - 0
QuoteEngine/settings.example.inc → QuoteEngine/www/settings.example.inc


+ 0 - 0
QuoteEngine/styles.css → QuoteEngine/www/styles.css