import sqlite3
from joelbot import JoelBot

bot = JoelBot('ilb_test')

conn = sqlite3.connect(bot.config['bot']['dbfile'])
conn.row_factory = sqlite3.Row
conn.isolation_level = None
c = conn.cursor()
c_i = conn.cursor()

for msg in c.execute(
        '''SELECT tid FROM inbox WHERE parent_id IS NULL AND tid NOT LIKE \'t4_%\''''
):
    msgid = msg[0]
    print "Checking {}...".format(msgid)
    data = bot.r.get_info(thing_id=msgid)
    if data and data.parent_id:
        try:
            print "Updating message {} with parent id {}...".format(
                data.name, data.parent_id)
            c_i.execute('''UPDATE inbox SET parent_id=? WHERE tid=?''',
                        (data.parent_id, data.name))
            conn.commit()
        except sqlite3.OperationalError:
            pass
Beispiel #2
0
from joelbot import JoelBot
import traceback
from time import sleep
import sys
import prawcore

bot = JoelBot('all',useragent='inbox')

while True:
  try:
    bot.check_messages()
    bot.log("Sleeping for %d seconds...", bot.config['bot']['inbox_time'])
    sys.stdout.flush()
    sleep(bot.config['bot']['inbox_time'])

  except prawcore.exceptions.OAuthException:
    bot.refresh_oauth()
  except KeyboardInterrupt:
    bot.log("Shutting down...")
    sys.exit("Keyboard interrupt, shutting down...")
  except Exception, e:
    print traceback.format_exc()
    sleep(5)
Beispiel #3
0
from joelbot import JoelBot
import traceback
from time import sleep
import sys
import praw
import prawcore

bot = JoelBot('all', useragent='cleanup')

while True:
    try:
        bot.cleanup()
        bot.log("Sleeping for %d seconds...",
                bot.config['bot']['cleanup_time'])
        sleep(bot.config['bot']['cleanup_time'])

    except prawcore.exceptions.OAuthException:
        bot.refresh_oauth()
    except KeyboardInterrupt:
        bot.log("Shutting down...")
        sys.exit("Keyboard interrupt, shutting down...")
    except Exception, e:
        print traceback.format_exc()
        sleep(5)
Beispiel #4
0
  f = open('status.html', 'w')
  t_data = {
    'last_restarted': datetime.fromtimestamp(time.time()),
    'config': bot.config,
    'num_keys': imagemap.num_keys(),
    'num_images': imagemap.num_images(),
    'imagelist': imagemap.get_tuples(),
  }
  f.write(t.render(**t_data))

parser = argparse.ArgumentParser(description="Links text such as themoreyouknow.gif to actual images")

global bot
global imagemap

bot = JoelBot('all')
bot.log("\n", stderr=True)
bot.log("Starting up...", stderr=True)

signal.signal(signal.SIGHUP,signal_handler)

#Load image map, first from wiki
try:
  imageconf = bot.get_wiki_yaml('conf/imagelist')
  bot.log('Loaded imagelist from wiki')
except Exception as e:
  bot.log("Couldn't load imagelist from wiki: " + str(sys.exc_info()[0]))
  imageconf = None

# Fall back to local file
if not imageconf: