Beispiel #1
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)
Beispiel #2
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 #3
0
  }
  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()))
  bot.log('Loaded imagelist from file')

imagemap = ImageMap(imageconf, bot.config['bot']['animated_extensions'], bot.config['bot']['switchable_extensions'])

markdown = imagemap.get_formatted()

# Update the image map on the wiki
Beispiel #4
0
  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:
  imageconf = yaml.load(open('imagelist.yaml'))