This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Espen's profile picture

[CC 1.45 - 1.481] ccTwitterFeed v1.02

Started by Espen, 20 November 2012 - 06:55 AM
Espen #1
Posted 20 November 2012 - 07:55 AM
Description:
Periodically pulls public tweets from a Twitter account and displays them in a navigable screen.


More Screenshots:
Spoiler

Features:
  • Pulls new tweets in a configurable interval.
  • Auto-Flip: Flips through tweets automatically with a configurable delay.
  • Load tweets from the web or alternatively directly from a file with cached tweets.
  • A (hopefully) self-explanatory usage screen.
  • Color support (only when running from advanced computers, of course).
Instructions:
SpoilerPrerequisite:
Needs the HTTP API enabled.
To enable, open .minecraft/config/ComputerCraft.cfg and look for enableapi_http
Then set general to true.

Installation:
  1. Download the file below.
  2. Unpack the folder 'ccTwitterFeed' contained within into .minecraft/saves/[YOUR_WORLD_SAVE]/computers/[COMPUTER_ID]/

Usage:
  1. Start the CC computer
  2. Change into the ccTwitterFeed folder:
  3. cd ccTwitterFeed
  4. Enter ccTwitterFeed to see the options.
  5. For further options (Pull delay, Auto-Flip and its delay), look at the beginning of ccTwitterFeed's code.

Keys (also described in the head of the code):
  • DOWN / RIGHT 	-> Show next tweet
  • UP / LEFT 	-> Show previous tweet
  • + / - 		-> Increase/Decrease number of tweets to flip through
  • T 		-> Toggle auto flip
  • Q 		-> Quit program
Renaming: Both the folder ccTwitterFeed and the program ccTwitterFeed can be renamed to whatever you like.
Only the file UTILS, as well as the folder XMLParser (including its contents) have to remain their names, unless you also change their reference within the ccTwitterFeed-Program as well. Or else ccTwitterFeed won't find the UTILS functions or the XML parser!

IMPORTANT
  • Short version:
  • SpoilerDon't pull for new tweets like insane!
  • Long version:
  • SpoilerKeep in mind that the Twitter API has a rate limit on GET requests!
    As of v1.1 of the Twitter API, pulling the user timeline (like ccTwitterFeed does) is limmited to 180 requests per 15 minutes.
    That equates to 12 requests per minute. So one shouldn't pull new tweets less than every 5 seconds!
    That's why you can configure a reasonable pull delay in the program (120 seconds per default).
    1-2 Minutes should be a reasonable delay, as you wouldn't expect someone to make new tweets every 5 seconds anyway.
    Right? … *unsure, you never know*

    If you suddenly get an error after a while, right when the program starts pulling new tweets, then you probably have reached the rate limit and should adjust the pull delay.
    Set it higher, wait for a few minutes (or get a new IP by reconnecting) and then try again.

Download:
Spoilerv 1.02:Note: The ZIP-file contains two additional files needed for parsing XML. They are from LuaXML-0.0.0, which doesn't seem to be actively developed anymore but still works nontheless.

Changelog:
Spoilerv1.02
  • Added config value to set autoflip for program startup as suggested by [post='77248']hayhaycrusher[/post].
  • (see 'bAutoFlip' in config section of ccTwitterFeed)
v1.01
  • Made it backwards-compatible with CC versions that don't have Advanced Computers or the keys-API.

Future (unlikely for the time being):
Spoiler
  • Read the number of requests left for the 15 minute window and give a notice to the user.
  • Minor fix for Auto-Flip (at the moment, remaining seconds shown count from n to 1 during first time after toggle, but n-0 to 0 for all subsequent times, until re-toggle.)

Afterwords:
[indent=1]This is kind of an overdue release as this has been lying around in my MC 1.2.5 folder since march this year.
I originally planned to release it back then, but Uni got me really busy at the time, which also forced me to be absent from the forums for a few months.

Searching through my old progams yesterday I rediscovered it and have retouched it a bit.
I mainly added some color support, changed some condition logic and made use of the keys API.
The core functionality, while untouched, still works with the updated Twitter API v1.1

