GithubHelp home page GithubHelp logo

itshobbes / mimic Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 387 KB

Mimic is a discord bot built originally for The Programmer's Hangout that creates sentences based on its users.

License: MIT License

Java 99.97% Dockerfile 0.03%
discord disparse java jda jooq the-programmers-hangout tph

mimic's Introduction

Hi there 👋

What's the hardest part about making skimmed milk? Throwing the cows across the lake.

Discord: @itshobbes (formerly itsHobbes#1985)

mimic's People

Contributors

boscojared avatar dependabot[bot] avatar itshobbes avatar kokoden avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

kokoden immjs

mimic's Issues

Improving markov quality

Is your feature request related to a problem? Please describe.
Currently markov chains are created by pairing a word and a follow word. Only two words are considered at a time as a Bigram.

Describe the solution you'd like
Quality of generated sentences may be improved by using a tri-gram (or n-gram higher) method instead.
• Create a markov interface
• Allow multiple implementations of markov chains to be used.

Add analytics command

Is your feature request related to a problem? Please describe.
Basic analytics were added for logging command usage of mimic!self, mimic!rand, and mimic!all. But there is currently no command to view these analytics.

Describe the solution you'd like
• Add a mimic!analytics command to view the analytics for the server the command is invoked in.
• The command should display the usage for each of the mimic commands over time.
• The command should accept a number of days argument. (min: 7, default: 30, max: 90)
• The command should respond with an image graph of usage for each command (The XChart library looks like a good option)
• The command should have a cooldown of 30 seconds, scoped to the channel.

Add global opt-out

Is your feature request related to a problem? Please describe.
Current functionality means a user that has opted-in on multiple servers would have to opt out of each server individually.

Describe the solution you'd like
This FR proposes an optional --global argument to the opt-out command allowing the user to opt-out of all servers they have joined.

  1. The bot should respond with a success response informing the user they will be opted out and they will receive a DM from the bot with the list of servers (if DMs are open)
  2. The bot should send a DM to the user with a list of all servers they have been opted out from.

Markov Chains for language snippets

Is your feature request related to a problem? Please describe.
Code snippets are a big part of helping out users that are learning to code. There is room for this bot to read and parse specific language code snippets from discord.

Describe the solution you'd like

  • Standard message reading should probably filter out code snippets, or pass them into the code snippet parser. The existing DB should also be cleaned of such messages. (They can be moved into a separate table for language snippets)
  • Code snippet reading should parse the language from the snippet. Initial step can be to read the language from the code block header, eg. ```js
  • Message validation will probably need altering from standard message parsing.
  • Markov generation may need tweaking.
  • Proposed usage examples mimic!js, mimic!java

Describe alternatives you've considered

  • Sources other than discord could be considered. GitHub being one of them.

For now this implementation is open for discussion. Additional details, changes, and suggestions are welcome.

Edit Message listener ignores message length

Currently the edit message listener ignores the message length required by the Markov chain.

Steps to reproduce:

  1. Send a valid message
  2. Edit the message to a token length < 3
  3. Generate a markov chain for the user

Expected Result
Short message edits are ignored. Markov chains can be built without issue

Actual result
Short message edits are not ignored. Causing Markov chains to fail

Additional Info

Caused by: java.lang.IllegalArgumentException: Input '<:pleb_this:582076395119706113>'is too short. Must be greater than 3 tokens.
	at uk.co.markg.bertrand.markov.Markov.parseInput(Markov.java:110) ~[bertrand-1.0.jar:?]
	at uk.co.markg.bertrand.markov.Markov.parseInput(Markov.java:98) ~[bertrand-1.0.jar:?]
	at uk.co.markg.bertrand.markov.Markov.<init>(Markov.java:26) ~[bertrand-1.0.jar:?]
	at uk.co.markg.bertrand.markov.Markov.load(Markov.java:37) ~[bertrand-1.0.jar:?]
	at uk.co.markg.bertrand.markov.Markov.load(Markov.java:31) ~[bertrand-1.0.jar:?]
	at uk.co.markg.bertrand.command.markov.MarkovSelf.execute(MarkovSelf.java:27) ~[bertrand-1.0.jar:?]

Improve server-wide chain caching

Is your feature request related to a problem? Please describe.
Server-wide chain caching is currently done by serialising the markov class into a file and reading the file. The cache expires after 2 hours. This can be improved

Describe the solution you'd like
Cache timings should scale in line with the number of messages saved per server. If a server is low on total messages read, mimic!all will perform poorly if it must wait 2 hours to utilise any new messages.
Example functionality:
• servers with x < 10_000 messages stored should not be cached
• servers with 10_000 > x < 100_000 messages stored should be cached for 1 hours
• servers with 100_000 < x messages stored should be cached for 6 hours

Cache timing and message limits can be subject to change.

It would be worth experimenting between the memory usage of caching the chain in a byte array vs reading the serialised from a file.

Support multi-guild operation

Is your feature request related to a problem? Please describe.
Current the bot does not support multi-guild operations.

Describe the solution you'd like

  • Channel permissions should be saved on a per guild basis.
  • Channel permissions should be viewed on a per guild basis.
  • Messages should be saved on a per guild basis.
  • Users should be able to opt-in and opt-out on a per guild basis.
  • Statistics should be calculated and displayed on a per guild basis.
  • Generally, it should not be possible for data cross contamination between guilds.

Additional context
Commits can be prefixed with [db] for database related commits (updating schema, updating JOOQ files, updating repository classes) and [command] for command based commits.

Prevent discord command injection through mimic!start

Is your feature request related to a problem? Please describe.
Mimic seems to be able to run commands through mimic!start E.G. mimic!start tph!selfmute

Describe the solution you'd like
mimic!start could use a Zero Width Space in front of the result

Describe alternatives you've considered

  • Filtering certain prefixes (but that could be hard-coding)

Additional context
Tried in TPH (I got told) and I think an attacker could be able to run things from mimic, even though I failed

Add cooldowns to channel commands

Is your feature request related to a problem? Please describe.
There is currently no cooldown on channel commands.

Describe the solution you'd like
Cool downs should be added to channels.edit, channels.add, and channels.remove.
Cool down should be 5 seconds and scoped to the user.
Cooldowns should not send the cooldown message. If disparse has been updated (BoscoJared/disparse#26), then the cooldown reaction should be sent.

Add Mimic Start command

Describe the solution you'd like
The command should allow the user to start a sentence so that mimic can finish it.
Example usage:
mimic!start I like -> mimic's response: I like ....

This should use the global server chain.

Add "read" command to list readable channels for normal users

Is your feature request related to a problem? Please describe.
Users are currently unable to view the list of channels that the bot can is configured to read messages from.

Describe the solution you'd like

  • A new command "read" that lists all channels that the bot is capable of reading from. (usage: mimic!read)
  • The command should be accessible for all users.
  • The command should show the channels as a clickable link (channel mention) in a MessageEmbed

Additional context
Commit name should be prefixed with [command] for command related changes or [db] for database related changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.