tweet-hs-1.0.1.35: Command-line tool for twitter

Safe HaskellNone
LanguageHaskell2010

Web.Tweet

Contents

Description

Various utilities to tweet using the twitter api

Make sure you have a file credentials file (default the executable looks for is `.cred`) with the following info:

api-key: API_KEY

api-sec: API_SECRE

tok: OAUTH_TOKEN

tok-sec: TOKEN_SECRET

Synopsis

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"

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 Tweet Source #

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.

Constructors

Tweet 

Instances

Generic Tweet Source # 

Associated Types

type Rep Tweet :: * -> * #

Methods

from :: Tweet -> Rep Tweet x #

to :: Rep Tweet x -> Tweet #

Default Tweet Source # 

Methods

def :: Tweet #

type Rep Tweet Source # 
type Rep Tweet = D1 * (MetaData "Tweet" "Web.Tweet.Types" "tweet-hs-1.0.1.35-Gw9iLzkhNZ7O8oCAQsoJq" False) (C1 * (MetaCons "Tweet" PrefixI True) ((:*:) * (S1 * (MetaSel (Just Symbol "_status") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * String)) ((:*:) * (S1 * (MetaSel (Just Symbol "_handles") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * [String])) (S1 * (MetaSel (Just Symbol "_replyID") NoSourceUnpackedness NoSourceStrictness DecidedLazy) (Rec0 * (Maybe Int))))))

data TweetEntity Source #

Data type for tweets as they are returned

Instances

Eq TweetEntity Source # 
Show TweetEntity Source # 
Generic TweetEntity Source # 

Associated Types

type Rep TweetEntity :: * -> * #

Default TweetEntity Source # 

Methods

def :: TweetEntity #

type Rep TweetEntity 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.

status :: Lens' Tweet String Source #

Lens for Tweet accessing the status field.

handles :: Lens' Tweet [String] Source #

Lens for Tweet accessing the handles field.

replyID :: Lens' Tweet (Maybe Int) Source #

Lens for Tweet accessing the _replyID field.

text :: Lens' TweetEntity String Source #

Lens for TweetEntity accessing the _text field.

name :: Lens' TweetEntity String Source #

Lens for TweetEntity accessing the _name 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

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.

showTimeline :: Int -> Bool -> FilePath -> IO String Source #

Display user timeline

showTweets :: Bool -> Either (ParseError Char Void) Timeline -> String Source #

Display user timeline in color, as appropriate

showFavorites :: Int -> String -> Bool -> FilePath -> IO String Source #

Display a user's favorites

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

oAuthMem Source #

Arguments

:: ByteString

API key

-> ByteString

API secret

-> OAuth 

Create an OAuth api key from two ByteStrings.

credentialMem Source #

Arguments

:: ByteString

Token

-> ByteString

Token secret

-> Credential 

Functions to generate a URL string from a Tweet

urlString :: Tweet -> String Source #

print output of a request and return status id as an Int.

Convert a tweet to a percent-encoded url for querying an API

Timeline filters

filterReplies :: Timeline -> Timeline Source #

Filter out replies

filterRTs :: Timeline -> Timeline Source #

Filter out retweets

filterQuotes :: Timeline -> Timeline Source #

Filter out quotes

Helper function to print a bird