hsendxmpp (empty) → 0.1.0.0
raw patch · 5 files changed
+95/−0 lines, 5 filesdep +basedep +hsloggerdep +pontarius-xmppsetup-changed
Dependencies added: base, hslogger, pontarius-xmpp, string-class
Files
- CHANGELOG.md +5/−0
- LICENSE +14/−0
- Main.hs +46/−0
- Setup.hs +2/−0
- hsendxmpp.cabal +28/−0
+ CHANGELOG.md view
@@ -0,0 +1,5 @@+# Revision history for hsendxmpp++## 0.1.0.0 -- YYYY-mm-dd++* First version. Released on an unsuspecting world.
+ LICENSE view
@@ -0,0 +1,14 @@+ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE+ Version 2, December 2004++ Copyright (C) 2004 Sam Hocevar+ 22 rue de Plaisance, 75014 Paris, France+ Everyone is permitted to copy and distribute verbatim or modified+ copies of this license document, and changing it is allowed as long+ as the name is changed.++ DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION++ 0. You just DO WHAT THE FUCK YOU WANT TO.+
+ Main.hs view
@@ -0,0 +1,46 @@+{-# LANGUAGE OverloadedStrings #-}++module Main where++import qualified Data.String.Class as S+import Network.Xmpp+import Network.Xmpp.Internal hiding (priority, status)+import System.Console.GetOpt+import System.Environment+++data Options = Options+ { oUserName :: String+ , oPassWord :: String+ , oServer :: String+ } deriving (Eq, Show)++defaultOptions = Options+ { oUserName = ""+ , oPassWord = ""+ , oServer = ""+ }++options :: [OptDescr (Options -> Options)]+options =+ [ Option ['u'] ["username"] (ReqArg (\str o -> o { oUserName = str }) "user") "Use this username to authenticate to the server"+ , Option ['p'] ["password"] (ReqArg (\str o -> o { oPassWord = str }) "password") "Use this password to authenticate to the server"+ , Option ['j'] ["jserver"] (ReqArg (\str o -> o { oServer = str }) "server") "Connect to this server"+ ]++getOpts :: IO (Options, [String])+getOpts = do+ args <- getArgs+ pn <- getProgName+ case getOpt Permute options args of+ (o,n,[] ) -> return (foldl (flip id) defaultOptions o, n)+ (_,_,errs) -> ioError (userError (concat errs ++ usageInfo ("Usage: " ++ pn ++ " <recipient>") options))++main :: IO ()+main = do+ (opts, recipients) <- getOpts+ text <- getContents+ eSess <- session (oServer opts) (simpleAuth (S.toText $ oUserName opts) (S.toText $ oPassWord opts)) def+ let sess = either (error . show) id $ eSess+ sendPresence presenceOnline sess+ mapM_ (\tjid -> sendMessage ((simpleIM (parseJid tjid) $ S.toText text) { messageType = Chat }) sess >> pure ()) recipients
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ hsendxmpp.cabal view
@@ -0,0 +1,28 @@+-- Initial hsendxmpp.cabal generated by cabal init. For further+-- documentation, see http://haskell.org/cabal/users-guide/++name: hsendxmpp+version: 0.1.0.0+synopsis: sendxmpp clone, sending XMPP messages via CLI+-- description:+license: OtherLicense+license-file: LICENSE+author: Sergey Alirzaev+maintainer: zl29ah@gmail.com+-- copyright:+category: Network+build-type: Simple+extra-source-files: CHANGELOG.md+cabal-version: >=1.10++executable hsendxmpp+ main-is: Main.hs+ ghc-options: -fno-warn-tabs+ -- other-modules:+ -- other-extensions:+ build-depends: base >=4.12 && <4.13,+ pontarius-xmpp >= 0.4.5 && < 0.6,+ hslogger >= 1.2.8 && < 1.4,+ string-class >= 0.1.7.0 && < 0.2+ -- hs-source-dirs:+ default-language: Haskell2010