Skip to content

Commit

Permalink
Moved plugins to plugins.old
Browse files Browse the repository at this point in the history
  • Loading branch information
ori-sky committed Jul 31, 2014
1 parent e704764 commit a0bdd25
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
52 changes: 52 additions & 0 deletions plugins.old/Mode.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{- Copyright 2014 David Farrell <[email protected]>
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-}

module Mode where

import Data.List (nub)
import Data.Maybe (fromMaybe)
import qualified Data.Map as M
import qualified Data.IntMap as IM
import IRC.Message
import IRC.Numeric
import IRC.Action
import qualified IRC.Server.Client as Client
import qualified IRC.Server.Channel as Chan
import IRC.Server.Client.Helper
import IRC.Server.Channel.Helper
import IRC.Server.Environment (whenRegistered)
import qualified IRC.Server.Environment as Env
import Config
import Plugin

plugin = defaultPlugin {handlers=[CommandHandler "MODE" mode]}

mode :: CommandHSpec
mode env (Message _ _ (chan@('#':_):xs)) = whenRegistered env $ env {Env.actions=a:Env.actions env}
where
locChans = Env.channels (Env.local env)
aMsg e = do
sendChannelOthersFromClient (Env.client e) e (Env.channels l M.! chan) $ "PRIVMSG " ++ chan ++ " :" ++ text
return e
where l = Env.local e
aNoSuch e = sendNumeric e numERR_NOSUCHCHANNEL [chan, "No such channel"] >> return e
a = if M.member chan locChans
then ChanAction "Mode" chan aMsg
else GenericAction aNoSuch
mode env (Message _ _ (chan:_)) = whenRegistered env $ env {Env.actions=a:Env.actions env}
where a = GenericAction $ \e -> sendNumeric e numERR_BADCHANNAME [chan, "Illegal channel name (no umodes yet)"]
>> return e
mode env _ = whenRegistered env $ env {Env.actions=a:Env.actions env}
where a = GenericAction $ \e -> sendNumeric e numERR_NEEDMOREPARAMS ["MODE", "Not enough parameters"] >> return e
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a0bdd25

Please sign in to comment.