Skip to content

Commit d9e6dc5

Browse files
authored
Merge pull request #151 from Bongo50/refresh
Refresh
2 parents 556e984 + e167b2e commit d9e6dc5

32 files changed

+631
-340
lines changed

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
.env
44
db.*
55
database*
6-
*.cabal
7-
stack.yaml.lock
86
.gitattributes
97
.vscode
8+
dist-newstyle/
9+
cabal.project.local

Dockerfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# stack resolver 18.18 uses ghc 8.10.7
2-
FROM haskell:8.10.7 as build
1+
# stack resolver 24.10 uses ghc 9.10.2 - when upgrading LTS version in stack.yaml, check Haskell version on https://www.stackage.org/ and check which Debian release is available on https://hub.docker.com/_/haskell/
2+
FROM haskell:9.10.2-bullseye as build
33
RUN mkdir -p /tablebot/build
44
WORKDIR /tablebot/build
55

66
# system lib dependencies
7-
RUN sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list && \
8-
apt-get update -qq && \
7+
RUN apt-get update -qq && \
98
apt-get install -qq -y libpcre3-dev build-essential pkg-config libicu-dev --fix-missing --no-install-recommends && \
109
apt-get clean && \
1110
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
@@ -16,12 +15,12 @@ RUN stack build --system-ghc
1615

1716
RUN mv "$(stack path --local-install-root --system-ghc)/bin" /tablebot/build/bin
1817

19-
FROM haskell:8.10.7-slim as app
18+
# ensure this matches first FROM
19+
FROM haskell:9.10.2-slim-bullseye as app
2020

21-
# system runtime deps
22-
RUN sed -i s/deb.debian.org/archive.debian.org/g /etc/apt/sources.list && \
23-
apt-get update -qq && \
24-
apt-get install -qq -y libpcre3 libicu63 --fix-missing --no-install-recommends && \
21+
# system runtime deps - if this command fails, check libicu version (https://packages.debian.org/index) and upgrade if necessary
22+
RUN apt-get update -qq && \
23+
apt-get install -qq -y libpcre3 libicu67 --fix-missing --no-install-recommends && \
2524
apt-get clean && \
2625
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
2726

cabal.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
packages: .
2+
3+
source-repository-package
4+
type: git
5+
location: [email protected]:L0neGamer/haskell-distribution.git
6+
tag: 569d6452e4bffedb2c0d3795885fccdb22a4d29d
7+
8+
source-repository-package
9+
type: git
10+
location: [email protected]:L0neGamer/duckling.git
11+
tag: f22e3cdd7b77977fe3e9ec75fccd9a0f79c47f97

package.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ library:
100100
- TypeOperators
101101
- RankNTypes
102102
- BangPatterns
103+
- ViewPatterns
103104
ghc-options:
104105
- -Wall
105106

