aboutsummaryrefslogtreecommitdiffstats
path: root/src/Plugin/GitHubCommit.hs
blob: 4175fb8e453ee48488ca58c47d9ae7c97f991933 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
module Plugin.GitHubCommit
    ( gitHubCommit
    ) where

import Text.Regex.TDFA

import qualified Message as M
import Plugin.Base

gitHubCommit = Plugin
    { matchRegex = "^[0-9a-f]{40}$"
    , perform = gitHubCommitAction
    }

gitHubCommitAction :: PluginAction
gitHubCommitAction message =
    "https://github.com/" ++ M.text message =~ matchRegex gitHubCommit

type Id = Int

type RepoUrl = String

-- | A type to match the database table for this plugin.
data ChannelRepoUrl = ChannelRepoUrl Id M.Channel RepoUrl deriving (Show)

instance FromRow ChannelRepoUrl where
    fromRow = ChannelRepoUrl <$> field <*> field <*> field