Fix issue with trimming text
This commit is contained in:
parent
3999dbd4a1
commit
7ed13c3042
13
msgs.py
13
msgs.py
@ -26,17 +26,24 @@ def formatEmbedDesc(type,body,qrt,pollDisplay,likesDisplay):
|
|||||||
if pollDisplay==None:
|
if pollDisplay==None:
|
||||||
pollDisplay=""
|
pollDisplay=""
|
||||||
|
|
||||||
|
if qrt!={} and not (type=="" or type=="Video"):
|
||||||
|
|
||||||
|
qrtDisplay=genQrtDisplay(qrt)
|
||||||
|
if 'id' in qrt and ('https://twitter.com/'+qrt['screen_name']+'/status/'+qrt['id']) in body:
|
||||||
|
body = body.replace(('https://twitter.com/'+qrt['screen_name']+'/status/'+qrt['id']),"")
|
||||||
|
body = body.strip()
|
||||||
|
body+=qrtDisplay
|
||||||
|
qrt={}
|
||||||
|
|
||||||
if type=="" or type=="Video":
|
if type=="" or type=="Video":
|
||||||
output = body+pollDisplay
|
output = body+pollDisplay
|
||||||
elif qrt=={}:
|
elif qrt=={}:
|
||||||
output= body+pollDisplay+likesDisplay
|
output= body+pollDisplay+likesDisplay
|
||||||
else:
|
else:
|
||||||
qrtDisplay = genQrtDisplay(qrt)
|
output= body + likesDisplay
|
||||||
output= body + qrtDisplay + likesDisplay
|
|
||||||
if len(output)>248:
|
if len(output)>248:
|
||||||
# find out how many characters we need to remove
|
# find out how many characters we need to remove
|
||||||
diff = len(output)-248
|
diff = len(output)-248
|
||||||
print("diff: "+str(diff))
|
|
||||||
# remove the characters from body, add ellipsis
|
# remove the characters from body, add ellipsis
|
||||||
body = body[:-(diff+1)]+"…"
|
body = body[:-(diff+1)]+"…"
|
||||||
return formatEmbedDesc(type,body,qrt,pollDisplay,likesDisplay)
|
return formatEmbedDesc(type,body,qrt,pollDisplay,likesDisplay)
|
||||||
|
12
twitfix.py
12
twitfix.py
@ -314,6 +314,7 @@ def link_to_vnf_from_tweet_data(tweet,video_link):
|
|||||||
qrt['handle'] = tweet['quoted_status']['user']['name']
|
qrt['handle'] = tweet['quoted_status']['user']['name']
|
||||||
qrt['screen_name'] = tweet['quoted_status']['user']['screen_name']
|
qrt['screen_name'] = tweet['quoted_status']['user']['screen_name']
|
||||||
qrt['verified'] = tweet['quoted_status']['user']['verified']
|
qrt['verified'] = tweet['quoted_status']['user']['verified']
|
||||||
|
qrt['id'] = tweet['quoted_status']['id_str']
|
||||||
|
|
||||||
text = tweet['full_text']
|
text = tweet['full_text']
|
||||||
|
|
||||||
@ -420,7 +421,6 @@ def embed(video_link, vnf, image):
|
|||||||
|
|
||||||
desc=msgs.formatEmbedDesc(vnf['type'],desc,vnf['qrt'],pollDisplay,likeDisplay)
|
desc=msgs.formatEmbedDesc(vnf['type'],desc,vnf['qrt'],pollDisplay,likeDisplay)
|
||||||
|
|
||||||
print(len(desc))
|
|
||||||
appNamePost = ""
|
appNamePost = ""
|
||||||
if vnf['type'] == "Text": # Change the template based on tweet type
|
if vnf['type'] == "Text": # Change the template based on tweet type
|
||||||
template = 'text.html'
|
template = 'text.html'
|
||||||
@ -463,12 +463,14 @@ def embedCombinedVnf(video_link,vnf):
|
|||||||
urlLink = urllib.parse.quote(video_link)
|
urlLink = urllib.parse.quote(video_link)
|
||||||
likeDisplay = msgs.genLikesDisplay(vnf)
|
likeDisplay = msgs.genLikesDisplay(vnf)
|
||||||
|
|
||||||
if vnf['qrt'] == {}: # Check if this is a QRT and modify the description
|
if 'poll' in vnf:
|
||||||
desc = (desc + likeDisplay)
|
pollDisplay= msgs.genPollDisplay(vnf['poll'])
|
||||||
else:
|
else:
|
||||||
qrtDisplay=msgs.genQrtDisplay(vnf["qrt"])
|
pollDisplay=""
|
||||||
desc = (desc + qrtDisplay + likeDisplay)
|
|
||||||
|
|
||||||
|
desc=msgs.formatEmbedDesc(vnf['type'],desc,vnf['qrt'],pollDisplay,likeDisplay)
|
||||||
|
|
||||||
|
|
||||||
image = "https://vxtwitter.com/rendercombined.jpg?imgs="
|
image = "https://vxtwitter.com/rendercombined.jpg?imgs="
|
||||||
for i in range(0,int(vnf['images'][4])):
|
for i in range(0,int(vnf['images'][4])):
|
||||||
image = image + vnf['images'][i] + ","
|
image = image + vnf['images'][i] + ","
|
||||||
|
Loading…
x
Reference in New Issue
Block a user