Safe Haskell | None |
---|---|
Language | Haskell2010 |
Various utilities to tweet using the twitter api
Make sure you have a file credentials file (default the executable looks for is $HOME/.cred.toml
) with the following info:
api-key = API_KEY api-sec = API_SECRET tok = OAUTH_TOKEN tok-sec = TOKEN_SECRET
Synopsis
- basicTweet :: String -> FilePath -> IO Int
- thread :: String -> [String] -> Maybe Int -> Int -> FilePath -> IO ()
- reply :: String -> [String] -> Maybe Int -> FilePath -> IO ()
- data Tweet = Tweet {}
- data TweetEntity = TweetEntity {}
- pricklyTweet :: Tweet
- type Timeline = [TweetEntity]
- type Config = (OAuth, Credential)
- status :: Lens' Tweet String
- handles :: Lens' Tweet [String]
- replyID :: Lens' Tweet (Maybe Int)
- text :: Lens' TweetEntity String
- name :: Lens' TweetEntity String
- screenName :: Lens' TweetEntity String
- tweetId :: Lens' TweetEntity Int
- quoted :: Lens' TweetEntity (Maybe TweetEntity)
- retweets :: Lens' TweetEntity Int
- favorites :: Lens' TweetEntity Int
- module Web.Tweet.API
- type Filter = Timeline -> Timeline
- showProfile :: String -> Int -> Bool -> FilePath -> IO String
- showBest :: String -> Int -> Bool -> FilePath -> IO String
- showBest' :: String -> Int -> Bool -> FilePath -> IO String
- showReplies :: String -> Int -> Bool -> FilePath -> IO String
- showTimeline :: Int -> Bool -> FilePath -> IO String
- showFilteredTL :: [Filter] -> String -> Int -> Bool -> FilePath -> IO String
- showTweets :: Bool -> Either (ParseErrorBundle String Void) Timeline -> String
- showFavorites :: Int -> String -> Bool -> FilePath -> IO String
- signRequest :: FilePath -> Request -> IO Request
- oAuthMem :: ByteString -> ByteString -> OAuth
- credentialMem :: ByteString -> ByteString -> Credential
- urlString :: Tweet -> String
- filterReplies :: Timeline -> Timeline
- filterRTs :: Timeline -> Timeline
- filterQuotes :: Timeline -> Timeline
- bird :: String
Functions to tweet
basicTweet :: String -> FilePath -> IO Int Source #
Tweet a string given a path to credentials; return the id of the status.
basicTweet "On the airplane." ".cred.toml"
thread :: String -> [String] -> Maybe Int -> Int -> FilePath -> IO () Source #
thread tweets together nicely. Takes a string, a list of handles to reply to, plus the ID of the status you're replying to.
If you need to thread tweets without replying, pass a Nothing
as the third argument.
thread "Hi I'm back in New York!" ["friend1","friend2"] Nothing 1 ".cred"
reply :: String -> [String] -> Maybe Int -> FilePath -> IO () Source #
Reply with a single tweet. Works the same as thread
but doesn't take the fourth argument.
reply "Idk what that means" ["friend1"] (Just 189943500) ".cred"
Data type for a tweet
Data type for our request: consists of the status text, whether to trium u information in the response, the handles to mention, and optionally the id of the status to reply to.
data TweetEntity Source #
Data type for tweets as they are returned
Instances
Eq TweetEntity Source # | |
Defined in Web.Tweet.Types (==) :: TweetEntity -> TweetEntity -> Bool # (/=) :: TweetEntity -> TweetEntity -> Bool # |
pricklyTweet :: Tweet Source #
type Timeline = [TweetEntity] Source #
Stores data like (name, text, favoriteCount, retweetCount)
type Config = (OAuth, Credential) Source #
Contains an OAuth
and a Credential
; encapsulates everything needed to sign a request.
text :: Lens' TweetEntity String Source #
Lens for TweetEntity
accessing the _text
field.
name :: Lens' TweetEntity String Source #
Lens for TweetEntity
accessing the _name
field.
screenName :: Lens' TweetEntity String Source #
Lens for TweetEntity
accessing the _screenName
field.
tweetId :: Lens' TweetEntity Int Source #
Lens for TweetEntity
accessing the _tweetId
field.
quoted :: Lens' TweetEntity (Maybe TweetEntity) Source #
Lens for TweetEntity
accessing the _quoted
field.
retweets :: Lens' TweetEntity Int Source #
Lens for TweetEntity
accessing the _retweets
field.
favorites :: Lens' TweetEntity Int Source #
Lens for TweetEntity
accessing the _favorites
field.
Various API calls
module Web.Tweet.API
showProfile :: String -> Int -> Bool -> FilePath -> IO String Source #
Show a user profile given screen name, how many tweets to return, and whether to print them in color.
showBest :: String -> Int -> Bool -> FilePath -> IO String Source #
Show the most successful tweets by a given user, given their screen name.
showBest' :: String -> Int -> Bool -> FilePath -> IO String Source #
Show the most successful tweets by a given user, given their screen name. Additionally filter out replies.
showTweets :: Bool -> Either (ParseErrorBundle String Void) Timeline -> String Source #
Display user timeline in color, as appropriate
Functions to sign API requests
signRequest :: FilePath -> Request -> IO Request Source #
Sign a request using your OAuth dev token, as stored in a config file. Uses the IO monad because signatures require a timestamp
:: ByteString | API key |
-> ByteString | API secret |
-> OAuth |
Create an OAuth api key from two ByteStrings.
:: ByteString | Token |
-> ByteString | Token secret |
-> Credential |
Functions to generate a URL string from a Tweet
Timeline filters
filterReplies :: Timeline -> Timeline Source #
Filter out replies
filterQuotes :: Timeline -> Timeline Source #
Filter out quotes