remove old IRC bot entirely

the porting is complete, everything i care about has been moved to the
django-based codebase, and this old junk can finally go

IT IS A NEW ERA, one of maintainability and flexible changes. after
years of procrastinating, i have finally done this. the future is now
This commit is contained in:
2015-06-19 21:50:35 -05:00
parent 8c77780923
commit 2dc2b6a8a2
11 changed files with 1 additions and 3194 deletions

View File

@@ -1,61 +0,0 @@
"""
factfiles-to-facts - insert facts from flat file to database
Copyright (C) 2010 Brian S. Stephan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import argparse
import getpass
import os
import sqlite3
import socket
import sys
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--factfile')
parser.add_argument('-c', '--category')
args = parser.parse_args()
if args.factfile == None or args.category == None:
print('script needs both -c (category) and -f (filename)')
sys.exit(2)
# database
dbfile = 'dr.botzo.data'
db = sqlite3.connect(dbfile)
# open file
if os.path.isfile(args.factfile):
with open(args.factfile, 'r') as file:
lines = file.readlines()
for line in lines:
try:
line = line.rstrip()
print('inserting \'' + line + '\'')
db.execute('''INSERT INTO facts_facts (category, fact, who, userhost)
VALUES (?,?,?,?)''', (args.category, line.decode('utf-8', 'ignore'), getpass.getuser(), getpass.getuser() + '@' + socket.getfqdn()))
except sqlite3.Error as e:
db.rollback()
print("sqlite error: " + str(e))
sys.exit(2)
db.commit()
else:
print('filename \'' + whats[0] + '\' doesn\'t exist')
# vi:tabstop=4:expandtab:autoindent
# kate: indent-mode python;indent-width 4;replace-tabs on;

View File

@@ -1,58 +0,0 @@
"""
import-file-into-markov_chain.py
Copyright (C) 2011 Brian S. Stephan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
import argparse
import os
import sqlite3
import sys
parser = argparse.ArgumentParser(description='Import lines into the specified context_id.')
parser.add_argument('context_id', metavar='CONTEXT', type=int, nargs=1)
args = parser.parse_args()
print(args.context_id[0])
db = sqlite3.connect('dr.botzo.data')
db.row_factory = sqlite3.Row
cur = db.cursor()
statement = 'INSERT INTO markov_chain (k1, k2, v, context_id) VALUES (?, ?, ?, ?)'
for line in sys.stdin:
# set up the head of the chain
w1 = '__start1'
w2 = '__start2'
# for each word pair, add the next word to the dictionary
for word in line.split():
try:
cur.execute(statement, (w1.decode('utf-8', 'replace'), w2.decode('utf-8', 'replace'), word.decode('utf-8', 'replace'), args.context_id[0]))
except sqlite3.Error as e:
db.rollback()
print("sqlite error: " + str(e))
raise
w1, w2 = w2, word
try:
cur.execute(statement, (w1.decode('utf-8', 'replace'), w2.decode('utf-8', 'replace'), '__stop', args.context_id[0]))
db.commit()
except sqlite3.Error as e:
db.rollback()
print("sqlite error: " + str(e))
raise
# vi:tabstop=4:expandtab:autoindent