Giter Site home page Giter Site logo

k9's Introduction

K9 Build Status

A Discord bot with some useful commands.

It uses Discord4J, an awesome Java library for the Discord API.

About

K9 was originally created for a server about Minecraft modding, and its first command was to look up MCP mappings. It still has this feature, but there is now much more!

  • Custom pings for arbitrary regex (!ping)
    • Ever wanted to be pinged for something other than your username? Want to make sure to catch every time someone says your name, because you're a creepy bastard with nothing better to do? Then this is the command for you!
  • A command to manage "information" channels
    • Allows any administrator to update the content of an information channel from an outside source.
  • A Clojure REPL emulator (!clj)
    • If you know what this means, then you're probably a nerd.
  • The ability to create custom commands (called "tricks") which can process user input and execute code (!trick)
    • I don't have a funny quip for this one, but trust me, it's neat!
  • Look up CurseForge projects and download counts for any username (!cf)
    • You're so vain, I bet you'll run this command on yourself.
  • Lets you keep track of the best quotes from your server, and even battle them together head-to-head! (!quote)
    • Because everything is funnier out of context.
  • The ability to change the command prefix
    • What do you mean other bots already use an exclamation mark?
  • Create drama (!drama)
  • Slap people (!slap)
  • More to come!

It also features a complete help system, so figuring out how to use a command is as simple as !help [command].

How do I get K9 in my server already?

Well, if you're lucky enough to know me, just ask. Currently the instance of K9 I run is private, so only I can invite it to servers I personally know the owners of. However, K9 is open source and the build server I use is public, so it's easy to set up your own instance! See the next section for a how-to.

So you want to run your own K9

Great! Before doing anything, make sure you have the latest version of Java 8 installed on the machine that will be running the bot.

  1. Download the bot from Jenkins. Make sure to grab the -all jar, it includes all the libraries needed to run K9 inside it.
  2. Create a Discord App. Give it an appropriate name, and make sure to click the "Create a Bot User" button. After that, make sure to copy the bot token, you'll need it for the next step!
  3. That's all the setup! Make sure the bot jar is inside a clean directory (it will create some folders for storing data), and then you can run it with the syntax: java -jar [jar name] -a [bot token]. You might want to do this inside a screen or similar.

And that's all! You should see a lot of console output, and then the bot will be running! To invite it to a server, use the "Generate OAuth2 URL" button on the app page. What permissions you give the bot is up to you, but it does not (currently) need any more than these:

I know this sounds impossible, but I think K9 can be better. How can I help?

See the CONTRIBUTING.md file.

k9's People

Contributors

coehlrich avatar eutro avatar jaredlll08 avatar jayjay1989 avatar phit avatar pie-flavor avatar prospector avatar sizableshrimp avatar thiakil avatar tterrag1098 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

k9's Issues

tricks not showing thrown exceptions

creating a trick like:
!trick -at clj trickname (throw (Exception. "Hi"))
will output:
Error evaluating trick: null
whereas
!clj (throw (Exception. "Hi"))
will output the expected
Could not process command: java.security.PrivilegedActionException: java.lang.Exception: Hi

Add high five feature from the Chisel IMC server

I miss the old feature from the chisel IMC where if two people typed o/ or \o in a row, the bot would mention the high five and increment their counter. Would be a nice feature to include in K9

Prevent info channel command from pinging users/roles

Currently, from my reading of the code and anecdotal evidence from cpw's last updating of the #rules channel on Forgecord, whenever a channel is updated using K9's info command, it pings any users or roles within the message text (excluding embeds, because pings do not work in embeds).

This presents a difficulty whenever a server owner or administrator is updating such channels using the info command and the text contains mentions of roles or users (such as listing the staff roles of the server), because any update will cause a ping to be sent to all users, which means that server owners/administrators have to coordinate with these pinged users to make sure they know that this ping is due to an update of the rules channel (to avoid inciting irritation or anger from those users who hate pings with a passion unrivaled).

However, I have found a solution residing in the Discord Developer documentation for Channels, for the Allowed Mentions Object.
The Allowed Mentions object in messages allows granular control whether what mentions in a message will actually cause a ping to be sent to users. It allows controlling mentions for: roles, users, @everyone/@here, specific roles, and specific users.
As a side effect, it also disables the yellow background in messages with pings.

Image of my bot using the Allowed Mentions feature to prevent a ping to myself
Image of my bot using the Allowed Mentions feature to prevent a ping to another user, with their confirmation The yellow background of the bot's message is due to it being a reply message (with mention) to my own command.

Discord4J implements this through MessageCreateSpec#setAllowedMentions(AllowedMentions), taking in an AllowedMentions object, built using its own Builder class which defaults to (to my understanding) an empty AllowedMentions object which prevents all mentions from becoming pings.
As a reference, JDA implements this feature through MessageAction#allowedMentions(Collection<Message.MentionType>) and other related methods when sending messages. To implement this in my bot, I have passed in an empty collection, and the results of that are shown above.

This feature will be very useful to servers that use K9's info command to manage rules channels, so their owners/administrators can update the rules for e.g. spelling mistakes or minor clarifications, without having to ping and disturbed those mentioned users/roles. (cough Forgecord cough)

Easy quoting

Feature request: automatically quote anything reacted to with ๐Ÿ’พ (or a custom "quote" emoji if you want to get fancy).

Spigot mapping support

Would it be possible to add support for spigot's mappings as well? This discord bot seems very useful, but the thing is I would need to be able to use spigot's mappings as well. Is this something that could possibly be added?

