; Basic AI Database Setup
on *:connect: {
; If the database exists, skip this, otherwise, we must create it.
if ($exists($scriptdir\impulse.db)) { set %validated Yes | halt }
var %bot.home = $?="What location will the bot run on? (Example: irc.dal.net)"
var %bot.chan = $?="What is the name of the channel this bot will service? (Example: #bot)"
var %bot.boss = $?="Enter the owner's nickname:"
set %bot.base $sqlite_open($scriptdir\impulse.db)
; If the database path is valid, continue.
if (%bot.base) { echo -a Database is now created and initalized. }
; If the table "BotInfo" doesn't exist, create it and the proper fields.
sqlite_exec %bot.base CREATE TABLE IF NOT EXISTS BotInfo (ID INTEGER PRIMARY KEY AUTOINCREMENT, Owner UNIQUE, OwnerIP, OwnerIPMask, BotServer, BotChannel)
; Get the owner IP address.
.dns $me
var %sql = INSERT INTO BotInfo (Owner, OwnerIP, OwnerIPMask, BotServer, BotChannel) VALUES ( $sqlite_qt($me) , $sqlite_qt(%dns.ip) , $sqlite_qt(%dns.mask) , $sqlite_qt(%bot.home) , $sqlite_qt(%bot.chan) )
if ($sqlite_errno != $SQLITE_OK) {
echo -a Error #: $+ %sqlite_errstr - Error with Query
}
else {
halt
}
if ($sqlite_exec(%bot.base, %sql)) {
echo -a Query Parsed | unset %dns.*
}
else {
halt | echo -a Error #: $+ %sqlite_errstr - Error with Query
}
:skip
halt
}
alias add.move {
set %new.move.detect $1-
set %new.move.freq $?="How much will the bot use it? (From 1 to 10)"
sqlite_exec %bot.base CREATE TABLE IF NOT EXISTS BotMoves (ID INTEGER PRIMARY KEY AUTOINCREMENT, Move UNIQUE, Freq)
var %sql = INSERT INTO BotMoves (Move, Freq) VALUES ( $sqlite_qt($1-) , $sqlite_qt( %new.move.freq ))
if ($sqlite_exec(%bot.base, %sql)) {
echo -a Query Parsed | unset %new.*
}
else {
echo -a Error #: $+ %sqlite_errstr - Error with Query
halt
}
}