Skip to content

Commit c91e811

Browse files
authored
Fix Heroku Key-Value Store connection and remove Reddit (#83)
* Update Gradle and JDK * Remove Reddit skill * Modify Lettuce connection to match Heroku recommended setup
1 parent a45c8d4 commit c91e811

File tree

15 files changed

+236
-284
lines changed

15 files changed

+236
-284
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ In order to host your own copy of Glyph, some set up will be required.
2222
- All references entities must be understood too
2323
- A free ("Trial") plan is sufficient
2424
- You should disable "Log interaction to Dialogflow"
25-
2. Create a Reddit application for the Reddit skill
26-
3. Create a PostgreSQL database and Redis data store
27-
4. Set the needed environment variables as seen in the application.conf files
28-
5. Build and start the bot and config website
25+
2. Create a PostgreSQL database and Redis data store
26+
3. Set the needed environment variables as seen in the application.conf files
27+
4. Build and start the bot and config website
2928

3029
## License
3130

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ subprojects {
2222

2323
dependencies {
2424
implementation("net.dv8tion:JDA:$jdaVersion")
25-
implementation("io.lettuce:lettuce-core:6.0.0.M1")
25+
implementation("io.lettuce:lettuce-core:6.4.0.RELEASE")
2626
implementation("ch.qos.logback:logback-classic:$logbackVersion")
2727
testImplementation(kotlin("test"))
2828
}

docs/skills.rst

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,6 @@ Example phrases:
127127
- roles list
128128
- list roles
129129

130-
Images
131-
------
132-
Glyph can pull images from Reddit_ when asked. As of right now, these can either be memes, cats, snakes, birds, dogs and lizards.
133-
134-
.. _Reddit: https://reddit.com/
135-
136-
Example phrases:
137-
138-
- image from **coaxedintoasnafu**
139-
- image from **youdontsurf**
140-
- **meme**
141-
142130
QuickView
143131
---------
144132
Glyph can post helpful embeds that include additional information for links from `Fur Affinity`_ and Picarto_. This feature can be controlled in the :doc:`/configuration`.
@@ -229,4 +217,4 @@ There are a few other tiny fun/easter egg skills that are so small they don't de
229217
Some hints are to what they are are NumberWang, Dad jokes, jokes, the Doomsday Clock, `snowstamp`_, magic 8-ball and a few others.
230218

231219
.. _snowstamp: https://pixelatomy.com/snow-stamp/
232-
.. _official server: https://gl.yttr.org/server
220+
.. _official server: https://gl.yttr.org/server

glyph-bot/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ dependencies {
2424
implementation("club.minnced:discord-webhooks:0.5.7")
2525
implementation("com.google.cloud:google-cloud-storage:1.106.0")
2626
implementation("com.google.cloud:google-cloud-dialogflow:1.0.0")
27-
implementation("net.dean.jraw:JRAW:1.1.0")
2827
implementation("org.ocpsoft.prettytime:prettytime:4.0.4.Final")
2928
implementation("io.ktor:ktor-client-okhttp:$ktorVersion")
3029
implementation("io.ktor:ktor-client-json-jvm:$ktorVersion")

glyph-bot/src/main/kotlin/Glyph.kt

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,30 @@ import org.yttr.glyph.bot.skills.SkillDirector
2020
import org.yttr.glyph.bot.skills.config.ConfigDirector
2121
import org.yttr.glyph.bot.skills.config.ServerConfigSkill
2222
import org.yttr.glyph.bot.skills.creator.ChangeStatusSkill
23-
import org.yttr.glyph.bot.skills.moderation.*
23+
import org.yttr.glyph.bot.skills.moderation.AuditingDirector
24+
import org.yttr.glyph.bot.skills.moderation.BanSkill
25+
import org.yttr.glyph.bot.skills.moderation.GuildInfoSkill
26+
import org.yttr.glyph.bot.skills.moderation.KickSkill
27+
import org.yttr.glyph.bot.skills.moderation.PurgeSkill
28+
import org.yttr.glyph.bot.skills.moderation.UserInfoSkill
2429
import org.yttr.glyph.bot.skills.play.DoomsdayClockSkill
2530
import org.yttr.glyph.bot.skills.play.EphemeralSaySkill
2631
import org.yttr.glyph.bot.skills.play.RankSkill
27-
import org.yttr.glyph.bot.skills.play.RedditSkill
2832
import org.yttr.glyph.bot.skills.roles.RoleListSkill
2933
import org.yttr.glyph.bot.skills.roles.RoleSetSkill
3034
import org.yttr.glyph.bot.skills.roles.RoleUnsetSkill
3135
import org.yttr.glyph.bot.skills.starboard.StarboardDirector
32-
import org.yttr.glyph.bot.skills.util.*
36+
import org.yttr.glyph.bot.skills.util.FallbackSkill
37+
import org.yttr.glyph.bot.skills.util.FeedbackSkill
38+
import org.yttr.glyph.bot.skills.util.HelpSkill
39+
import org.yttr.glyph.bot.skills.util.SnowstampSkill
40+
import org.yttr.glyph.bot.skills.util.SourceSkill
41+
import org.yttr.glyph.bot.skills.util.StatusSkill
42+
import org.yttr.glyph.bot.skills.util.TimeSkill
3343
import org.yttr.glyph.bot.skills.wiki.WikiSkill
3444
import org.yttr.glyph.shared.pubsub.redis.RedisAsync
3545

46+
3647
/**
3748
* The Glyph object to use when building the client
3849
*/
@@ -49,13 +60,14 @@ object Glyph {
4960

5061
private val aiAgent: AIAgent = Dialogflow(conf.getString("dialogflow.credentials").byteInputStream())
5162

52-
private val redis: RedisAsync = RedisClient.create().run {
53-
val redisUri = RedisURI.create(conf.getString("data.redis-url")).apply {
54-
// We are using Heroku Redis which is version 5, but for some reason they give us a username.
55-
// However if we supply the username it runs the version 6 command and fails to login.
56-
username = null
57-
}
58-
connect(redisUri).async()
63+
private val redis: RedisAsync = let {
64+
// https://devcenter.heroku.com/articles/connecting-heroku-redis#lettuce
65+
val uri = RedisURI.create(conf.getString("data.redis-url"))
66+
uri.isVerifyPeer = false
67+
68+
val client = RedisClient.create(uri)
69+
val connection = client.connect()
70+
connection.async()
5971
}
6072

6173
private val configDirector = ConfigDirector {
@@ -77,7 +89,6 @@ object Glyph {
7789
BanSkill(),
7890
RankSkill(),
7991
EphemeralSaySkill(),
80-
RedditSkill(),
8192
WikiSkill(),
8293
TimeSkill(),
8394
FeedbackSkill(),

glyph-bot/src/main/kotlin/skills/play/RedditSkill.kt

Lines changed: 0 additions & 114 deletions
This file was deleted.

glyph-bot/src/main/resources/application.conf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,4 @@ glyph {
2727
}
2828
// Bot list website statistics
2929
bot-list.top = ${?DISCORDBOTLIST_TOKEN}
30-
// Skills related settings
31-
skills {
32-
// Reddit authentication
33-
reddit {
34-
// Your username, do not lie to Reddit
35-
username = ${REDDIT_USERNAME}
36-
client-id = ${REDDIT_CLIENT_ID}
37-
client-secret = ${REDDIT_CLIENT_SECRET}
38-
}
39-
}
4030
}

glyph-bot/src/main/resources/logback.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@
1212
<logger name="io.lettuce.core.protocol.ConnectionWatchdog" level="WARN"/>
1313
<logger name="io.lettuce.core.protocol.ReconnectionHandler" level="WARN"/>
1414
<logger name="club.minnced.discord.webhook.WebhookClient" level="OFF"/>
15-
<logger name="RedditSkill" level="DEBUG"/>
1615
</configuration>

glyph-shared/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ dependencies {
77
implementation("org.jetbrains.exposed:exposed-core:$exposedVersion")
88
implementation("org.jetbrains.exposed:exposed-jdbc:$exposedVersion")
99
implementation("org.jetbrains.exposed:exposed-java-time:$exposedVersion")
10-
implementation("org.postgresql:postgresql:42.3.3")
10+
implementation("org.postgresql:postgresql:42.7.4")
1111
}

glyph-shared/src/main/kotlin/pubsub/redis/RedisPubSub.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,13 @@ class RedisPubSub(configure: Config.() -> Unit) : PubSub {
2626
}
2727

2828
private val config = Config().also(configure)
29-
private val redis = RedisClient.create(RedisURI.create(config.redisConnectionUri).apply { username = null })
29+
private val redis = let {
30+
// https://devcenter.heroku.com/articles/connecting-heroku-redis#lettuce
31+
val uri = RedisURI.create(config.redisConnectionUri)
32+
uri.isVerifyPeer = false
33+
34+
RedisClient.create(uri)
35+
}
3036
private val redisCommandsAsync = redis.connect().async()
3137
private val redisPubSubConnection: StatefulRedisPubSub = redis.connectPubSub()
3238

0 commit comments

Comments
 (0)