I’m part way through developing an app that displays my daily Wordle score. I’m still working out how exactly to get the data from Wordle into the Tidbyt.
Current Display:
Suggestions welcome for getting the data on the display updated daily.
Current thoughts:
- Share to the Tidbyt app on Android/iPhone
- Post a JSON/POST message direct to the Tidbyt
- Scrape the data out of the Browser’s LocalStorage file, nyt-wordle-state key/object
- ?
6 Likes
Current plan is to Post my score to Twitter, and have the Tidbyt pull score from there. That said, I’m having a bit of a struggle trying to figure out how to get Pixlet to pull my latest tweet, decode, and drop into my current display widgets.
Suggestions? Help? I already have my Twitter Dev account, and a Bearer Token; which was a learning experience all its own!
Ok, quick update. I’ve successfully gotten my code to pull my latest twitter post!
First I pull all my latest tweets:
res = http.get(
url = "https://api.twitter.com/2/users/15010281/tweets?start_time=2022-05-05T00:00:00Z",
headers = {
"Authorization": "Bearer " + str(BEARER_TOKEN)
}
)
Then I take the JSON returned from the Twitter API above, and pull out the latest Tweet’s text only:
print(res.json()["data"][0]["text"])
I have a couple print statements which are helping me debug:
print(str(res.status_code))
print(res.json()["data"][0]["text"])
Which gives me:
Now I just need to figure out how to map that string (including the color boxes!) to the widgets that I made last week…
2 Likes
SUCCESS! Thanks to an amazing user on Discord, @rgkimball , I’ve got a local working copy. Couldn’t seem to wrap my brain around building the UI via “for loops” but it finally clicked.
Next up, I’m going to try to figure out 2 things:
-
Hide my App Bearer Token via an environment variable or cache or … ???
-
Investigate pushing to the Community Apps so everyone can use it!
3 Likes
What’s the latest word on Wordlebyt?
Well, I FINALLY got my Tidbyt! (so that’s exciting!)
As for Wordlebyt itself, turns out, publishing the app is harder than just uploading my code that works locally. Maybe I should just pay someone like $20 to publish it for me?
What problems are you having? Should just be a simple pull request on github
I’m a Systems Engineer, which means I can’t really do anything useful. I don’t really know what a simple pull request from github really means. Additionally, I’ve got to implement the cache system to hide the API key, and figure how all of that works. At least one final thing would be to implement a schema so the user can put their own twitter handle in.
$20… anyone?
From what little I know you can use the secret module (see pixlet docs) to encrypt your API key.
You’d also probably need to use oauth2 which is documented in pixlet and you’d have to check Twitter docs to implement that. I can’t remember if there is a second Twitter app a community member made or not.
Edit: a systems engineer is probably pretty useful
I’ve got the OAUTH2 command working with the Twitter API. Unfortunately, the way I’ve got it implemented in code, the key is in plaintext for building the message to send to Twitter API. I think you’re right about needed to somehow use the secrets module (someone suggested using CACHE but I’m not sure how that would work).
Yeah from what I understand you’ll just need to use the secrets module. Which should hide any personal info and stuff.
I looked into this more today. I’ve got my entire system setup, and I’m now attempting to incorporate the Schema to let the user enter their Twitter UserID.
I noticed that the Tidbyt team has created a “Tweets from your timeline” app, and they’ve implemented a button for when you are installing where you connect your twitter account! It seems this could be an ideal way for me to get to each user’s tweets into the app, but for some reason that app isn’t in the community repo. Does anyone know where this type of thing is documented?
Schema added! I’ve got a field for entering your Twitter UserID (unfortunately I didn’t find a way to use your @Twitter handle directly, sorry!) and a field for the Dev API Key for testing.
MANY THANKS to @whyamihere on Discord for fixing my ‘pixlet encrypt’ issue. Turns out, 0.9.0 is a really old version of pixlet
Today I’m trying to address the fact that all users share the same data on the Community App server. As soon as someone were to run the app, their data would overwrite and push to everyone elses’ Tidbyt.
Apparently the cache module can solve this! … although, might be kinda cool to see others’ Wordle scores? Maybe a future feature that rotates through others’ scores.
Current Issues:
- Need a way to trigger Pixlet to go get the new Wordle score posted to Twitter
- Need to handle tweets that are NOT Wordle scores. Currently, if the latest tweet isn’t a Wordle score, the app breaks
For the ‘trigger issue’, the problem is that I normally just push the app from my computer to the Tidbyt after I post my new score. That isn’t going to work with a community app b/c there I don’t see a way to ‘kick off’ the update from the app other than to continually remove/reinstall. Initially, I think I’ll have it update every 15 minutes. I’m sure at some point I’ll bump up against the API rate limit. At that point I think I’ll have time to add the ‘Twitter Account Login’ OAUTH schema which may fix that. If the dev that made the Latest Tweet app would just let me peek at their code, that would be fantastic
Ok, I think I’ve got the second issue fixed - - - I’m cache’in’ like it’s fashion and I’ve got some error checking included to keep bad tweets from crashin’ the display.
I still have no way to ‘prompt’ the app to update, so at the moment you’ll just have to wait 15 minutes for it to refresh. (sorry!)
PR submitted! Looks like V1.0 will hit the shelves when the app gods deem it worthy.
THAT SAID - I’ve already decided that there is a much easier way to implement this - and it won’t block up your twitter feed (for those that use it!).
V2.0 will be a simply copy/paste into the Schema.
- Play Wordle on your phone
- When the score page is presented, press SHARE
- Select COPY
- Open Tidbyt App and find Wordlebyt
- Paste your score into the “Paste Your Wordle Score Here” field.
This has a huge advantage of massively simplifying the entire process.
- No per-user cache
- No need to parse twitter
- No need for Twitter API, Dev Account, etc
- Doesn’t block your twitter feed
- Far less error checking required!
Pull Request for V2.0 has been submitted. I like this version so much more, and I hope others find it fun! Tidbyt4Lyfe
Quick update. I wanted a few months, and it looks like there is still a difference between how the local Schema emulation parses text versus how the real Schema works. Unfortunately, this breaks the app.
I noticed there is a new pixlet version, so I’m going to try to see if that might help me out.
Honestly, there seems to be a bug in the community server parsing the Schema text. It seems to treat text from the user differently that the default text it is provided when it comes to /n //n and “/n”.
OMG - I am honestly embarrassed at how long that took me to update! Who knew that converting a mostly standard string of text, followed by a mostly ordered set of boxes would be so hard!!?
I basically completely rewrote the code that handles the schema text parsing. PR submitted, should be liveish in a week or so.
Happy Wordling!
For those who are Beta Testers, Wordlebyt is finally live!
Go check it out and let me know what you think!