Permalink
Browse files

Added language support

git-svn-id: http://svn.blisted.org/awkbot/trunk@218 ebfa9934-6f10-0410-9599-894cdf3d53f0
  • Loading branch information...
1 parent f613f35 commit b308dd2e65ac664913f66f7dd6aea6c9ab86d8af scott committed Apr 10, 2011
Showing with 66 additions and 27 deletions.
  1. +7 −0 awkbot.sql
  2. +0 −2 bin/awkbot
  3. +6 −6 etc/awkbot.conf
  4. +15 −1 htdocs/index.xhtml
  5. +15 −4 src/awkbot.awk
  6. +2 −2 src/awkbot_db_mysql.awk
  7. +5 −4 src/awkpaste.awk
  8. +13 −6 src/config.awk
  9. +3 −2 src/mysql.awk
View
@@ -45,6 +45,13 @@ INSERT INTO `qna` VALUES ('mysql_quote','something tag really needs to add to my
INSERT INTO `qna` VALUES ('xmb','the guy with incompatible libraries');
INSERT INTO `qna` VALUES ('mysql.awk','http://www.blisted.org/svn/modules/mysql.awk/ until tag writes documentation');
+CREATE TABLE `paste` (
+ paste_id int(11),
+ nick varchar(20) not null,
+ subject varchar(80) not null,
+ language varchar(15) not null default 'awk',
+ content text
+) TYPE=MyISAM;
CREATE TABLE `status` (
`running` boolean not null default false,
View
@@ -13,8 +13,6 @@ then echo "Generated script ($bootstrap) exited prematurely, please inspect"
exit 1
fi
-echo "using $livedata"
-
# Done with this one
rm $bootstrap
View
@@ -1,16 +1,16 @@
-
+debug 1
# IRC Stuff
<irc>
- nickname awkbot
- altnick awkbot-
- username awkbot
- realname AWK IRC bot
+ nickname awktest
+ altnick awktest-
+ username awktest
+ realname AWK IRC bot: Testing
# server irc.isprime.com:6667
server irc.freenode.net:6667
# port 6667
# channel awk perl pike
# channel c++
- channel awk #leapfrog
+ channel awk
# channel blacksun
debug 1
startup PRIVMSG NickServ :identify darwin
View
@@ -20,8 +20,22 @@ label {
<label for="description">Description</label>
<input type="text" name="description" size="80"/>
</div>
+ <div>
+ <label for="language">Language</label>
+ <select name="language">
+ <option value="awk">AWK</option>
+ <option value="java">Java</option>
+ <option value="javascript">JavaScript</option>
+ <option value="c">C</option>
+ <option value="c++">C++</option>
+ <option value="perl">Perl</option>
+ <option value="pike">Pike</option>
+ <option value="bash">Bash</option>
+ <option value="d">D</option>
+ </select>
+ </div>
<div>
- <label for="paste">Content</label>
+ <label for="content">Content</label>
<textarea name="content" rows="40" cols="80"></textarea>
</div>
<div>
View
@@ -74,9 +74,19 @@ function reconnect () {
}
# When the connection gets closed, restart the conversation...
-#/^Terminated/ || /^Connection closed/ {
-# reconnect()
-#}
+/^Terminated/ || /^Connection closed/ {
+ reconnect()
+}
+
+$1 == "quit" {
+ _msg = $2
+
+ for (i = 3; i <= NF; i++) {
+ _msg = _msg " " $i
+ }
+
+ irc_quit(_msg)
+}
# TODO [20091211 18:14] Is this still necessary?
# Nasty hack to clean up every few records
@@ -86,7 +96,8 @@ NR % 10000 == 0 {
fflush(irc["tempfile"])
close(irc["tempfile"])
}
-$1 == "say" {
+
+$1 == "say" {
_msg = $3
for (i = 4; i <= NF; i++) {
_msg = _msg " " $i
View
@@ -133,8 +133,8 @@ function awkbot_db_paste_add (nick, description, content) {
}
function awkbot_db_paste_get (id,row ,rv,result) {
- rv = mysql_query("SELECT paste_id, nick, subject, content FROM paste " \
- "WHERE paste_id = " mysql_quote(id))
+ rv = mysql_query("SELECT paste_id, nick, subject, language, content " \
+ "FROM paste WHERE paste_id = " mysql_quote(id))
result = mysql_fetch_assoc(rv, row)
mysql_finish(rv)
View
@@ -13,10 +13,11 @@ BEGIN {
if (query["id"]) {
if (awkbot_db_paste_get(query["id"], paste)) {
- id = query["id"]
- nick = paste["nick"]
- subject = paste["subject"]
- content = paste["content"]
+ id = query["id"]
+ nick = paste["nick"]
+ subject = paste["subject"]
+ language = paste["language"]
+ content = paste["content"]
link = sprintf("%s?id=%d", config("paste.cgi"), id)
# This should be dealt with in mysql.awk
View
@@ -22,8 +22,8 @@ function config_parse (config_data,level,filename ,l,t,s,current,closing) {
sub(/^[\t ]*#.*$/, "")
if (config_data["debug"]) {
- printf "read:%s:%d %s\n", filename, NR, $0
- print "Current namespace", level
+ printf "read:%s:%d %s\n", filename, NR, $0 > "/dev/stderr"
+ print "Current namespace", level > "/dev/stderr"
}
if (/<[^\/][^>]*>/) {
@@ -32,7 +32,7 @@ function config_parse (config_data,level,filename ,l,t,s,current,closing) {
s = substr($0, RSTART + 1, RLENGTH - 2)
- if (config_data["debug"]) print "Opening: ", s
+ if (config_data["debug"]) print "Opening: ", s > "/dev/stderr"
if (level) config_parse(config_data, level SUBSEP s, filename)
else config_parse(config_data, s, filename)
}
@@ -46,7 +46,9 @@ function config_parse (config_data,level,filename ,l,t,s,current,closing) {
t = split(s, l, SUBSEP)
current = l[t]
- if (config_data["debug"]) print "Open", current, "close", closing
+ if (config_data["debug"])
+ print "Open", current, "close", closing > "/dev/stderr"
+
assert((current == closing), "Inconsistent open/close tags")
return
}
@@ -56,7 +58,9 @@ function config_parse (config_data,level,filename ,l,t,s,current,closing) {
# Using split rather than 3 argument match, for mawk.
split($0, l, /[ ][ ]*/)
- if (config_data["debug"]) print level SUBSEP l[1], "=", l[2]
+ if (config_data["debug"])
+ print level SUBSEP l[1], "=", l[2] > "/dev/stderr"
+
if (level) config_data[level, l[1]] = l[2]
else config_data[l[1]] = l[2]
}
@@ -72,7 +76,10 @@ function config (item, value ,element) {
gsub(/\./, SUBSEP, element)
if (value) _config[element] = value
- if (_config["debug"]) print "config():", item, "(" element ")", value
+
+ if (_config["debug"])
+ print "config():", item, "(" element ")", value > "/dev/stderr"
+
# We should just treat undefined stuff as undefined *shrug*
# assert(_config[element], "config(): " element " is of no value")
return _config[element]
View
@@ -35,8 +35,9 @@ function mysql_tempfile_command (command) {
function mysql_login (username, password, host, args) {
mysql["user"] = "-u" username
mysql["pass"] = "-p" password
- if (host) mysql["host"] = "-h" host
- if (args) mysql["args"] = args
+
+ if (host) mysql["host"] = "-h" host
+ if (args) mysql["args"] = args
}
function mysql_query (query ,input,key,i,call,resource) {

0 comments on commit b308dd2

Please sign in to comment.