re-add image_preview; configurable
This commit is contained in:
@@ -31,6 +31,8 @@ config['enhanced-random-user'] = ( 'FIXME', 'FIXME' )
|
|||||||
|
|
||||||
config['tea_steep_time'] = (3*60 + 40)
|
config['tea_steep_time'] = (3*60 + 40)
|
||||||
|
|
||||||
|
config['image_preview'] = True
|
||||||
|
|
||||||
def conf(val):
|
def conf(val):
|
||||||
if val in list(config.keys()):
|
if val in list(config.keys()):
|
||||||
return config[val]
|
return config[val]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# -*- coding: utf-8 -*-
|
# -*- 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
|
import urllib.request, urllib.parse, urllib.error, html.parser
|
||||||
from local_config import conf, set_conf
|
from local_config import conf, set_conf
|
||||||
from common import *
|
from common import *
|
||||||
@@ -149,6 +149,13 @@ def extract_url(data):
|
|||||||
lev_str = 'lev=%d/%d:%d ' %(lev_res, len(title), len(lev_url))
|
lev_str = 'lev=%d/%d:%d ' %(lev_res, len(title), len(lev_url))
|
||||||
message = lev_str + 'Title: %s: %s' %(title, r)
|
message = lev_str + 'Title: %s: %s' %(title, r)
|
||||||
elif 1 == status:
|
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))
|
logger('info', 'no message sent for non-text %s (%s)' %(r, title))
|
||||||
continue
|
continue
|
||||||
elif 2 == status:
|
elif 2 == status:
|
||||||
|
|||||||
Reference in New Issue
Block a user