If you have a question or anything else, drop me a line, as usual. :)/>
Cheers,
Espen
[/indent]
Edited on 20 January 2013 - 03:31 AM
Jasonfran #2
Posted 20 November 2012 - 08:11 AM
Nice, I thought about making an actual minecraft mod like that allows you to do this but never got around to it. This is a good alternative
Espen #3
Posted 20 November 2012 - 08:27 AM
Nice, I thought about making an actual minecraft mod like that allows you to do this but never got around to it. This is a good alternative
Thanks :(/>/> Do you mean a peripheral, or a pure Minecraft-Mod, independent from ComputerCraft?
Edited on 20 November 2012 - 07:28 AM
Jasonfran #4
Posted 20 November 2012 - 09:00 AM
Nice, I thought about making an actual minecraft mod like that allows you to do this but never got around to it. This is a good alternative
Thanks :(/>/>/> Do you mean a peripheral, or a pure Minecraft-Mod, independent from ComputerCraft?
An independent mod
KillaVanilla #5
Posted 21 November 2012 - 06:06 PM
Whoa. This is cool; too bad I don't use Twitter.
Espen #6
Posted 21 November 2012 - 07:15 PM
Whoa. This is cool; too bad I don't use Twitter.
You mean you don't have an account or you don't watch any tweets of somebody else?
Because this is merely for viewing viewing tweets, not for posting them. So you don't necessarily need an account, only the name of a twitter channel. :(/>/>
flatlinerqz #7
Posted 15 December 2012 - 09:43 AM
I made a slight change to the code on my system. I changed the URL to api.twitter.com/1/MindcrackLP/lists/mindcrackers/statuses.xml. That allows me to see the tweets of all of the mindcrack guys.
Espen #8
Posted 15 December 2012 - 11:10 AM
I made a slight change to the code on my system. I changed the URL to api.twitter.com/1/MindcrackLP/lists/mindcrackers/statuses.xml. That allows me to see the tweets of all of the mindcrack guys.
Yeah, I didn't think of lists at the time and hence didn't look into them at all. Only focused on following individual accounts.
But glad to see it's relatively easy to implement. Also nice to know there is a Mindcrack Twitter list, thx! ^_^/>
Learning_inpaired #9
Posted 19 December 2012 - 08:20 AM
i got an error…server Http is enabled, tekkit 3.1.2.

ccTwitterFeed:32: bios:267: Attempt to wright to
global: disk/twitter/UTILS

Now befor u bash me, i did give full perms to all the files for this via server side.
but no idea whats going on here
Espen #10
Posted 19 December 2012 - 09:04 AM
i got an error…server Http is enabled, tekkit 3.1.2.

ccTwitterFeed:32: bios:267: Attempt to wright to
global: disk/twitter/UTILS

Now befor u bash me, i did give full perms to all the files for this via server side.
but no idea whats going on here
I just took a look at the CC code contained within Tekkit v3.1.2 and it seems it is using an old ComputerCraft (v1.33).
In that version ComputerCraft is protecting the global table from being modified by programs, that's why it throws that error message for you.

If you CAN update to Tekkit 3.1.3 then I'd suggest doing that, as it contains a more up-to-date version of ComputerCraft (v1.41) that doesn't have that limitation anymore.
Alternatively I'd have to rewrite how I include the UTILS functions, so that it's compatible with older ComputerCraft versions.
If you cannot update then I can give the rewrite a try. But it might take a while before I get some free time from my RL duties.
Maybe the day after tomorrow, that totally depends on certain stuff going on tomorrow.

I'll let you know as soon as I take a look at it. :)/>
Learning_inpaired #11
Posted 19 December 2012 - 10:05 AM
all right the info, i wont be updateing to tekkit 3.1.3 for now as theres a server-crasher bug with the obsiden pipes atm, i do have the ccTwitterFeed and http enabled on my private server, i it would be easer for you to eather edit it there or jsut do a download from pastebin. maby if i just do an update on computercraft's bios files maby that will work thouhts? i still have the zip from tekkit3.1.3
Espen #12
Posted 19 December 2012 - 11:20 AM
Only updating the bios.lua? Hmm, that could work. Depends on how much other files depend on stuff that would then be changed.
I'm not at my computer at home, so I can't take a look right now. But I would just test it on a local minecraft copy and see if the computers and their programs still work as intended. I.e. replace the 1.33 bios.lua with the up-to-date one.

But even if that doesn't work I might make ccTwitterFeed compatible with the older versions, will see. :)/>
Learning_inpaired #13
Posted 19 December 2012 - 01:09 PM
im trying a number of things atm, ill reedit this post to let you know how it went.

EDIT: first i replaced the entire CC mod, no luck..
attempt #2 i replaces the entire lua folder, everything works but same error on your program.
attempt #3 leaveing the previus files, i replaced the class files.. broke it lol…
attempt #4 if = failed
then rs.setbundledOutput("head", event.explode)
end
Espen #14
Posted 20 December 2012 - 06:45 AM
Ok, found the error for sure now.
Because of the protected global table in v1.33 of CC I can't do a pcall() on dofile() to check for errors.
I just removed the pcall and make a plain call to dofile() without checking for errors.
If dofile() fails for some reason, then there will be an error along the line anyway, so… meh.
But at least it's downward-compatible now. In theory even as far down as the CC version where the HTTP API was introduced.

I tested with a version of CC 1.33 on MC 1.2.5 and also found some other potential problems, like calls to APIs or methods that would be missing in older CC versions (keys, term.isColor, etc.)
I coded in some more thorough checks to allow the use of this program in much older CC versions.

If you don't mind, I'd like you to try again before I update the OP.
The current dev-version is here: [attachment=795:ccTwitterFeed.zip]
Learning_inpaired #15
Posted 20 December 2012 - 09:17 AM
all right i can now say that it works very nice to load the tweets, from _jeb!!
also sent you a PM
BUT, it won oad tweets from my own account lol.
i think maby the name is to long? woodzykiler 11 char's
also tryed @woodzykiler and also _woodzykiler oth wont read
ERROR:
ccTwitterFeed:195:
couldnt pull data from twitter.
check screen name or outher parameters
and dont pull to -blah blah blah
Espen #16
Posted 20 December 2012 - 09:34 AM
Did you pull multiple times in a row perhaps?
Twitter has a limit on how many times you can pull tweets with the API, so you shouldn't pull too many times per minute.
Basically, everytime you start the program it pulls fresh tweets from Twitter. (Except if you use the -F file mode).

But I'll take a look at why it doesn't work with your username.

EDIT:
Just checked your twitter account via web-browser and it seems your tweets are set to private.
ccTwitterFeed only supports public tweets. Otherwise you'd need to log in with a twitter-account and I didn't want to open a can of worms regarding security or just the handling and storing of account data.
Sorry, should've mentioned that in the OP. ^_^/>
Edited on 20 December 2012 - 08:40 AM
Learning_inpaired #17
Posted 20 December 2012 - 11:44 AM
hh ok, well in that case everything shuld eb just fine then :D/>
nice work
rootbear75 #18
Posted 31 December 2012 - 09:38 AM
How do i send the twitter feed to the monitor i have above the computer?
I also want it to automatically flip between tweets
Espen #19
Posted 31 December 2012 - 11:46 AM
There is a key-map in the instructions of the OP, which shows all available keys. To toggle auto-flip, press T.
To send the output of any program to a connected monitor, make use of the monitor-program:
monitor <SIDE> <PRORGAM> <PARAMETERS>
For more, type:
help monitor
MylesJames #20
Posted 19 January 2013 - 12:21 PM
Hey,


I am really confused how you send the program to run on a monitor, please help. Thanks


Myles
anonimo182 #21
Posted 19 January 2013 - 02:31 PM
Hey, couldn´t you read the above post? another thread from the previous week have been awoken…
DarkenedEvil #22
Posted 19 January 2013 - 03:45 PM
wow…just wow this is amazing!
hayhaycrusher #23
Posted 20 January 2013 - 02:14 AM
on the programs startup how to you automaticly auto flip without pressing t
Espen #24
Posted 20 January 2013 - 04:32 AM
on the programs startup how to you automaticly auto flip without pressing t
That wasn't yet possible, but I've just updated the program to add that feature.
See OP for new version 1.02 :)/>
hayhaycrusher #25
Posted 20 January 2013 - 05:15 AM
on the programs startup how to you automaticly auto flip without pressing t
That wasn't yet possible, but I've just updated the program to add that feature.
See OP for new version 1.02 :)/>


Thanks