re-add image_preview; configurable

This commit is contained in:
urlbot
2014-10-03 19:18:52 +02:00
parent 6ce9e177de
commit 6d11929e54
2 changed files with 12 additions and 3 deletions

View File

@@ -31,6 +31,8 @@ config['enhanced-random-user'] = ( 'FIXME', 'FIXME' )
config['tea_steep_time'] = (3*60 + 40)
config['image_preview'] = True
def conf(val):
if val in list(config.keys()):
return config[val]

View File

@@ -1,7 +1,7 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys, os, stat, re, time, pickle
import sys, os, stat, re, time, pickle, random
import urllib.request, urllib.parse, urllib.error, html.parser
from local_config import conf, set_conf
from common import *
@@ -149,6 +149,13 @@ def extract_url(data):
lev_str = 'lev=%d/%d:%d ' %(lev_res, len(title), len(lev_url))
message = lev_str + 'Title: %s: %s' %(title, r)
elif 1 == status:
if conf('image_preview'):
# of course it's fake, but it looks interesting at least
char = """,._-+=\|/*`~"'"""
message = 'No text but %s, 1-bit ASCII art preview: [%c] %s' %(
title, random.choice(char), r
)
else:
logger('info', 'no message sent for non-text %s (%s)' %(r, title))
continue
elif 2 == status: