Skip to content

Commit

Permalink
Add message intent compliance (#70)
Browse files Browse the repository at this point in the history
* Upgrade to Kotlin 1.6.10

Gradle was literally failing otherwise

* Create compliance tracking table

* Create basic compliance prompt when trying to use AI

* Generalize compliance message generation and processing

* Add compliance command and messages for all types

* Check compliance decisions in the Starboard and QuickView listeners

* Fix command choice names

* Use volatile messaging when replying with Dialogflow Compliance

* Update the data collection information to act as a privacy policy

* Add questions section

* Attempt to fix references to other sections

I don't feel like building locally so using RTD to see

* Various doc fixes

Not worth describing

* Remove old annotations
  • Loading branch information
yttrian committed Mar 14, 2022
1 parent 5557173 commit 75fd2d4
Show file tree
Hide file tree
Showing 23 changed files with 578 additions and 96 deletions.
28 changes: 28 additions & 0 deletions .grazie.en.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# "en" in the file name specifies the natural language to be checked, so you can use other ISO codes, e.g. "ru" or "de"

# A subset of "vale" linter syntax is supported:
# "existence", "substitution", "sequence", "capitalization", "occurrence", "conditional" rule types.
# See https://docs.errata.ai/vale/styles#extension-points for more details.

extends: substitution
message: Consider using %s
level: warning
ignorecase: true
swap:
(the|this) bot: Glyph
---
extends: substitution
message: %s is captitalized at the Q and the V
level: warning
ignorecase: false
swap:
quickview: QuickView
quickviews: QuickViews
quick[ -]views: QuickViews
---
extends: substitution
message: Fur Affinity is two words
level: warning
ignorecase: true
swap:
furaffinity: Fur Affinity
12 changes: 9 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Glyph, a Discord bot that uses natural language instead of commands
* powered by DialogFlow and Kotlin
*
* Copyright (C) 2017-2021 by Ian Moore
* Copyright (C) 2017-2022 by Ian Moore
*
* This file is part of Glyph.
*
Expand Down Expand Up @@ -51,8 +51,8 @@ import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompile
internal val kotlinVersion: String by project.extra

plugins {
kotlin("jvm") version "1.5.10"
kotlin("plugin.serialization") version "1.5.10"
kotlin("jvm") version "1.6.10"
kotlin("plugin.serialization") version "1.6.10"
id("tanvd.kosogor") version "1.0.12"
}

Expand All @@ -67,10 +67,16 @@ subprojects {
apply(plugin = "kotlinx-serialization")
apply(plugin = "tanvd.kosogor")

val jdaVersion: String by project.extra
val logbackVersion: String by project.extra

repositories {
maven("https://m2.dv8tion.net/releases")
}

dependencies {
implementation(kotlin("stdlib-jdk8", kotlinVersion))
implementation("net.dv8tion:JDA:$jdaVersion")
implementation("io.lettuce:lettuce-core:6.0.0.M1")
implementation("ch.qos.logback:logback-classic:$logbackVersion")
testImplementation("org.jetbrains.kotlin:kotlin-test")
Expand Down
2 changes: 2 additions & 0 deletions docs/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM python:3
RUN pip install sphinx sphinx_rtd_theme
6 changes: 3 additions & 3 deletions docs/basics.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
The Basics
=======

How to Add Glyph
How to add Glyph
^^^^^^^^^^^^^^^^
To add Glyph to your server, use this `invite link`_.

.. _invite link: https://gl.yttr.org/invite

How to Use Glyph
How to use Glyph
^^^^^^^^^^^^^^^^
- In a server, start a message with an @mention for Glyph and then type your message.
- In a Private Message, just type your message.
Expand All @@ -16,6 +16,6 @@ See :doc:`/skills` for a complete guide on everything Glyph can do and what to s

.. _DialogFlow: https://dialogflow.com/

How to Configure Glyph
How to configure Glyph
^^^^^^^^^^^^^^^^^^^^^^
See :doc:`/configuration`.
39 changes: 31 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,30 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# conf.py
#
# Glyph, a Discord bot that uses natural language instead of commands
# powered by DialogFlow and Kotlin
#
# Copyright (C) 2017-2022 by Ian Moore
#
# This file is part of Glyph.
#
# Glyph is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

#
# glyph documentation build configuration file, created by
# Glyph documentation build configuration file, created by
# sphinx-quickstart on Mon Jun 5 16:24:08 2017.
#
# This file is execfile()d with the current directory set to its
Expand Down Expand Up @@ -48,8 +71,8 @@
master_doc = 'index'

# General information about the project.
project = 'glyph'
copyright = '2020, Ian Moore'
project = 'Glyph'
copyright = '2022, Ian Moore'
author = 'Ian Moore'

# The version info for the project you're documenting, acts as replacement for
Expand Down Expand Up @@ -102,7 +125,7 @@
# -- Options for HTMLHelp output ------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'glyphdoc'
htmlhelp_basename = 'Glyphdoc'


# -- Options for LaTeX output ---------------------------------------------
Expand All @@ -129,7 +152,7 @@
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'glyph.tex', 'glyph Documentation',
(master_doc, 'Glyph.tex', 'Glyph Documentation',
'Ian Moore', 'manual'),
]

Expand All @@ -139,7 +162,7 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'glyph', 'glyph Documentation',
(master_doc, 'Glyph', 'Glyph Documentation',
[author], 1)
]

Expand All @@ -150,8 +173,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'glyph', 'glyph Documentation',
author, 'glyph', 'One line description of project.',
(master_doc, 'Glyph', 'Glyph Documentation',
author, 'Glyph', 'One line description of project.',
'Miscellaneous'),
]

Expand Down
9 changes: 5 additions & 4 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ Glyph makes it easy to set a custom configuration on your server.

Setting a configuration
------------------------
1. Say to Glyph "edit config"
2. Open the given link
3. Edit the configuration and click Save
1. Say to Glyph "edit config" or go to `configuration editor`_ directly
2. Edit the configuration
3. Click Save

.. note::
If the configuration has an error, Glyph will fallback to using the previous error-free configuration.
Additionally, if Glyph is removed from the server, the server's configuration will be deleted from the database.

.. _configuration editor: https://gl.yttr.org/config
72 changes: 52 additions & 20 deletions docs/data.rst
Original file line number Diff line number Diff line change
@@ -1,39 +1,65 @@
Data Collection
===============
Privacy Policy
==============

We understand that when you use a bot, there's a certain level of privacy you expect.
That is why we provide this information below, to clear up any concerns.

Opt-ins and opt-outs
--------------------

Data We Collect
Within the Discord client, Glyph provides tools to manage your data usage with the :code:`/compliance` command.

In order to use the natural language processing features of Glyph, you must explicitly opt-in to allow your message
content to be sent to Dialogflow for processing. Read more below under `message contents`_.

Data we collect
---------------

session ids
^^^^^^^^^^^
:What: An MD5 hash of your user ID and the channel ID
:What: An `MD5`_ hash of your user id and the channel id
:When: Glyph is explicitly mentioned via DM or @mention
:Where: DialogFlow requests and message logs
:Why: Used with DialogFlow to ensure any follow up intents are personalized to you

messages
^^^^^^^^
:What: A copy of your message contents, your _`session ID` and what skill Glyph interpreted it to be
.. _MD5: https://en.wikipedia.org/wiki/MD5

message contents
^^^^^^^^^^^^^^^^

**Dialogflow**

:What: A copy of your message contents only
:When: Glyph is explicitly mentioned via DM or @mention, only
:Where: Temporary log on Heroku, logs generally disappear within 24 hours
:Where: Anonymously sent to Dialogflow for the sole purpose of understanding and responding to your request
:Why: To understand the intent of your message and respond

**Heroku**

:What: A copy of your message contents, your `session ids`_ (not username) and what skill Glyph interpreted it to be
:When: Glyph is explicitly mentioned via DM or @mention, only
:Where: Application logs on Heroku
:Why: To make sure Glyph is responding appropriately or see what messages caused an error

compliance
^^^^^^^^^^
:What: Your user id and opt-in/opt-out decision in a compliance category along with the time
:When: You click on "Opt in" or "Opt out"
:Where: A PostgreSQl database managed by Heroku
:Why: To respect message content data privacy decisions

configurations
^^^^^^^^^^^^^^
:What: The server ID and the configuration settings
:When: A custom configuration is set by a server admin (deleted when Glyph is removed from the server)
:What: The server id and the configuration settings
:When: A custom configuration is set by a server admin
:Where: A PostgreSQl database managed by Heroku
:Why: To access and store a server's unique configuration

server info
^^^^^^^^^^^
:What: The server name, ID, member count (humans and bots)
:What: The server name, id, member count (humans and bots)
:When: Glyph is added or removed from a server
:Where: A private Discord channel (sent via webhooks)
:Where: A private Discord channel (sent via webhooks) managed by Glyph's owner
:Why: To see what servers Glyph has been added and removed from and see which servers are considered bot farms

username history
Expand All @@ -44,14 +70,20 @@ username history
:Why: So server admins can remember who people are even if they change their name


Data We Don't Collect
Data we don't collect
---------------------

Obviously anything we don't collect is not listed above but here's a list of common things we don't collect.
Glyph intentionally does not provide options to "audit log" deleted and edited messages.

When you deleted a message, if Glyph interacted with it, we attempt to delete any responses it generated to it
and any copy that may be in a starboard if it was starboarded.

All audit log messages sent by Glyph to a server's logging channel are done via fire-and-forget webhooks.
The contents of these messages is never stored elsewhere.

Questions?
----------

If you have any questions or concerns about the usage and storage of your data please join the `official server`_.

- Deleted messages
- Message edits
- The username, ID, or discriminator of who sent feedback
- Audit logs (once they are sent, they are forgotten)
- Ban reasons
- Kick reasons
.. _official server: https://gl.yttr.org/server
7 changes: 1 addition & 6 deletions glyph-bot/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Glyph, a Discord bot that uses natural language instead of commands
* powered by DialogFlow and Kotlin
*
* Copyright (C) 2017-2021 by Ian Moore
* Copyright (C) 2017-2022 by Ian Moore
*
* This file is part of Glyph.
*
Expand Down Expand Up @@ -56,10 +56,6 @@ internal val coroutinesVersion: String by project.extra
internal val jdaVersion: String by project.extra
internal val ktorVersion: String by project.extra

repositories {
maven("https://m2.dv8tion.net/releases")
}

shadowJar {
jar {
archiveName = "glyph-bot.jar"
Expand All @@ -80,7 +76,6 @@ tasks.withType(KotlinJvmCompile::class) {
dependencies {
implementation(project(":glyph-shared"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:$coroutinesVersion")
implementation("net.dv8tion:JDA:$jdaVersion")
implementation("club.minnced:discord-webhooks:0.5.7")
implementation("com.google.cloud:google-cloud-storage:1.106.0")
implementation("com.google.cloud:google-cloud-dialogflow:1.0.0")
Expand Down
5 changes: 4 additions & 1 deletion glyph-bot/src/main/kotlin/Glyph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Glyph, a Discord bot that uses natural language instead of commands
* powered by DialogFlow and Kotlin
*
* Copyright (C) 2017-2021 by Ian Moore
* Copyright (C) 2017-2022 by Ian Moore
*
* This file is part of Glyph.
*
Expand Down Expand Up @@ -33,6 +33,7 @@ import net.dv8tion.jda.api.sharding.DefaultShardManagerBuilder
import net.dv8tion.jda.api.utils.cache.CacheFlag
import org.yttr.glyph.bot.ai.AIAgent
import org.yttr.glyph.bot.ai.dialogflow.Dialogflow
import org.yttr.glyph.bot.messaging.ComplianceListener
import org.yttr.glyph.bot.messaging.MessagingDirector
import org.yttr.glyph.bot.messaging.quickview.QuickviewDirector
import org.yttr.glyph.bot.presentation.BotList
Expand Down Expand Up @@ -162,6 +163,8 @@ object Glyph {
messagingDirector, AuditingDirector, skillDirector, configDirector,
serverDirector, QuickviewDirector(messagingDirector), StatusDirector, StarboardDirector(redis)
)

it.addEventListeners(ComplianceListener)
}

builder.build()
Expand Down

0 comments on commit 75fd2d4

Please sign in to comment.