Changeset 46


Ignore:
Timestamp:
02/11/11 14:38:05 (16 months ago)
Author:
notopic
Message:

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

Location:
QuoteEngine
Files:
5 added
1 edited
4 moved

Legend:

Unmodified
Added
Removed
  • QuoteEngine/QuoteEngine.tcl

    r43 r46  
    1010 
    1111# load the extension 
    12 # CHANGE ME: My main bot's server has broken TCL, so I need the line below: 
    13 #load /usr/local/lib/mysqltcl-2.12/libmysqltcl2.12.so 
    14 #load /home/notopic/lib/mysqltcl-2.50/libmysqltcl2.50.so 
    15 # BUT most people should get away with this if their server's setup right: 
    1612package require mysqltcl 
    1713 
    18 # Use only one or other of the above! 
    19  
    20 # connect to database 
    21 # CHANGE ME 
    22 proc quote_connect { } { 
    23         global db_handle 
    24                  
    25         set db_handle [mysqlconnect -host localhost -user notopic -password moo -db quotes] 
    26  
    27         if {$db_handle != ""} { 
    28                 return 1 
    29         } else { 
    30                 return 0 
    31         } 
    32 } 
    33  
    34 # url to site 
    35 # CHANGE ME (use blank if you're not using the PHP script) 
    36 set php_page "http://sakaki.jamesoff.net/~notopic/" 
    37  
    38 # automatically spew "relevant" quotes? 
    39 set quote_automatic 1 
    40  
    41 # minimum number of seconds between automatic quotes 
    42 set quote_automatic_minimum [expr 3 * 3600] 
    43  
    44 # bind commands CHANGE as needed 
     14# Make sure you edit the sample settings file and save it as "QuoteEngine-settings.tcl" 
     15# in the eggdrop scripts directory! 
     16source "scripts/QuoteEngine-settings.tcl" 
     17 
     18# bind commands CHANGE as needed to set who can use 
    4519# use ".chanset #channel [+/-]quoteengine" to enable/disable individual 
    4620# channels 
     
    6034bind pubm "-|ov" * quote_auto 
    6135 
    62 # a user with this flag(s) can't use the script at all 
    63 set quote_noflags "Q|Q" 
    64  
    65 # maximum number of quotes to show in channel when searching before switching 
    66 # to /msg'ing the user 
    67 set quote_chanmax 5 
    68  
    69 # shrink multiple spaces to single spaces when fetching a quote? 
    70 set quote_shrinkspaces 1 
    71  
    72 ### code starts here (no need to edit stuff below currently) 
    73 #1.00 
    74 set quote_version "cvs" 
     36################################################################################ 
     37#No need to edit beyond this point 
     38################################################################################ 
     39 
     40set quote_version "1.3" 
    7541set quote_auto_last(blah) 0 
    7642 
     
    7844setudef flag quoteengine 
    7945 
    80 ### procedures start here 
     46# connect to database 
     47proc quote_connect { } { 
     48        global db_handle quote_db 
     49                 
     50        set db_handle [mysqlconnect -host $quote_db(host) -user $quote_db(user) -password $quote_db(password) -db $quote_db(database)] 
     51 
     52        if {$db_handle != ""} { 
     53                return 1 
     54        } else { 
     55                return 0 
     56        } 
     57} 
    8158 
    8259################################################################################ 
     
    275252################################################################################ 
    276253proc quote_search { nick host handle channel text } { 
    277   global db_handle php_page quote_noflags quote_chanmax 
     254  global db_handle quote_webpage quote_noflags quote_chanmax 
    278255 
    279256  if {![channel get $channel quoteengine]} { 
     
    348325 
    349326      regsub "#" $channel "" chan 
    350       if {$php_page != ""} { 
    351         puthelp "${command}(Plus $remaining more matches: $php_page?filter=${text}&channel=${chan}&search=search)" 
     327      if {$quote_webpage != ""} { 
     328        puthelp "${command}(Plus $remaining more matches: $quote_webpage?filter=${text}&channel=${chan}&search=search)" 
    352329      } else { 
    353330        puthelp "${command}Plus $remaining other matches" 
     
    377354################################################################################ 
    378355proc quote_url { nick host handle channel text } { 
    379   global php_page quote_noflags 
    380  
    381   if {![channel get $channel quoteengine]} { 
    382     return 0 
    383   } 
    384  
    385   if [matchattr $handle $quote_noflags] { return 0 } 
    386  
    387   if {$php_page != ""} { 
     356  global quote_webpage quote_noflags 
     357 
     358  if {![channel get $channel quoteengine]} { 
     359    return 0 
     360  } 
     361 
     362  if [matchattr $handle $quote_noflags] { return 0 } 
     363 
     364  if {$quote_webpage != ""} { 
    388365# changed for better url by dubkat 
    389   puthelp "PRIVMSG $channel :${php_page}?channel=[string range $channel 1 end]" 
     366  puthelp "PRIVMSG $channel :${quote_webpage}?channel=[string range $channel 1 end]" 
    390367  } else { 
    391368    puthelp "PRIVMSG $channel :Not available." 
     
    615592                } 
    616593 
    617                 putlog "RANDOM QUOTE: $quote ($id)" 
     594                putloglev d * "RANDOM QUOTE: $quote ($id)" 
    618595                puthelp "PRIVMSG $channel :\[\002$id\002\] $quote" 
    619596                set quote_auto_last($channel) [clock seconds] 
Note: See TracChangeset for help on using the changeset viewer.