src/Tablebot.hs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import Data.Map as M (empty)
2727
import Data.Maybe (fromMaybe)
2828
import Data.Text (Text, pack)
2929
import qualified Data.Text as T
30-
import Data.Text.Encoding (encodeUtf8)
3130
import Database.Persist.Sqlite
3231
( runMigration,
3332
runSqlPool,
@@ -38,7 +37,6 @@ import Discord.Internal.Rest
3837
import LoadEnv (loadEnv)
3938
import Paths_tablebot (version)
4039
import System.Environment (getEnv, lookupEnv)
41-
import System.Exit (die)
4240
import Tablebot.Handler (eventHandler, killCron, runCron, submitApplicationCommands)
4341
import Tablebot.Internal.Administration
4442
( ShutdownReason (Reload),
@@ -144,13 +142,8 @@ runTablebot vinfo dToken prefix dbpath plugins config =
144142
activityStatus =
145143
UpdateStatusOpts
146144
{ updateStatusOptsSince = Nothing,
147-
updateStatusOptsGame =
148-
Just
149-
( def
150-
{ activityName = gamePlaying config prefix,
151-
activityType = ActivityTypeGame
152-
}
153-
),
145+
updateStatusOptsActivities =
146+
[mkActivity (gamePlaying config prefix) ActivityTypeGame],
154147
updateStatusOptsNewStatus = UpdateStatusOnline,
155148
updateStatusOptsAFK = False
156149
}

src/Tablebot/Handler.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ submitApplicationCommands compiledAppComms cacheMVar =
127127
Nothing -> pure ()
128128
Just serverIdStr -> do
129129
serverId <- readServerStr serverIdStr
130-
aid <- partialApplicationID . cacheApplication <$> readCache
130+
aid <- fullApplicationID . cacheApplication <$> readCache
131131
applicationCommands <-
132132
mapM
133133
( \(CApplicationCommand cac action) -> do

src/Tablebot/Internal/Administration.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ module Tablebot.Internal.Administration
1414
)
1515
where
1616

17-
import Control.Monad.Cont (MonadIO, void, when)
17+
import Control.Monad (void, when)
18+
import Control.Monad.IO.Class (MonadIO)
1819
import Data.List.Extra (isInfixOf, lower, trim)
1920
import Data.Text (Text, pack)
2021
import Database.Persist

src/Tablebot/Internal/Alias.hs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,21 @@
1010
module Tablebot.Internal.Alias where
1111

1212
import Control.Monad.Exception (MonadException (catch), SomeException)
13-
import Data.Text
13+
import qualified Data.Text as T
1414
import Database.Persist.Sqlite (BackendKey (SqlBackendKey))
1515
import qualified Database.Persist.Sqlite as Sql
1616
import Database.Persist.TH
1717
import Discord.Types
1818
import Tablebot.Internal.Administration (currentBlacklist)
1919
import Tablebot.Internal.Types
20-
import Tablebot.Utility.Database (liftSql, selectList)
21-
import Tablebot.Utility.Types (EnvDatabaseDiscord)
20+
import Tablebot.Utility.Types (EnvDatabaseDiscord, liftSql)
2221

2322
share
2423
[mkPersist sqlSettings, mkMigrate "aliasMigration"]
2524
[persistLowerCase|
2625
Alias
27-
alias Text
28-
command Text
26+
alias T.Text
27+
command T.Text
2928
type AliasType
3029
UniqueAlias alias type
3130
deriving Show
@@ -38,5 +37,5 @@ getAliases uid = do
3837
if "alias" `elem` blacklist
3938
then return Nothing
4039
else
41-
(Just . fmap Sql.entityVal <$> selectList [AliasType Sql.<-. [AliasPublic, AliasPrivate uid]] [])
40+
liftSql (Just . fmap Sql.entityVal <$> Sql.selectList [AliasType Sql.<-. [AliasPublic, AliasPrivate uid]] [])
4241
`catch` (\(_ :: SomeException) -> return Nothing)

src/Tablebot/Internal/Handler/Command.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ module Tablebot.Internal.Handler.Command
1717
)
1818
where
1919

20+
import qualified Data.Functor as Functor
2021
import Data.List (find)
2122
import qualified Data.List.NonEmpty as NE
2223
import Data.Maybe (catMaybes)
@@ -125,18 +126,17 @@ instance ShowErrorComponent ReadableError where
125126

126127
makeBundleReadable :: ParseErrorBundle Text Void -> (ParseErrorBundle Text ReadableError, String)
127128
makeBundleReadable (ParseErrorBundle errs state) =
128-
let (errors, title) = NE.unzip $ NE.map makeReadable errs
129+
let (errors, title) = Functor.unzip $ NE.map makeReadable errs
129130
in (ParseErrorBundle errors state, getTitle $ NE.toList title)
130131
where
131132
getTitle :: [Maybe String] -> String
132133
-- Safety proof for application of `head`: we filter by `not . null` so each element is nonempty.
133134
getTitle titles = case filter (not . null) $ catMaybes titles of
134135
-- therefore, `x` is nonempty, so `lines x` is nonempty, meaning that `head (lines x)` is fine,
135136
-- since `lines x` is nonempty for nonempty input.
136-
(x : xs) ->
137-
let title = head (lines x)
138-
in if null xs then title else title ++ " (and " ++ show (length xs) ++ " more)"
139-
[] -> "Parser Error!"
137+
((NE.nonEmpty . lines -> Just (title NE.:| _)) : xs) ->
138+
if null xs then title else title ++ " (and " ++ show (length xs) ++ " more)"
139+
_ -> "Parser Error!"
140140

141141
-- | Transform our errors into more useful ones.
142142
-- This uses the Label hidden within each error to build an error message,

src/Tablebot/Internal/Types.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ instance PersistField AliasType where
127127
toPersistValue AliasPublic = PersistInt64 (-1)
128128
fromPersistValue = \case
129129
PersistInt64 (-1) -> Right AliasPublic
130-
PersistInt64 i -> Right $ AliasPrivate (fromIntegral i)
130+
PersistInt64 i -> Right $ AliasPrivate (DiscordId (Snowflake (fromIntegral i)))
131131
_ -> Left "AliasType: fromPersistValue: Invalid value"
132132

133133
instance PersistFieldSql AliasType where

0 commit comments

Comments
 (0)