From 6d11929e54aa0607bc20b1252b81cef17d3e489f Mon Sep 17 00:00:00 2001 From: urlbot Date: Fri, 3 Oct 2014 19:18:52 +0200 Subject: [PATCH] re-add image_preview; configurable --- local_config.py.skel | 2 ++ urlbot.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/local_config.py.skel b/local_config.py.skel index 6774ad2..77f57f1 100644 --- a/local_config.py.skel +++ b/local_config.py.skel @@ -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] diff --git a/urlbot.py b/urlbot.py index acbc0e1..9a3b1fa 100755 --- a/urlbot.py +++ b/urlbot.py @@ -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,8 +149,15 @@ 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: - logger('info', 'no message sent for non-text %s (%s)' %(r, title)) - continue + 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: message = 'No title: %s' % r elif 3 == status: