tweet-hs-1.0.1.1: 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"

Data type for a tweet

data Tweet Source #

Data type for our request: consists of the status text, whether to trium user 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 # 

data TweetEntity Source #

Data type for tweets as they are returned

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

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

Functions to generate a URL string from a Tweet

urlString :: Tweet -> String Source #

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

Helper function to print a bird