Exemple #1
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('ilb_test')

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:
  imageconf = yaml.load(open('imagelist.yaml'))
  shutil.copy('imagelist.yaml','imagelist.%d.yaml' % (time.time()))
Exemple #2
0
from joelbot import JoelBot
import traceback
from time import sleep
import sys

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 KeyboardInterrupt:
    bot.log("Shutting down...")
    sys.exit("Keyboard interrupt, shutting down...")
  except Exception, e:
    print traceback.format_exc()
    sleep(5)
Exemple #3
0
    if (last_cleaned and last_cleaned >
        (time.time() - bot.config['bot']['cleanup_time'])):
        return

    last_cleaned = time.time()
    return bot.cleanup()


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

global bot
global last_cleaned
global imagemap

bot = JoelBot('ilb_test')
last_cleaned = 0

signal.signal(signal.SIGHUP, signal_handler)

#Load image map
imageconf = yaml.load(open('imagelist.yaml'))
imagemap = load_imagelist(imageconf)

markdown = print_imagelist(imageconf)

shutil.copy('imagelist.md', 'imagelist.previous.md')
mdf = open('imagelist.md', 'w')
mdf.write(markdown)
mdf.close()
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
Exemple #5
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)
from joelbot import JoelBot
import traceback
from time import sleep
import sys

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 KeyboardInterrupt:
    bot.log("Shutting down...")
    sys.exit("Keyboard interrupt, shutting down...")
  except Exception, e:
    print traceback.format_exc()
    sleep(5)
Exemple #7
0
def cleanup():
  global last_cleaned

  if(last_cleaned and last_cleaned > (time.time() - bot.config['bot']['cleanup_time'])):
    return

  last_cleaned = time.time()
  return bot.cleanup()

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

global bot
global last_cleaned
global imagemap

bot = JoelBot('ilb_test')
last_cleaned = 0

signal.signal(signal.SIGHUP,signal_handler)

#Load image map
imageconf = yaml.load(open('imagelist.yaml'))
imagemap = load_imagelist(imageconf)

markdown = print_imagelist(imageconf)

shutil.copy('imagelist.md','imagelist.previous.md')
mdf = open('imagelist.md','w')
mdf.write(markdown)
mdf.close()
Exemple #8
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)
Exemple #9
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: