100DaysOfCode-twitter-bot
100DaysOfCode-twitter-bot copied to clipboard
fix:limit check on tweet characters
Change proposed in this pull request:
Reduce spam retweets by modifying the bot logic as follows:
-
Apply a limit of 140 characters on the retrieved Tweets. This would only check the trimmed text in
full_text
. -
The hashtag
#100DaysOfCode
must be present in the text.
Tests
Successful retweet according to the updated logic:
https://twitter.com/junaid046/status/1552798489809104897
Rejected Tweets:
-
full_text
:
"RT @QuantScraper: keep on growing @CarolButWithAK ! let's support #WomenWhoCode #WomenInSTEM #WomenInTech
#GirlsWhoCode #javascript #html #…",
- character count: 140
-
full_text
:
'pay homework..\n' +
'pay coursework\n' +
'pay essay\n' +
'pay write\n' +
'pay biology\n' +
'pay history\n' +
'pay psychology\n' +
'pay dissertation\n' +
'pay research\n' +
'pay paper due\n' +
'pay math.\n' +
'pay physics...\n' +
'pay law.\n' +
'pay statistics\n' +
'pay lab report\n' +
'#100DaysOfCode\n' +
'#ElonMusk',
- character count: 250
-
full_text
:
RT @Kasungwa_: The goal this Year is to open our first physical campus in Kenya come October 2022 (@lux_academy and @DSEAfrica ) as �𝗨𝗫 𝗔𝗖…
- character count: 145
Thanks to @miljan-fsd from parcel-react-app for the template 👌
I've been using the early access V2 API, but this package uses 1.1 so I might be missing some things.
But rather than parsing the full_text
for hashtags, we should be able to access the entities.hashtags
property to view the actual hashtag data?
Ref: https://github.com/twitterdev/tweet-updates/blob/d6a6d3f448a6f35cd0cc541cf8549b3694ec8686/samples/initial/extended_classic_14002.json#L12
Thank you @naomi-lgbt for the suggestion. I just checked the entities property and it looks like this:
full_text: 'Day 11 of #100DaysOfCode tried to add UI to my old CRUD application',
truncated: false,
display_text_range: [ 0, 67 ],
entities: { hashtags: [Array], symbols: [], user_mentions: [], urls: [] },