Volledige schets met sommige interpretatie
Versie 9. Dit is de psychische hersenen Processing Schets ten tijde van de release van dit Instructable.
Wijzigingen zullen op de Git repository
https: int v=words.size()-1; github.com/rosemarybeetle/psychic-fortune-teller
credits
words.remove(v);
if (queryType.equals("hashtag"))
{
if (hashtagArray[1].equals("#"+queryString)) {
hashtags.remove(hashtagArray[1]);
}
else if (hashtags.size() >int(adminSettings[6])/10)
{
hashtags.remove(0);
} // keeps aray to a finite length by dropping off first element as new one is added
}
println ("hashtagArray["+k+"]= "+hashtagArray[1]);
}
// <<<<<<<
// >>>>>>> set up list of usernames
String username= cleanTweets.get(k);
String usernameArray[] = username.split("
.// println ("usernameArray = ");
//println (usernameArray);
if (usernameArray.length>1)
{ This sketch is the mind control of Psychic Fortune Teller, an automaton that can read the collective mind of twitter
int vv=words.size()-1; // takes out the username by removing last entry in words() It has a Processing brain connected to a Twitter app, connecting via OAUTH
words.remove(vv);// It harvests tweets from predefined searchs
// println ("usernameArray["+j+"]= "+usernameArray[1]); Deconstructs the weet content into words, hashtags, usernames and urls
} Then uses these to create fortune readings, which it speaks using text-to-speeach
if (usernames.size() >int(adminSettings[6])/6) it also tweets a summary.
{
usernames.remove(0); RESPECT to...
} // keeps aray to a finite length by dropping off first element as new one is added
// <<<<<<<< JER THORP - Visualisation is based on his code example
// >>>>>>>> set up urls >>>>>> see http:String url = cleanTweets.get(k);blog.blprnt.com/blog/blprnt/updated-quick-tutorial-processing-twitter
String urlArray[] = url.split("h"); Awesome!
if (urlArray.length>1)
{ The people behind twitter4j
String urlArray2[] = urlArray[1].split("t"); see https:if (urlArray2.length>2)github.com/yusuke/twitter4j/network
{ using here, version 3.03
urls.add(url); NOTE - you have to have the twitter4j library installed in the libraries folder for this to work!
int vvv=words.size()-1; You need to register your app to get OAUTH keys for Twitter4j
words.remove(vvv); You can put them in a separate tab in your sketch
}
else if (urls.size() >int(adminSettings[6])/6) Andreas Schlegel - controlP5 GUI Library
{ see http:urls.remove(0);www.sojamo.de/libraries/controlP5/
} // keeps aray to a finite length by dropping off first element as new one is added For positioning see (also Andreas Schlegel -
// <<<<<<<<<< end https:// >>>>>>>>>>code.google.com/p/controlp5/source/browse/trunk/examples/controlP5button/controlP5button.pde?r=6
}
}; Nikolaus Gradwohl for the GURU text to speech library for Processing
} see http:println ("WORDS.SIZE () = "+words.size());www.local-guru.net/blog/pages/ttslib
println ("words = "+words);
println ("-
initialisatie
// >>>>>>> create text log file of words from pyschic scanning >>>>>>>>> >for (int p =0;p>
{>uberWords = append (uberWords, words.get(p).toString());>}>uberWords = append (uberWords, "WORDS UPDATE REFRESH COMPLETED");>uberWords = append (uberWords, " ");
saveStrings ("words-"+stamp+".txt", uberWords);
// <<<<<< end word text log file
// >>>>>> create log file of users
for (int jj =0;jj
{ <uberUsers = append (uberUsers, "<}<saveStrings ("users-"+stamp+".txt", uberUsers);<// <<<<<<<<< end user text log file<// >>>>>> create log file of hashtags<for (int jj =0;jj end load flags
{ >uberHashtags = append (uberHashtags, "#"+hashtags.get(jj).toString());>}>saveStrings ("hashtags-"+stamp+".txt", uberHashtags);>// <<<<<<<<< end hashtag text log file>// >>>>>> create log file of urls fortune variables initialisations
for (int jj =0;jj
{
uberUrls = append (uberUrls, urls.get(jj).toString());
}
saveStrings ("urls-"+stamp+".txt", uberUrls);
// <<<<<<<<< end url text log file
} //end try ?? <catch(TwitterException e) {<println("TEST query tweet: " + e + " Status code: " + e.getStatusCode());<} // end try/catch<grabTime=millis(); // reset grabTime<if (loadSettingsFirstLoadFlag==true)<{
loadSettingsFirstLoadFlag =false; // >//this is the line that will cause subsequqnt updates to remove the first word(0)>}>cleanTweets.clear();>tweetster.clear();>} // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end grabTweets() <<<<<<<<>
void buttonCheck(String tweetTextIntro) gui variables init...
String tfUserCurrent =""{ if (b.isPressed()) { used to check what is in the username text box
String tfTextCurrent =""println("button being pressed"); sendTweet ("digital (onscreen) Button MOUSE"); used to check what is in the free-text text box
int valFocus = 0b.setWidth(50); // action for onscreen button press default
}
}
// <<<<<<<<<<<<<<<<<<<<<<< end of BUTTONCHECK
// >>>>>>>>>>>>>>> check the open serial port >>>>>>>>>>
void checkSerial() {
println (); <//println ("inside checkSerial()");<try {<// >>>>>> see if the port is sending you stuff<while (port.available () > 0) {<String inByte = port.readString();<println ("Safe from OUSIDE IF . inByte = "+inByte);
int w=int(random(150)); >b.setWidth(w);>println ();>port.clear();>sendTweet ("physical Button");>}>} // end try catch (Exception e) {s to hold all of the words that we get from the imported tweets
println ("Check serial exception = "+e);
stopWords = new }()} // <<<<<<<<<<<<<<<<<<<<< end checkSerial <<<<<<<<<<<<<<<<<<<<<
// >>>>>>>>>>>>>>>>>>> load remote admin settings >>>>>>>>>>>>>>
cleanTweets = new
void loadRemoteAdminSettings ()(){
try {
words = new String checkRandomSpeech = adminSettings[8];()adminSettings = loadStrings("https://docs.google.com/spreadsheet/pub?key=0AgTXh43j7oFVdFNOcGtMaXZnS3IwdTJacllUT1hLQUE&output=txt");
if ((checkRandomSpeech.equals(adminSettings[8]))!=true) {
hashtags = new tts.speak(adminSettings[8]);()}
for (int i = 0 ; i < adminSettings.length; i++) {
usernames = new println("adminSettings["+i+"]= "+adminSettings[i]);()} // end for
if (adminSettings[5].equals("h")) {
urls = new println ("use hashtag for search");()queryString = adminSettings[0];
queryType = "hashtag"; tweetster = new }()if (adminSettings[5].equals("u"))
String uberWords [] = new String[0]{ println ("use username phrase for search");massive array to build up history of words harvested
String uberHashtags [] = new String[0]queryString = adminSettings[1]; queryType = "username";massive array to build up history of hashtags harvested
String uberUsers [] = new String[0]} if (adminSettings[5].equals("s"))massive array to build up history of users harvested
String uberUrls [] = new String[0]{ println ("use search term for search");massive array to build up history of urls harvested
String queryString = ""queryString = adminSettings[2]; queryType = "search term";
String queryType = ""} updateDisplayVariables();
// now load load fortune fragments
fortFrags1 = new String frag1 []= loadStrings ("https://docs.google.com/spreadsheet/pub?key=0AgTXh43j7oFVdDQ3cUZ5Y2RMTm9RSXNrdElZTjN5R1E&output=txt");()for (int ff1=0; ff1
{
fortFrags2 = new fortFrags1.add(frag1[ff1]);()println ("Fortune Frag1 = "+fortFrags1.get(ff1));
}
fortFrags3 = new String frag2 []= loadStrings ("https://docs.google.com/spreadsheet/pub?key=0AgTXh43j7oFVdGFQLTFhMUVqTTlkTjlRVUN4c3JtOGc&output=txt");()for (int ff2=0; ff2
{
fortFrags4 = new fortFrags2.add(frag2[ff2]);()println ("Fortune Frag2 = "+frag2[ff2]);
println ("Fortune Frag1 = "+fortFrags2.get(ff2)); <}<String frag3 []= loadStrings ("https://docs.google.com/spreadsheet/pub?key=0AgTXh43j7oFVdFE0Qm1yYmhyYWJETVJsSHJIOGFMQ3c&output=txt");<for (int ff3=0; ff3<
{<fortFrags3.add(frag3[ff3]);<println ("Fortune Frag3 = "+frag3[ff3]); Variables for admin and tweettexts - e.g Array for containing imported admin settings from Google spreadsheet (init with default settings)
}
String frag4 []= loadStrings ("https://docs.google.com/spreadsheet/pub?key=0AgTXh43j7oFVdG9KTnhLS2Zvbk5HNXp2RmRpeUZtTUE&output=txt");
for (int ff4=0; ff4
{
fortFrags4.add(frag4[ff4]);
println ("Fortune Frag4 = "+frag4[ff4]);
}
// end if
}
catch (Exception e) {
println ("no CONNECTION");
}
} >// >>>>>
void loadRemoteStopWords ()>{>try {>String stopWordsLoader [] = loadStrings("https://docs.google.com/spreadsheet/pub?key=0AgTXh43j7oFVdFByYk41am9jRnRkeU9LWnhjZFJTOEE&output=txt");>if (loadstopWordsCheckInt==true) grabTweets Timer settings >{>for (int i = 0 ; i < stopWordsLoader.length; i++) {>//stop>stopWords.add(stopWordsLoader[i]);>println("stopWords["+i+"]= "+stopWords.get(i)+". Length now: "+stopWords.size());>}>loadstopWordsCheckInt=false;>}>}>catch (Exception e)>{
println("jjjjjjjjjjjjj");
}
String stamp = year()+"-"+month()+"-"+day()+"-"+hour()+"-"+minute()}void keyReleased() { <if (key==TAB) {<println ("Tab key released");<//tfToggleFocus(valFocus);<}<else if ((key==ENTER )|(key == RETURN)) {<sendTweet("pressed return");
Instellen van GUI interface-gebouw bibliotheek (ControlP5)
} >}>void tfToggleFocus (int val)>{>/*if (val==0)>{>tf.setFocus(true); GUI library and settings
import controlP5.*tf.setColorBackground(focusBackgroundColor); tf.setColor(focusColor); import the GUI library
ControlP5 cp5valFocus=1; } creates a controller (I think!)
else if (val==1) {
tf.setFocus(false);
tf.setColorBackground(focusOffBackgroundColor);
tf.setColor(focusOffColor);
valFocus=0; <}*/<tf.setFocus(true);<tf.setColorBackground(focusBackgroundColor);<tf.setColor(focusColor);<}<void updateDisplayVariables() {<// Reading the mind queryString
Text-to-speech bibliotheek (GURU) instellen
String currentHashtag = adminSettings [0]; >String displayHashtag = "hashtag = "+adminSettings [0]+" ";>if (adminSettings[0]=="")>{>displayHashtag="";>}>String currentUserName = adminSettings [1];>String displayUserName = " = "+adminSettings [1]+" "; import GURU text-to-speech library
import guru.ttslib.*if (adminSettings[1]=="") { NB this also needs to be loaded (available from http:displayUserName="";www.local-guru.net/projects/lib/ttslib-0.3.zip)
TTS tts} String currentSearchTerms = adminSettings [2]; create an instance called 'tts'
String displaySearchTerms = "search = "+adminSettings [2]; <if (adminSettings[2]=="")<{<displayUserName="";<}<readingSettingText = "Reading the hive mind for "+queryType+"= "+ queryString;<color cl = color(70, 30, 180);// not in use<color cl2 = color(70, 230, 180);//not in use
fill (clPanel); >//rect(30, boxY+15, width, 105);>fill(0, 0, 0, 255);>textSize(40);>//text(readingSettingText, 10, boxY+40);>//rect(0, boxY+13, width, 1);>textSize(40);>text(" 2, boxY+33); import standard processing Serial library
fill (clPanel);
Serial portrect(columnPos2_X, boxY-10, width, 50); fill(0, 0, 0, 255); create an instance called 'port'
textSize(35); <//text(adminSettings[7], columnPos2_X+30, boxY-25);<text("<
//displayHashtag+displayUserName+displaySearchTerms;<}<
void buildAdminPanel() {<int panelTop = height-panelHeight;<fill (clPanel);
rect(0, panelTop, width, panelHeight); >// >>>>>>> set up fonts>//PFont font = createFont("arial",20);>font = new ControlFont(createFont("arial", 100), 40);>// <<<<<<<>// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> set up GUI elements >>>>>>>>>>>>>>>>>>>>>noStroke(); needed to stop Twitter overpolling from within sendTweet
float tweetTimer = 5000cp5 = new ControlP5(this); // adds in a control instance to add buttons and text field to noStroke(); wait period (in milliseconds) after sending a tweet, before you can send the next one
float timerT=millis()tf = cp5.addTextfield(""); tf.setPosition(border, boxY); temporary timer for sendTweet
float delayChecktf.setSize(boxWidth, boxHeight); tf.setColorBackground(focusBackgroundColor);delayChecktf.setColor(focusColor); tf.setFont(font); THIS IS IMPORTANT. it i what stops overpollin g of the Twitter API
tf.setFocus(true); <//tf.setAutoClear(true);<tf.captionLabel().setControlFont(font);<// <// create a new button with name 'Tell my Fortune'<b = cp5.addButton("but", 20, 100, 50, 80, 20);<b.setId(2); // id to target this element End of main initialisation
Main Setup functie...
b.setWidth(250); // width
tts = new TTS()b.setHeight(25); b.setPosition(border, boxY+100); create text to speech instance
tts.speak(adminSettings[8])b.captionLabel().setControlFont(font);b.captionLabel().style().marginLeft = 1; preloaded, not web
b.captionLabel().style().marginTop = 1; adminSettings 1 " + adminSettings)b.setVisible(true); b.isOn(); DEBUG STUFF
b.setColorBackground(focusOffBackgroundColor);
println("adminSettings["+i+"]= "+adminSettings[i])// // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end of GUI <<<<<<<<<< DEBUG STUFF
// >>>>>>>>
}
void readFortune (String tweetText)
loadRemoteAdminSettings(){ int picW1 = int(random (words.size())); loads Twitter search parameters from remote Google spreadsheet
String fortuneWord1= words.get(picW1);
tts.speak("I am connected to the web. Master.Your commands have been loaded into my brain")int picW2 = int(random (words.size())); String fortuneWord2= words.get(picW2); DEBUG STUFF - SPOKEN OUT. ONLY WORKS IF CONNECTION WORKS
int hash = int(random (hashtags.size()));
String fortuneHash= hashtags.get(hash);
tts.speak("I am sorry. I am not able to connect to the web. Your commands have not been loaded into my brain master")int urler = int(random (urls.size())); String fortuneUrl= urls.get(urler); DEBUG STUFF
int userer = int(random (usernames.size()));
loadRemoteStopWords()String fortuneUser = usernames.get(userer);int frag1Int =int (random (fortFrags1.size())); load list of stop words into an array, loaded from a remote spreadsheet
String fraglet1 = fortFrags1.get(frag1Int); >int frag2Int =int (random (fortFrags2.size()));>String fraglet2 = fortFrags2.get(frag2Int);>int frag3Int =int (random (fortFrags3.size()));>String fraglet3 = fortFrags3.get(frag3Int);>int frag4Int =int (random (fortFrags4.size()));>String fraglet4 = fortFrags4.get(frag4Int);>fortune = "Psychic summary for + ". for: #"+queryString+". "+ fortuneWord1+", "+ fortuneWord2+", #"+fortuneHash+ ", "+fortuneUrl+". Enjoy/RT"; screen size and settings....
size(screen.width-border, screen.height-border)println ("just before fortune spoken");fortuneSpoken = "Hello. "+tfUserCurrent+". "+adminSettings[7]+ ". "+fortuneGreeting +". Here. you are. Your Psychic Hive Mind. Fortune. based on reading .the collective mind of. "+queryString+". is. "+fraglet1+". "+ fortuneWord1+". "+ fraglet2+". "+fortuneWord2+". "+fraglet3+". hashtag."+fortuneHash+ ". "+fraglet4+". Twitter user."+fortuneUser+". Thank you. I have tweeted a psychic summary of this reading to your twitter account. Moove along now. " ; USE THIS SETTING FOR EXPORTED APPLICATION IN FULLSCREEN (PRESENT) MODE
background(0)println ("fortuneSpoken= "+fortuneSpoken); } SET BACKGROUND TO BLACK
http://search.twitter.com/search.json?q=%23museumnext <<<<<<<
>>>>> Make initial serial port connection handshake
println(Serial.list()) DEBUG STUFF - display communication ports (use this in test for available ports)
port = new Serial(this, Serial.list()[0], 115200) OPEN PORT TO ARDUINO
if errors
---")
Exception = "+ae) print it
---")
---")
<<<<<<<
Now call tweeting action functions...
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end of setup() <<<<<<<<<<<<<<<<<<<<<<<<<<
Main loop functie
buttonCheck("HELLO") on screen check button every loop
>>>>>> Draw a faint black rectangle over what is currently on the stage so it fades over time.
fill(0, 30) change the latter number to make the fade deeper (from 1 to 20 is good)
<<<<<<
>>>>>>> WORDS
Draw a word from the list of words that we've built
<<<<<<<
>>>>>>> HASHTAGS
Draw a hashtag from the list of words that we've built
<<<<<<<
>>>>>> USERNAMES
Draw a username from the list of words that we've built
<<<<<<
>>>>>> URLS
Draw a url from the list of words that we've built
<<<<<<
-------------
>>>>> Put url somewhere random on the stage, with a random size and colour
text(url, random(width)-widthRandomiser, random(panelTop))
<<< SEND URL TO THE SCREEN
>>> SENDs HASHTAG TO THE SCREEN WITH DIFFERENT SIZE
<<< END SEND HASHTAG#
>>>SEND WORD TO SCREEN ALSO WITH DIFFERENT SETTINGS
<<< END SEND WORD
>>> SEND USERNAME TO SCREEN
<<< END SEND USERNAME
----------
following is for text boxes background.
tfUserCurrent=tf.getText() check the text box content every loop
tfUserCurrent= "+tfUserCurrent) DEBUG STUFF
checkSerial() check serial port every loop
Functie SENDTWEET() - stuurt tweets!
>>>>>>>>>>>>>>>>>>>>>>>> SEND THAT TWEET >>>>>>>>>>>>>>>
void sendTweet (String tweetText)
if ((tfUserCurrent.equals(""))!=true) THE BOX CAN'T BE EMPTY
timerT=millis() reset the timer each time
this is needed to prevent sending multiple times rapidly to Twitter
which will be frowned upon!
RESET A TIMER
println("tweet being sent") DEBUG STUFF
println("tfUserCurrent = "+ tfUserCurrent) DEBUG STUFF
tweetTextIntro = readingSettingText INITIALISE THE INTRO TEXT VARIABLE...
println("tweet Send actions complete over") DEBUG STUFF
--- NB - the variables twitOAuthConsumerKey, are in a seperate tab
println("Successfully tweeted the message: "+fortune + " to user: [ + status.getText() + "].") DEBUG STUFF
catch(TwitterException e)
end try
else
tts.speak("You have not entered your Twitter user nayme. Sorry. I cannot reed your fortune. without this") THE BOX WAS EMPTY
<<<<<<<<<<<<<<<<<<<<<<<<< END SEND TWEETS <<<<<<<<<<<<<<<
Functie GRABTWEETS() - Dit is de belangrijkste oogsten functie
>>>>>>>>>>>>>>>>>>>>>>>>> GRAB THOSE TWEETS >>>>>>>>>>>>>
void grabTweets()
color cl3 = color(70, 130, 180)
fill (cl3)
rect(0, (height/2)-120, width, 90)
fill(0, 25, 89, 255)
textSize(70)
Reading the collective mind...", (width/8)-120, (height/2)-50) THE ALERT FOR UPDATE CHECKING PAUSE
loadRemoteAdminSettings() GET THE LATEST ADMIN FROM GOOGLE SPREADSHEET
Credentials
ConfigurationBuilder cbTest = new ConfigurationBuilder()
--- NB - the variables twitOAuthConsumerKey, etc. ARE IN A SEPARATE SHEET
cbTest.setOAuthConsumerKey(twitOAuthConsumerKey)
cbTest.setOAuthConsumerSecret(twitOAuthConsumerSecret)
cbTest.setOAuthAccessToken(twitOAuthAccessToken)
cbTest.setOAuthAccessTokenSecret(twitOAuthAccessTokenSecret)
Twitter twitterTest = new TwitterFactory(cbTest.build()).getInstance()
TRY ALLOWS ERROR HANDLING FOR EXCEPTIONS...
Query query = new Query(queryString) this is default you check the first of 4 admin settings, but should be extended to include passing a selctor param
query.count(int(adminSettings[3])) count is the number of tweets returned per page
QueryResult result = twitterTest.search(query) gets the query
int ll=1 DEBUG STUFF
for (Status status : result.getTweets()) EXTRACT THE TWEETS
String user = status.getUser().getScreenName() GET THE TWITTER USERNAME
usernames.add(user) ADD TO THE ARRAYLIST FOR USERNAMES
String msg = status.getText() EXTRACT THE TWEET TEXT
tweet #"+ll) DEBUG STUFF
println(" + user) DEBUG STUFF
println("Text of tweet=" + status.getText()) DEBUG STUFF
-----------")
ll++ DEBUG STUFF (INCREMENT)
Break the tweet into words
String[] input = msg.split(" ") BREAK DOWN THE TWEET USING SPACES AS A DELIMITER
for (int j = 0 j < input.length j++)
cleanTweets.add(input[j]) CLEANTWEETS IS A STORE FOR TWEET WORDS WITH STOP WORDS REMOVED
for (int ii = 0 ii < stopWords.size() ii++)
if (stopWords.get(ii).equals(input[j]))
cleanTweets.remove(input[j]) THIS WORD IS A STOP WORD - REMOVE IT!
println("Word removed due to matched stopword: "+input[j]) DEBUG STUFF
end if
end for (ii++) stopword c
end clean this msg
end of all tweet cleaning
cleanTweets = "+cleanTweets)
for (int k = 0 k < cleanTweets.size() k++)
(cleanTweets.get(k) <"+cleanTweets.get(k)+".equals(queryString))"+queryString+"!= true")
words.add(cleanTweets.get(k))
if (words.size() >int(adminSettings[6]))
words.remove(0)
keeps aray to a finite length by dropping off first element as new one is added
>>>>>> make the list of hashtags
String hashtag= cleanTweets.get(k)
String hashtagArray[] = hashtag.split("#")
if (hashtagArray.length>1)
inside checker")
hashtags.add(hashtagArray[1])
int v=words.size()-1
words.remove(v)
if (hashtagArray[1].equals("#"+queryString))
hashtags.remove(hashtagArray[1])
else if (hashtags.size() >int(adminSettings[6])/10)
hashtags.remove(0)
keeps aray to a finite length by dropping off first element as new one is added
hashtagArray["+k+"]= "+hashtagArray[1])
<<<<<<<
>>>>>>> set up list of usernames
String username= cleanTweets.get(k)
usernameArray = ")
println (usernameArray)
if (usernameArray.length>1)
int vv=words.size()-1 takes out the username by removing last entry in words()
words.remove(vv)
usernameArray["+j+"]= "+usernameArray[1])
if (usernames.size() >int(adminSettings[6])/6)
usernames.remove(0)
keeps aray to a finite length by dropping off first element as new one is added
<<<<<<<<
>>>>>>>> set up urls >>>>>>
String url = cleanTweets.get(k)
String urlArray[] = url.split("h")
if (urlArray.length>1)
String urlArray2[] = urlArray[1].split("t")
if (urlArray2.length>2)
urls.add(url)
int vvv=words.size()-1
words.remove(vvv)
else if (urls.size() >int(adminSettings[6])/6)
urls.remove(0)
keeps aray to a finite length by dropping off first element as new one is added
<<<<<<<<<< end
>>>>>>>>>>
WORDS.SIZE () = "+words.size())
words = "+words)
>>>>>>> create text log file of words from pyschic scanning >>>>>>>>>
for (int p =0p
uberWords = append (uberWords, words.get(p).toString())
uberWords = append (uberWords, "WORDS UPDATE REFRESH COMPLETED")
uberWords = append (uberWords, " ")
saveStrings ("words-"+stamp+".txt", uberWords)
<<<<<< end word text log file
>>>>>> create log file of users
for (int jj =0jj
saveStrings ("users-"+stamp+".txt", uberUsers)
<<<<<<<<< end user text log file
>>>>>> create log file of hashtags
for (int jj =0jj
uberHashtags = append (uberHashtags, "#"+hashtags.get(jj).toString())
saveStrings ("hashtags-"+stamp+".txt", uberHashtags)
<<<<<<<<< end hashtag text log file
>>>>>> create log file of urls
for (int jj =0jj
uberUrls = append (uberUrls, urls.get(jj).toString())
saveStrings ("urls-"+stamp+".txt", uberUrls)
<<<<<<<<< end url text log file
end try ??
catch(TwitterException e)
println("TEST query tweet: " + e + " Status code: " + e.getStatusCode())
end try/catch
grabTime=millis() reset grabTime
loadSettingsFirstLoadFlag =false
this is the line that will cause subsequqnt updates to remove the first word(0)
cleanTweets.clear()
tweetster.clear()
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end grabTweets() <<<<<<<<
Functie BUTTONCHECK() - controle voor interactie
if (b.isPressed())
println("button being pressed")
sendTweet ("digital (onscreen) Button MOUSE")
b.setWidth(50)
action for onscreen button press
<<<<<<<<<<<<<<<<<<<<<<< end of BUTTONCHECK
>>>>>>>>>>>>>>> check the open serial port >>>>>>>>>>
Functie CHECKSERIAL() - controles voor data van de Arduino
void checkSerial()
inside checkSerial()")
>>>>>> see if the port is sending you stuff
while (port.available () > 0)
String inByte = port.readString()
Safe from OUSIDE IF . inByte = "+inByte)
int w=int(random(150))
b.setWidth(w)
port.clear()
sendTweet ("physical Button")
end try
Check serial exception = "+e)
<<<<<<<<<<<<<<<<<<<<< end checkSerial <<<<<<<<<<<<<<<<<<<<<
>>>>>>>>>>>>>>>>>>> load remote admin settings >>>>>>>>>>>>>>
LOADREMOTESETTINGS() - functie trekt controle gegevens uit Google spreadsheetsdata
String checkRandomSpeech = adminSettings[8]
if ((checkRandomSpeech.equals(adminSettings[8]))!=true)
tts.speak(adminSettings[8])
println("adminSettings["+i+"]= "+adminSettings[i])
end for
if (adminSettings[5].equals("h"))
use hashtag for search")
queryString = adminSettings[0]
queryType = "hashtag"
use username phrase for search")
queryString = adminSettings[1]
queryType = "username"
use search term for search")
queryString = adminSettings[2]
queryType = "search term"
now load load fortune fragments
String frag1 []= loadStrings ("https:docs.google.com/spreadsheet/pub?key=0AgTXh43j7oFVdDQ3cUZ5Y2RMTm9RSXNrdElZTjN5R1E&output=txt")
for (int ff1=0 ff1
fortFrags1.add(frag1[ff1])
Fortune Frag1 = "+fortFrags1.get(ff1))
String frag2 []= loadStrings ("https:docs.google.com/spreadsheet/pub?key=0AgTXh43j7oFVdGFQLTFhMUVqTTlkTjlRVUN4c3JtOGc&output=txt")
for (int ff2=0 ff2
fortFrags2.add(frag2[ff2])
Fortune Frag2 = "+frag2[ff2])
Fortune Frag1 = "+fortFrags2.get(ff2))
String frag3 []= loadStrings ("https:docs.google.com/spreadsheet/pub?key=0AgTXh43j7oFVdFE0Qm1yYmhyYWJETVJsSHJIOGFMQ3c&output=txt")
for (int ff3=0 ff3
fortFrags3.add(frag3[ff3])
Fortune Frag3 = "+frag3[ff3])
String frag4 []= loadStrings ("https:docs.google.com/spreadsheet/pub?key=0AgTXh43j7oFVdG9KTnhLS2Zvbk5HNXp2RmRpeUZtTUE&output=txt")
for (int ff4=0 ff4
fortFrags4.add(frag4[ff4])
Fortune Frag4 = "+frag4[ff4])
end if
no CONNECTION")
>>>>
LOADREMOTESTOPWORDS() - invoer de filterlijst stopword
String stopWordsLoader [] = loadStrings("https:docs.google.com/spreadsheet/pub?key=0AgTXh43j7oFVdFByYk41am9jRnRkeU9LWnhjZFJTOEE&output=txt")
for (int i = 0 i < stopWordsLoader.length i++)
stop
stopWords.add(stopWordsLoader[i])
println("stopWords["+i+"]= "+stopWords.get(i)+". Length now: "+stopWords.size())
loadstopWordsCheckInt=false
println("jjjjjjjjjjjjj")