Changeset 6


Ignore:
Timestamp:
04/30/06 16:45:44 (6 years ago)
Author:
james
Message:

use ping to make sure we're connected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • QuoteEngine/QuoteEngine.tcl

    r1 r6  
    6060 
    6161################################################################################ 
     62# quote_ping 
     63# Check we're still connected to mysql 
     64################################################################################ 
     65proc quote_ping { } { 
     66        global db_handle 
     67 
     68        if [::mysql::ping $dbhandle] { 
     69                return 0 
     70        } else { 
     71                return 1 
     72        } 
     73} 
     74 
     75################################################################################ 
    6276# quote_add 
    6377# !addquote <text> 
     
    7690    set handle $nick 
    7791  } 
     92 
     93        if {![quote_ping]} { 
     94                putquick "PRIVMSG $channel :Sorry, lost database connection :(" 
     95                return 0 
     96        } 
    7897 
    7998  set sql "INSERT INTO quotes VALUES(null, " 
     
    114133  if [matchattr $handle $quote_noflags] { return 0 } 
    115134 
     135        if {![quote_ping]} { 
     136                putquick "PRIVMSG $channel :Sorry, lost database connection :(" 
     137                return 0 
     138        } 
     139 
    116140  set where_clause "WHERE channel='$channel'" 
    117141  if [regexp -- "--?all" $text] { 
     
    160184    return 0 
    161185  } 
     186 
     187        if {![quote_ping]} { 
     188                putquick "PRIVMSG $channel :Sorry, lost database connection :(" 
     189                return 0 
     190        } 
    162191 
    163192        set text [mysqlescape $text] 
     
    215244    return 0 
    216245  } 
     246 
     247        if {![quote_ping]} { 
     248                putquick "PRIVMSG $channel :Sorry, lost database connection :(" 
     249                return 0 
     250        } 
    217251 
    218252  set where_clause "AND channel='[mysqlescape $channel]'" 
     
    320354  if [matchattr $handle $quote_noflags] { return 0 } 
    321355 
     356        if {![quote_ping]} { 
     357                putquick "PRIVMSG $channel :Sorry, lost database connection :(" 
     358                return 0 
     359        } 
     360 
    322361  set sql "SELECT COUNT(*) AS total FROM quotes WHERE channel='$channel'" 
    323362  putloglev d * "QuoteEngine: executing $sql" 
     
    373412 
    374413  if [matchattr $handle $quote_noflags] { return 0 } 
     414 
     415        if {![quote_ping]} { 
     416                putquick "PRIVMSG $channel :Sorry, lost database connection :(" 
     417                return 0 
     418        } 
    375419 
    376420  set text [mysqlescape $text] 
Note: See TracChangeset for help on using the changeset viewer.