SHARE
TWEET

Commands.hs

a guest Dec 2nd, 2013 11 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Commands where
  2.         -- Cambiar todas los parámetros por listas, así reducimos las llamadas y podemos usar la intensional
  3.         type IrcCommand = String
  4.         type UserName = String
  5.         type HostName = String
  6.         type ServerName = String
  7.         type NickName = String
  8.         type NickPass = String
  9.         type Message = String
  10.         type MessageTarget = String
  11.         type ChannelServ = String
  12.         type NewTopic = String
  13.        
  14.         -- Login && Connect
  15.        
  16.         getUser :: UserName -> HostName -> ServerName -> NickName -> IrcCommand
  17.         getUser u h s n = "USER " ++ u ++ " " ++ h ++ " " ++ s ++ " " ++ n
  18.        
  19.         getNick :: NickName -> IrcCommand
  20.         getNick n = "NICK " ++ n
  21.        
  22.         joinIrc :: ChannelServ -> IrcCommand
  23.         joinIrc c = "JOIN " ++ c
  24.        
  25.         -- User Functions
  26.        
  27.         setName :: NickName -> IrcCommand
  28.         setName n = "SETNAME " ++ n
  29.        
  30.         quit :: Message -> IrcCommand
  31.         quit m = "QUIT " ++ m
  32.        
  33.         -- Ejemplo Gestión:
  34.         setPass :: [NickPass] -> IrcCommand
  35.         setPass xs = "PASS " ++ (xs!!1)
  36.        
  37.         -- Message Functions
  38.        
  39.         privMsg :: MessageTarget -> Message -> IrcCommand
  40.         privMsg mt m= "PRIVMSG " ++ mt ++ " " ++ m
  41.        
  42.         changeTopic :: [String] -> IrcCommand
  43.         changeTopic xs = "TOPIC " ++ (xs!!1) ++ " " ++ (xs!!2)
  44.        
  45.         -- Other Functions
  46.        
  47.         listAllUsers :: IrcCommand
  48.         listAllUsers = "LIST"
  49.        
  50.         --whoisUser :: NickName -> IrcCommand
  51.         --whoisUser
  52.        
  53.         --banUser :: NickName -> IrcCommand
  54.         --banUser x = "/mode +b " ++ "show(Socket.send(getUserIp x))"
  55.        
  56.         --pingUsers :: [String] -> IrcCommand
  57.         --pingUsers [] = ""
  58.         --pingUsers (x:xs) = "PING " ++ (concatUsers (x:xs))
  59.        
  60.         --concatUsers :: [NickName] -> String
  61.         --concatUsers [] = ""
  62.         -- Se concatenarán todos los usuarios activos, se usará para hacer ping global
  63.         --concatUsers (x:xs) = show(Socket.send(getUserIP x)) ++ (concatUsers xs)
  64.        
  65.         getUserIP :: [NickName] -> ircCommand
  66.         getUserIP xs = "USERIP " ++ (xs!!1)
  67.         -- Admin Functions
  68.        
  69.         kickUser :: ChannelServ -> NickName -> IrcCommand
  70.         kickUser c n = "KICK " ++ c ++ " " ++ n
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top