|
|
@ -150,7 +150,6 @@ class PublicRelations(Bureau):
|
|
|
|
|
|
|
|
|
|
|
|
prn = self._get_small_printer()
|
|
|
|
prn = self._get_small_printer()
|
|
|
|
# TODO: abstract this to use a simple templating system instead of raw
|
|
|
|
# TODO: abstract this to use a simple templating system instead of raw
|
|
|
|
# TODO: add fancier formatting i.e. inverted text for username/handle
|
|
|
|
|
|
|
|
tweets = self.t.t.statuses.home_timeline(count=count,
|
|
|
|
tweets = self.t.t.statuses.home_timeline(count=count,
|
|
|
|
tweet_mode="extended")
|
|
|
|
tweet_mode="extended")
|
|
|
|
out = ""
|
|
|
|
out = ""
|
|
|
@ -159,6 +158,11 @@ class PublicRelations(Bureau):
|
|
|
|
username = t["user"]["name"]
|
|
|
|
username = t["user"]["name"]
|
|
|
|
prn.textln(username)
|
|
|
|
prn.textln(username)
|
|
|
|
prn.set()
|
|
|
|
prn.set()
|
|
|
|
|
|
|
|
if "retweeted_status" in t:
|
|
|
|
|
|
|
|
rt = t["retweeted_status"]
|
|
|
|
|
|
|
|
twtext = "RT from " + rt["user"]["name"] + "\n"
|
|
|
|
|
|
|
|
twtext += html.unescape(rt["full_text"])
|
|
|
|
|
|
|
|
else:
|
|
|
|
twtext = html.unescape(t["full_text"])
|
|
|
|
twtext = html.unescape(t["full_text"])
|
|
|
|
prn.block_text(twtext, font="0")
|
|
|
|
prn.block_text(twtext, font="0")
|
|
|
|
prn.ln()
|
|
|
|
prn.ln()
|
|
|
@ -178,6 +182,8 @@ class PublicRelations(Bureau):
|
|
|
|
|
|
|
|
|
|
|
|
tw_shortcode = self.short_tweet_id(t["id_str"])
|
|
|
|
tw_shortcode = self.short_tweet_id(t["id_str"])
|
|
|
|
#prn.barcode("PRtwd." + tw_shortcode, "CODE128", function_type="B")
|
|
|
|
#prn.barcode("PRtwd." + tw_shortcode, "CODE128", function_type="B")
|
|
|
|
|
|
|
|
#TODO: submit a patch to escpos to have a quiet_zone parameter
|
|
|
|
|
|
|
|
# as the default is a bit wide for 58mm printers
|
|
|
|
prn.soft_barcode("code128", "PRtwd." + tw_shortcode, module_width=0.16)
|
|
|
|
prn.soft_barcode("code128", "PRtwd." + tw_shortcode, module_width=0.16)
|
|
|
|
prn.ln(2)
|
|
|
|
prn.ln(2)
|
|
|
|
|
|
|
|
|
|
|
@ -198,6 +204,11 @@ class PublicRelations(Bureau):
|
|
|
|
username = tweet["user"]["name"]
|
|
|
|
username = tweet["user"]["name"]
|
|
|
|
prn.textln(username)
|
|
|
|
prn.textln(username)
|
|
|
|
prn.set()
|
|
|
|
prn.set()
|
|
|
|
|
|
|
|
if "retweeted_status" in tweet:
|
|
|
|
|
|
|
|
rt = tweet["retweeted_status"]
|
|
|
|
|
|
|
|
twtext = "RT from " + rt["user"]["name"] + "\n"
|
|
|
|
|
|
|
|
twtext += html.unescape(rt["full_text"])
|
|
|
|
|
|
|
|
else:
|
|
|
|
twtext = html.unescape(tweet["full_text"])
|
|
|
|
twtext = html.unescape(tweet["full_text"])
|
|
|
|
prn.block_text(twtext, font="0")
|
|
|
|
prn.block_text(twtext, font="0")
|
|
|
|
|
|
|
|
|
|
|
@ -217,13 +228,13 @@ class PublicRelations(Bureau):
|
|
|
|
tw_shortcode = self.short_tweet_id(tweet["id_str"])
|
|
|
|
tw_shortcode = self.short_tweet_id(tweet["id_str"])
|
|
|
|
prn.text("retweet\r\n")
|
|
|
|
prn.text("retweet\r\n")
|
|
|
|
#prn.barcode("PRtwrt." + tw_shortcode, "CODE128", function_type="B")
|
|
|
|
#prn.barcode("PRtwrt." + tw_shortcode, "CODE128", function_type="B")
|
|
|
|
prn.soft_barcode("code128", "PRtwrt." + tw_shortcode)
|
|
|
|
prn.soft_barcode("code128", "PRtwrt." + tw_shortcode, module_width=0.16)
|
|
|
|
prn.text("like\r\n")
|
|
|
|
prn.text("like\r\n")
|
|
|
|
#prn.barcode("PRtwlk." + tw_shortcode, "CODE128", function_type="B")
|
|
|
|
#prn.barcode("PRtwlk." + tw_shortcode, "CODE128", function_type="B")
|
|
|
|
prn.soft_barcode("code128", "PRtwlk." + tw_shortcode)
|
|
|
|
prn.soft_barcode("code128", "PRtwlk." + tw_shortcode, module_width=0.16)
|
|
|
|
prn.text("\r\n\r\n")
|
|
|
|
prn.text("\r\n\r\n")
|
|
|
|
#prn.barcode("PRtwre." + tw_shortcode, "CODE128", function_type="B")
|
|
|
|
#prn.barcode("PRtwre." + tw_shortcode, "CODE128", function_type="B")
|
|
|
|
prn.soft_barcode("code128", "PRtwre." + tw_shortcode)
|
|
|
|
prn.soft_barcode("code128", "PRtwre." + tw_shortcode, module_width=0.16)
|
|
|
|
prn.ln(2)
|
|
|
|
prn.ln(2)
|
|
|
|
prn.cut()
|
|
|
|
prn.cut()
|
|
|
|
prn.close()
|
|
|
|
prn.close()
|
|
|
@ -298,7 +309,6 @@ class PublicRelations(Bureau):
|
|
|
|
count = 10
|
|
|
|
count = 10
|
|
|
|
|
|
|
|
|
|
|
|
prn = self._get_small_printer()
|
|
|
|
prn = self._get_small_printer()
|
|
|
|
prn.codepage = "cp437"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: add fancier formatting i.e. inverted text for username/handle
|
|
|
|
# TODO: add fancier formatting i.e. inverted text for username/handle
|
|
|
|
# TODO: clean this up to use the built in formatting from escpos lib
|
|
|
|
# TODO: clean this up to use the built in formatting from escpos lib
|
|
|
@ -321,9 +331,6 @@ class PublicRelations(Bureau):
|
|
|
|
if media.type == "image":
|
|
|
|
if media.type == "image":
|
|
|
|
img = media
|
|
|
|
img = media
|
|
|
|
if img:
|
|
|
|
if img:
|
|
|
|
#filename = img.url.rsplit('/',1)[1]
|
|
|
|
|
|
|
|
#filename = "/tmp/" + filename
|
|
|
|
|
|
|
|
#print("fetching", img.remote_url, filename)
|
|
|
|
|
|
|
|
req_data = requests.get(img.url)
|
|
|
|
req_data = requests.get(img.url)
|
|
|
|
im = PIL.Image.open(io.BytesIO(req_data.content))
|
|
|
|
im = PIL.Image.open(io.BytesIO(req_data.content))
|
|
|
|
if im.mode in ("L", "RGB", "P"):
|
|
|
|
if im.mode in ("L", "RGB", "P"):
|
|
|
@ -333,7 +340,7 @@ class PublicRelations(Bureau):
|
|
|
|
|
|
|
|
|
|
|
|
tw_shortcode = self.short_tweet_id(str(t["id"]))
|
|
|
|
tw_shortcode = self.short_tweet_id(str(t["id"]))
|
|
|
|
#prn.barcode("PRmad." + tw_shortcode, "CODE128", function_type="B")
|
|
|
|
#prn.barcode("PRmad." + tw_shortcode, "CODE128", function_type="B")
|
|
|
|
prn.soft_barcode("code128", "PRmad." + tw_shortcode)
|
|
|
|
prn.soft_barcode("code128", "PRmad." + tw_shortcode, module_width=0.16)
|
|
|
|
|
|
|
|
|
|
|
|
notifications = self.masto.notifications(since_id=self.last_mast_notif)
|
|
|
|
notifications = self.masto.notifications(since_id=self.last_mast_notif)
|
|
|
|
if len(notifications) > 0:
|
|
|
|
if len(notifications) > 0:
|
|
|
|