tweet-hs 0.5.3.4 → 0.5.3.5
raw patch · 7 files changed
+86/−18 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- src/Web/Tweet/API.hs +1/−2
- src/Web/Tweet/Exec.hs +1/−1
- src/Web/Tweet/Parser.hs +1/−1
- src/Web/Tweet/Sign.hs +8/−7
- src/Web/Tweet/Utils/API.hs +13/−5
- stack.yaml +61/−1
- tweet-hs.cabal +1/−1
src/Web/Tweet/API.hs view
@@ -36,10 +36,9 @@ tweetData :: Tweet -> FilePath -> IO Int tweetData tweet filepath = do let requestString = urlString tweet- bytes <- postRequest ("https://api.twitter.com/1.1/statuses/update.json" ++ requestString) filepath+ bytes <- postRequest ("https://api.twitter.com/1.1/statuses/update.json" ++ requestString) filepath -- FIXME fix the coloration putStrLn $ displayTimelineColor . either (error "failed to parse tweet") id . getTweets . BSL.toStrict $ bytes pure . (view tweetId) . head . either (error "failed to parse tweet") id . getTweets . BSL.toStrict $ bytes--- FIXME fix the coloration -- | Gets user profile with max_id set. getProfileMax :: String -> Int -> FilePath -> Maybe Int -> IO (Either (ParseError Char Dec) Timeline)
src/Web/Tweet/Exec.hs view
@@ -80,7 +80,7 @@ selectCommand (Sort name maybeNum) color file = putStrLn =<< showBest name (maybe 11 id maybeNum) color file selectCommand (Markov name) _ file = do raw <- getMarkov name Nothing file- writeFile (name ++ ".txt") (unlines raw)+ appendFile (name ++ ".txt") (unlines raw) putStrLn $ "Written output to: " ++ name ++ ".txt" selectCommand (Delete n) color file = do putStrLn "Deleted:\n"
src/Web/Tweet/Parser.hs view
@@ -73,7 +73,7 @@ string $ "\"" <> str <> "\":" open <- optional $ char '\"' let forbidden = if (isJust open) then ("\\\"" :: String) else ("\\\"," :: String)- want <- many $ noneOf forbidden <|> specialChar '\"' <|> specialChar '/' <|> newlineChar <|> unicodeChar -- specialChar 'u'+ want <- many $ noneOf forbidden <|> specialChar '\"' <|> specialChar '/' <|> newlineChar <|> unicodeChar -- TODO modify parsec to make this parallel? pure want -- | Parse a newline
src/Web/Tweet/Sign.hs view
@@ -8,15 +8,10 @@ import Network.HTTP.Client import Web.Tweet.Types --- | Sign a request using your OAuth dev token.+-- | Sign a request using your OAuth dev token, as stored in a config file. -- Uses the IO monad because signatures require a timestamp signRequest :: FilePath -> Request -> IO Request-signRequest filepath req = do- o <- oAuth filepath- c <- credential filepath- signOAuth o c req---- TODO function to read a ~/.tweetrc file to a 'Config'+signRequest = (. flip signRequestMem) . (>>=) . mkConfig -- | Sign a request using a 'Config' object, avoiding the need to read token/key from file signRequestMem :: Config -> Request -> IO Request@@ -29,6 +24,12 @@ key <- (lineByKey "api-key") <$> getConfigData filepath let url = "api.twitter.com" return newOAuth { oauthConsumerKey = key , oauthConsumerSecret = secret , oauthServerName = url }++mkConfig :: FilePath -> IO Config+mkConfig filepath = do+ o <- oAuth filepath+ c <- credential filepath+ pure (o, c) -- | Create a new credential from a token and token secret credential :: FilePath -> IO Credential
src/Web/Tweet/Utils/API.hs view
@@ -17,19 +17,27 @@ import Web.Tweet.Sign -- | Make a GET request to twitter given a request string-getRequest :: String -> FilePath -> IO BSL.ByteString-getRequest urlStr filepath = do+getRequestMem :: String -> Config -> IO BSL.ByteString+getRequestMem urlStr config = do manager <- newManager tlsManagerSettings initialRequest <- parseRequest urlStr- request <- signRequest filepath $ initialRequest { method = "GET" }+ request <- signRequestMem config $ initialRequest { method = "GET" } responseBS request manager +-- | Make a GET request to twitter given a request string+getRequest :: String -> FilePath -> IO BSL.ByteString+getRequest = flip ((. getRequestMem) . (>>=) . mkConfig)+ -- | Make a POST request to twitter given a request string postRequest :: String -> FilePath -> IO BSL.ByteString-postRequest urlStr filepath = do+postRequest = flip ((. postRequestMem) . (>>=) . mkConfig)++-- | Make a POST request to twitter given a request string+postRequestMem :: String -> Config -> IO BSL.ByteString+postRequestMem urlStr config = do manager <- newManager tlsManagerSettings initialRequest <- parseRequest urlStr- request <- signRequest filepath $ initialRequest { method = "POST" }+ request <- signRequestMem config $ initialRequest { method = "POST" } responseBS request manager -- | Return HTTP request's result as a bytestring
stack.yaml view
@@ -1,6 +1,66 @@-resolver: lts-8.6+# This file was automatically generated by 'stack init'+#+# Some commonly used options have been documented as comments in this file.+# For advanced use and comprehensive documentation of the format, please see:+# http://docs.haskellstack.org/en/stable/yaml_configuration/++# Resolver to choose a 'specific' stackage snapshot or a compiler version.+# A snapshot resolver dictates the compiler version and the set of packages+# to be used for project dependencies. For example:+#+# resolver: lts-3.5+# resolver: nightly-2015-09-21+# resolver: ghc-7.10.2+# resolver: ghcjs-0.1.0_ghc-7.10.2+# resolver:+# name: custom-snapshot+# location: "./custom-snapshot.yaml"+resolver: lts-8.11++# User packages to be built.+# Various formats can be used as shown in the example below.+#+# packages:+# - some-directory+# - https://example.com/foo/bar/baz-0.0.2.tar.gz+# - location:+# git: https://github.com/commercialhaskell/stack.git+# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a+# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a+# extra-dep: true+# subdirs:+# - auto-update+# - wai+#+# A package marked 'extra-dep: true' will only be built if demanded by a+# non-dependency (i.e. a user package), and its test suites and benchmarks+# will not be run. This is useful for tweaking upstream packages. packages: - '.'+# Dependency packages to be pulled from upstream that are not in the resolver+# (e.g., acme-missiles-0.3) extra-deps: []++# Override default flag values for local packages and extra-deps flags: {}++# Extra package databases containing global packages extra-package-dbs: []++# Control whether we use the GHC we find on the path+# system-ghc: true+#+# Require a specific version of stack, using version ranges+# require-stack-version: -any # Default+# require-stack-version: ">=1.4"+#+# Override the architecture used by stack, especially useful on Windows+# arch: i386+# arch: x86_64+#+# Extra directories used by stack for building+# extra-include-dirs: [/path/to/dir]+# extra-lib-dirs: [/path/to/dir]+#+# Allow a newer minor version of GHC than the snapshot specifies+# compiler-check: newer-minor
tweet-hs.cabal view
@@ -1,5 +1,5 @@ name: tweet-hs-version: 0.5.3.4+version: 0.5.3.5 synopsis: Command-line tool for twitter description: a Command Line Interface Tweeter homepage: https://github.com/vmchale/command-line-tweeter#readme