BetterTwitFix/msgs.py
Dylan ff6651d2ad
Update 2023-05-04 (#88)
* Bump pillow from 9.4.0 to 9.5.0

Bumps [pillow](https://github.com/python-pillow/Pillow) from 9.4.0 to 9.5.0.
- [Release notes](https://github.com/python-pillow/Pillow/releases)
- [Changelog](https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst)
- [Commits](https://github.com/python-pillow/Pillow/compare/9.4.0...9.5.0)

---
updated-dependencies:
- dependency-name: pillow
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update deploy workflow

* Fix NSFW video embeds

* Fix small embed sizes

* Update gitignore

* Fix/workarounds for failing tests

* Revert "Add info message for #74"

This reverts commit 39490a49b98ba6e56a109958dab4cb953ede4fe8.

* Fixed tweet not found error

* Fix tweet not found test

* Bump boto3 from 1.26.104 to 1.26.127

Bumps [boto3](https://github.com/boto/boto3) from 1.26.104 to 1.26.127.
- [Release notes](https://github.com/boto/boto3/releases)
- [Changelog](https://github.com/boto/boto3/blob/develop/CHANGELOG.rst)
- [Commits](https://github.com/boto/boto3/compare/1.26.104...1.26.127)

---
updated-dependencies:
- dependency-name: boto3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump simple-git from 3.7.1 to 3.18.0

Bumps [simple-git](https://github.com/steveukx/git-js/tree/HEAD/simple-git) from 3.7.1 to 3.18.0.
- [Release notes](https://github.com/steveukx/git-js/releases)
- [Changelog](https://github.com/steveukx/git-js/blob/main/simple-git/CHANGELOG.md)
- [Commits](https://github.com/steveukx/git-js/commits/simple-git@3.18.0/simple-git)

---
updated-dependencies:
- dependency-name: simple-git
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Bump requests from 2.28.2 to 2.30.0

Bumps [requests](https://github.com/psf/requests) from 2.28.2 to 2.30.0.
- [Release notes](https://github.com/psf/requests/releases)
- [Changelog](https://github.com/psf/requests/blob/main/HISTORY.md)
- [Commits](https://github.com/psf/requests/compare/v2.28.2...v2.30.0)

---
updated-dependencies:
- dependency-name: requests
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-05-04 23:49:57 +01:00

50 lines
2.0 KiB
Python

failedToScan="Failed to scan your link! This may be due to an incorrect link, private/suspended account, deleted tweet, or Twitter itself might be having issues (Check here: https://api.twitterstat.us/)"
failedToScanExtra = "\n\nTwitter gave me this error: "
tweetNotFound="Tweet not found."
tweetSuspended="This Tweet is from a suspended account."
tweetDescLimit=340
def genLikesDisplay(vnf):
return ("\n\n💖 " + str(vnf['likes']) + " 🔁 " + str(vnf['rts']))
def genQrtDisplay(qrt):
verifiedCheck = "☑️" if ('verified' in qrt and qrt['verified']) else ""
return ("\n【QRT of " + qrt['uploader'] + " (@" + qrt['screen_name'] + ")"+ verifiedCheck+":】\n'" + qrt['description'] + "'")
def genPollDisplay(poll):
pctSplit=10
output="\n\n"
for choice in poll["choices"]:
output+=choice["text"]+"\n"+(""*int(choice["percent"]/pctSplit)) +" "+str(choice["percent"])+"%\n"
return output
def formatEmbedDesc(type,body,qrt,pollDisplay,likesDisplay):
# Trim the embed description to 248 characters, prioritizing poll and likes
output = ""
if pollDisplay==None:
pollDisplay=""
if qrt!=None 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=None
if type=="" or type=="Video":
output = body+pollDisplay
elif qrt==None:
output= body+pollDisplay+likesDisplay
else:
output= body + likesDisplay
if len(output)>tweetDescLimit:
# find out how many characters we need to remove
diff = len(output)-tweetDescLimit
# remove the characters from body, add ellipsis
body = body[:-(diff+1)]+""
return formatEmbedDesc(type,body,qrt,pollDisplay,likesDisplay)
else:
return output