; Basic AI Database Setup on *:DNS:{ set %dns.mask $dns(0).addr | set %dns.ip $dns(0).ip } on *:connect: { ; Point to Database Path var %botdb = $sqlite_open($scriptdir\xfed.db) ; If the database exists, skip the check. if ($exists($scriptdir\Databases\xfed.db)) { noop $tip(Information,Information,Database Exists -- Loading Bot...) start } else { noop $tip(Information,Information,Database not created -- Running Configuration.) dbsetup } } alias start { var %botdb = $sqlite_open($scriptdir\xfed.db) ; Grab owner information var %sql = SELECT Owner FROM Bot var %request = $sqlite_query(%botdb, %sql) if (%request) { ; Grab 'Owner' (1) Field from the table 'Bot' and apply it to an global variable. ; Grab 'IP Address' (2) Field from the table 'Bot' and apply it to an global variable. set %xfed.owner $sqlite_fetch_field(%request, 1) set %xfed.owner $sqlite_fetch_field(%request, 2) sqlite_free %sql noop $tip(Information,Information,Welcome back %xfed.owner $+ ) } else { noop $tip(Error,Error,Error executing query... Error %sqlite_errno -- %sqlite_errstr $+ ) halt } } alias dbsetup { var %botdb = $sqlite_open($scriptdir\xfed.db) var %bot.server = $?="What server will the bot run on?" var %bot.owner = $?="Enter the nickname of who will be administrating this bot:" var %bot.channel = $?="Where will this bot run in?" var %bot.nick = $?="What will my nick be?" ; Create 'Bot' table and fill in the fields sqlite_exec %botdb CREATE TABLE IF NOT EXISTS Bot (ID INTEGER PRIMARY KEY AUTOINCREMENT, Owner UNIQUE, IPAddress, IPMask, BServer, BChannel, BNick) ; Get owner IP Address .dns %bot.owner var %sql = INSERT INTO Bot (Owner, IPAddress, IPMask, BServer, BChannel, BNick) VALUES (Me , Yes , Yes , $sqlite_qt(%bot.server) , $sqlite_qt(%bot.channel) , $sqlite_qt(%bot.nick) ) if ($sqlite_errno != $sqlite_ok) { noop $tip(Error,Error,Error %sqlite_errno -- %sqlite_errstr $+ ) } else { halt } if $sqlite_exec(%bot.base, %sql) { noop $tip(Information,Information,Query Successful $+ ) } else { noop $tip(Error,Error,Error %sqlite_errno -- %sqlite_errstr $+ ) halt } }