Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cabalized

  • Loading branch information...
commit 1981fd7a95b14a97045f2f80d130d3a81689c67e 1 parent b6d84f0
nlogax authored
View
19 Settings.hs
@@ -1,19 +0,0 @@
-module Settings where
-
-import Data.List
-
-server = "chat.us.freenode.net"
-port = 6667 :: Int
-nick = "ultror"
-name = "ultror"
-
-channels = intercalate "," ["#clojure",
- "#jquery",
- "#jquery-ot",
- "#runlevel6",
- "#ultror"]
-
--- Authorized bot wranglers
-admins = nicks ["ajpiano akahn BBonifield coldhead gf3 matjas miketaylr",
- "nimbupani nlogax paul_irish seutje temp01"]
- where nicks = words . unlines
View
12 norby.cabal
@@ -44,11 +44,21 @@ Cabal-version: >=1.2
Executable norby
+ hs-source-dirs: src
-- .hs or .lhs file containing the Main module.
Main-is: Main.hs
-- Packages needed in order to build this package.
- Build-depends: Mueval >= 0.8 <= 1.0
+ Build-depends: base >= 4 && < 5
+ Build-depends: bson >= 0.0.3 && <= 0.1
+ Build-depends: hint >= 0.3 && <= 1.0
+ Build-depends: monads-fd >= 0.1 && <= 1.0
+ Build-depends: mongoDB >= 0.7 && <= 1.0
+ Build-depends: mueval >= 0.8 && <= 1.0
+ Build-depends: network >= 2.2 && <= 2.3
+ Build-depends: parsec >= 2.0 && <= 3.0
+ Build-depends: process >= 1.0 && <= 2.0
+ Build-depends: time >= 1.1.4 && <= 1.2
-- Modules not exported by this package.
-- Other-modules:
View
0  Eval.hs → src/Eval.hs
File renamed without changes
View
17 IRC.hs → src/IRC.hs
@@ -32,9 +32,10 @@ socket (Bot h) = h
-- Connect to the server and return the initial bot state
connect :: String -> Int -> IO Bot
-connect s p = notify $ (connectTo s . PortNumber $ fromIntegral p)
- >>= ap ((>> return) . const
- . flip hSetBuffering NoBuffering) Bot
+connect s p = notify $ do
+ h <- connectTo s $ PortNumber (fromIntegral p)
+ hSetBuffering h NoBuffering
+ return $ Bot h
where notify a = bracket_
(print ("Connecting to " ++ s ++ "...") >> hFlush stdout)
(print "It is so.") a
@@ -42,9 +43,11 @@ connect s p = notify $ (connectTo s . PortNumber $ fromIntegral p)
-- write $ Message (Maybe ett prefix) Command [parametrar]
-- write $ Message Nothing "LOL" ["nyeyhehe"]
write :: Message -> Net ()
-write msg = asks socket >>= \h -> liftIO $ hPrint h msg
- >> S.store msg
- >> (putStrLn $ "sent: " ++ (show msg))
+write msg = do
+ h <- asks socket
+ liftIO $ hPrint h msg
+ liftIO $ S.store msg
+ liftIO . putStrLn $ "sent: " ++ (show msg)
-- Process lines from the server
listen :: Handle -> Net ()
@@ -80,7 +83,5 @@ privmsg :: Param -> Param -> Net ()
privmsg c m = write $ Message Nothing "PRIVMSG" [c, U.excerpt' m]
join ps = write $ Message Nothing "JOIN" ps
-
part ps = write $ Message Nothing "PART" ps
-
quit ps = write $ Message Nothing "QUIT" ps
View
42 L.hs → src/L.hs
@@ -4,6 +4,7 @@
module L where
+import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.State
@@ -12,6 +13,7 @@ import Data.Char
import Data.Function
import Data.Functor
import Data.List
+import Data.List.Split
import Data.Maybe
import Data.Monoid
import Data.Ratio
@@ -41,8 +43,8 @@ oOo [] = [];
oOo s = concat [init s, [toUpper (last s)], tail (reverse s)]
type Peen = String
-ben :: Int -> Peen
-ben = ('8' :) . (++ "D") . flip replicate '='
+ben :: Integer -> Peen
+ben = ('8' :) . (++ "D") . flip genericReplicate '='
fap = fmap
@@ -54,11 +56,9 @@ gf n | n < 0 = "NEGATIVE U"
ajpiano = "PANDEMONIUM!!!" :: String
-akahn :: String -> String
-akahn s | null ts = "that ain't shit"
- | "?" `isSuffixOf` s = "did you mean " ++ s
- | otherwise = "that's not " ++ s
- where ts = trim s
+akahn :: Integer -> String
+akahn 0 = "akahn :)"
+akahn n = "AK" ++ genericReplicate n 'A' ++ "HN!!"
coldhead :: String -> String
coldhead s | null s = ">: |"
@@ -79,6 +79,7 @@ miketaylr s | null ts = "here, let me open that... wait a minute, there's noth
nlogax = (++ "n't") :: String -> String
paul_irish = ($) :: (effin -> rad) -> effin -> rad
+rwaldron = (++ ". Questions?") :: String -> String
sean = "koole" :: String
seutje = ("I would of " ++) :: String -> String
temp01 = Just "awesome" :: Maybe String
@@ -92,6 +93,33 @@ trim = trim' . trim'
dropInit = take 1 . reverse
+relTime t | t < s = ["now"]
+ | t == s = ["1 second"]
+ | t < m = [show t ++ " seconds"]
+ | t < m * 2 = ["1 minute"] ++ rest m
+ | t < h = [first m ++ " minutes"] ++ rest m
+ | t < h * 2 = ["1 hour"] ++ rest h
+ | t < d = [first h ++ " hours"] ++ rest h
+ | t < d * 2 = ["1 day"] ++ rest d
+ | t < w = [first d ++ " days"] ++ rest d
+ | t < w * 2 = ["1 week"] ++ rest w
+ | t < w * 4 = [first w ++ " weeks"] ++ rest w
+ | otherwise = ["a long time"]
+ where first = show . div t
+ rest v | mod t v == 0 = []
+ | otherwise = relTime $ mod t v
+ s = 1; m = s * 60; h = m * 60; d = h * 24; w = d * 7
+
+concatTime [] = []
+concatTime xss@(x:_) | x == "now" = x
+ | 1 == length xss = printf "%s ago." $ concat xss
+ | otherwise = printf "%s and %s ago."
+ (intercalate ", " $ init xss)
+ $ last xss
+
-- Omg postfix function application so you can `car & drive` instead of `drive car`!
infixl 0 &
x & f = f x
+
+ftoc t = 5/9 * (t - 32)
+ctof t = (9/5 * t) + 32
View
2  Main.hs → src/Main.hs
@@ -18,7 +18,7 @@ main = bracket (connect server port) disconnect loop
-- Join some channels, and start processing commands
run :: Net ()
run = do
- write $ Message Nothing "USER" [nick, "0", "*", name]
write $ Message Nothing "NICK" [nick]
+ write $ Message Nothing "USER" [nick, "0", "*", name]
write $ Message Nothing "JOIN" [channels]
asks socket >>= listen
View
2  Parser.hs → src/Parser.hs
@@ -5,7 +5,7 @@ import Text.ParserCombinators.Parsec hiding (letter, space)
import Types
parseMessage :: String -> Maybe Message
-parseMessage s = either (const Nothing) Just (parse message "" s)
+parseMessage s = either (const Nothing) Just (parse message "Message" s)
message = do
p <- optionMaybe (char ':' >> prefix >>= (space >>) . return)
View
4 Seen.hs → src/Seen.hs
@@ -73,10 +73,10 @@ escape' (c:cs) = escape c ++ escape' cs
formatSeen nick msg "PRIVMSG" chan
| "\SOHACTION" `isPrefixOf` msg = printf "%s was all like *%s %s* in %s" nick nick
- (U.excerpt' . init . drop 8 $ U.trim msg)
+ (U.excerpt 100 "..." . init . drop 8 $ U.trim msg)
chan
| otherwise = printf "%s said \"%s\" in %s" nick
- (U.excerpt' $ U.trim msg) chan
+ (U.excerpt 100 "..." $ U.trim msg) chan
formatSeen n m cmd c = case cmd of
"PART" -> printf "%s left %s" n c
View
29 src/Settings.hs
@@ -0,0 +1,29 @@
+module Settings where
+
+import Data.List
+
+server = "chat.us.freenode.net"
+port = 6667 :: Int
+nick = "hsbot"
+name = "hsbot"
+
+channels = intercalate "," [ "#clojure"
+ , "#inimino"
+ , "#jquery"
+ , "#jquery-ot"
+ , "#nlogax"
+ , "#runlevel6" ]
+
+-- Authorized bot wranglers
+admins = [ "ajpiano"
+ , "akahn"
+ , "BBonifield"
+ , "coldhead"
+ , "gf3"
+ , "matjas"
+ , "miketaylr"
+ , "nimbupani"
+ , "nlogax"
+ , "paul_irish"
+ , "seutje"
+ , "temp01" ]
View
0  Setup.hs → src/Setup.hs
File renamed without changes
View
0  Types.hs → src/Types.hs
File renamed without changes
View
0  Utils.hs → src/Utils.hs
File renamed without changes
Please sign in to comment.
Something went wrong with that request. Please try again.