Closed bullyawareness closed 5 years ago
That sounds relatively involved. Not all that difficult, but not something I can just bang out in this textbox in a minute or two. Can you be more precise about what problem you're encountering?
Please also see the resources (links) I listed for the user in Issue #2; you might also find them helpful in getting started.
Ok thanks, I will look into the link.
I have made progress, another thing what would be the best way to monitor around 5 keywords, would you suggest search-tweets or to stream? I have had no success with stream do you have an example of this?
Thankyou
Seems like you'd use a stream, but like you said, you are not worried about being banned, so that's up to you. Here's some code to help you along a bit:
(ns bullyawareness
"Re: bullyawareness's issue - https://github.com/chbrown/twttr/issues/3"
(:require [clojure.string :as str]
[twttr.api :as api]
[twttr.auth :as auth]))
(def credentials (auth/env->UserCredentials))
(def keywords ["damn" "you" "suck" "hate"])
(def track-stream (api/statuses-filter credentials :params {:track (str/join "," keywords)}))
(defn handle-tweet
[tweet]
(println (:screen_name (:user tweet)) "wrote:")
(println " " (str/replace (:text tweet) #"\s" " ")))
(run! handle-tweet (take 50 track-stream))
Hi there, I am new to Clojure and I would like to know how to build a function to reply to tweets containing certain words.
I have been trying to work this out for myself for a few days and getting nowhere.
I am able to send tweets in the repl, I need a function which will let me reply to tweets containing a word. I am not worried about being banned as I will be looking for a very unique set of keywords, I will have it set at ten minute intervals and it is for the purpose of monitering and standing up to online bullying.
Using the function I saw on an earlier issue, I am able to get a list of 15 tweets from keywords
I have been struggling to work out a way of writing a function to respond to the tweets and that is all. I have no issues with creating different tweets to send, however, I am pulling my hair out trying to write a function to respond to different users that I am getting with the filter-tweets function listed above.
Would greatly appreciate any suggestions.
Regards