No natives in -all package from jenkins

I got this error:

14:21:02 [elastic-2] i.n.u.i.NativeLibraryLoader Unable to load the library 'netty_transport_native_epoll_x86_64', trying other loading mechanism.
java.lang.UnsatisfiedLinkError: no netty_transport_native_epoll_x86_64 in java.library.path

All threads deadlocked immediately after starting

Another reminder to myself to look into this.
I booted it up like normal, but after listing the servers it's in..

16:01:47 [boundedElastic-6] com.tterrag.k9.K9   Guinevere Central  
16:01:47 [boundedElastic-6] com.tterrag.k9.K9   yeetum-bots  
16:01:47 [boundedElastic-6] com.tterrag.k9.K9   The Dugre project  
16:01:47 [boundedElastic-6] com.tterrag.k9.K9   Bolb Quarantine  
16:01:47 [boundedElastic-6] com.tterrag.k9.K9   Gemwire Randomness  
16:01:47 [boundedElastic-6] com.tterrag.k9.K9   Curle Army   
16:02:17 [parallel-5] c.t.k.c.a.CommandRegistrar Saving all command data.  
16:07:17 [parallel-5] c.t.k.c.a.CommandRegistrar Saving all command data.

It dropped off the user list and doesn't respond to commands.
Thread dump says that all threads are deadlocked, waiting for each other.
https://paste.gemwire.uk/view/raw/504a12ca

[Suggestion] xkcd linking

(Idea from BobbyTablesBot on Reddit.)

Suggestion: If a user ran !xkcd 303, K9 would post the link to xkcd 303 in the chat (keeping the embed). Same if they ran !xkcd Compiling or !xkcd compiling.
No idea how hard this would be to implement, but it'd be really neat ๐Ÿ˜„

Bot admin

Currently bot has hardcoded admin id, can this be changed?

Trick prefixes mild UX annoyance

The trick prefix is mildly irritating when you forget if it's ?! or !?

Can we instead change it to a double prefix? e.g. if your commands are configured to use ! the trick shortcut is !! ?

Otherwise just being able to configure prefixes for tricks would be cool.

[Enhancement] Tricks Info Channel

Just a quick feature idea i had today, this could be implemented in multiple ways, here's a couple:

  1. Allow the creation of a channel (similar to the !info command) that contains a current list of Tricks registered with the bot and their output, have this list update whenever a trick is updated

  2. Add a flag to the trick execution command to allow it to remain "updated", so whenever the command is updated the output is also updated.

  3. Similar to 1, but allow for only select tricks in the channel (to avoid "prank" tricks/etc in the channel)

Bot does not work

I'm self hosting this bot. Today it broke, so i restarted it, but it didn't help.
I updated it to 0.6.0-367, but it still doesn't work.
I guess it's related to mappings website shutdown, right?
How can i fix this issue?

!mcp func_151000_E
BOT K9: Unexpected error processing command: No such srg version: Unknown

Slap

Tagging @k9 in !slap does not slap the user

Question: Mojang proguard obfuscation map

Since 19w36a, Mojang has released proguard obfuscation map. The map allows for "private use" and disallows any distribution.

So two questions:

  1. Is it legal for K9 to add a mojang mapping lookup feature?
  2. If it is legal, will K9 have such a feature?

[Enhancement] Trick Aliases

Pretty simple, allow for tricks to have aliases. One thing that commonly tricks me up is a trick name being plural or not. Having aliases would be useful to solve this

Preserve removed and modified messages

Listen channels for message modification and save differences in dedicated channel.

  1. If someone removes message, repost it in special channel
  2. If someone modifies message, send diff in special channel

Field types

Show field type in mcpf command output.
May be useful

Suggestion: add a !react command

Add a !react command that takes a message link and emoji name as a parameter, and adds the reaction to the message, then removes it after 30 seconds. During this time, the person who used the command can click the reaction and add theirs, allowing non-nitro users to react with any emoji from a server K9 is on.

Bot stopped form working

I'm running 0.6.0-358

User: !mcpm getAliases 1.12.2
K9: Unexpected error processing command: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $

Old style embeds

After bot update, i noticed that mappings response is plain text.
Is it possible to switch to embeds as it was in older versions?

Command names are ambiguous and confusing

  1. None of their names actually describe what they do. The bot just assumes everyone will immediately know that !yc means !lookup_class
  2. Some of them have multiple meanings (i.e. mcage can be m_cage or mc_age)
  3. Running !help command doesn't do what help commands normally do (That's put under !commands for some reason, which does what !list would normally do)
  4. Relating to 1: running !commands does not provide any description of what any of the commands actually do.

Suggested changes:
!commands -> help (and add descriptions as per !help [command]

(keep originals as aliases)
!yc -> !class
!ym -> !method
!yf -> !field
!yp -> !param
!clj -> !eval
!mcage -> !mc_age
!yv -> !yarn_version
!lmgtfy (imgur?) -> !google

!cf is broked

Curse redesign thingie seems to have broken the cf command
image

K9 0.5.0.260 (on the moddedmc server)

[Quote Battle] Keep the winning quote in chat while voting for death or save

As the title says, it would be great if we could see the winning quote in chat and the amount of votes for/against while the voting for death or spare is still active.

quote battle

Perhaps where the arrow is it could say something like ... "against Quote # by x votes`. It would be nice to be able to see the quote which was deemed better than the one that lost and by how much.

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.