discord-diabetes / diabot

A diabetes-oriented chatbot for Discord
https://discord.gg/diabetes
Other
19 stars 13 forks source link

Add a quote search command #193

Closed davidlenfesty closed 1 year ago

davidlenfesty commented 1 year ago

I got a little annoyed at not being able to search, so I built a search command.

Basically it takes a list of keywords, and adds those as a regex filter on the message content (roughly sanitized to escape regex control characters), and returns a list of the first 10 quotes that contain all the keywords.

Nitpicks, suggestions, and other feedback extremely welcome, this is my first time touching any Kotlin or MongoDB. Feel free to ping me on the r/diabetes server if you want an invite to my bot testing server to play around with functionality. I'll be running diabot on my server so it should be up all the time.

Work left to do:

davidlenfesty commented 1 year ago

I'm dropping the username search feature for now, I don't really want to spend the time thinking about the semantics

p5nbTgip0r commented 1 year ago

I'm dropping the username search feature for now, I don't really want to spend the time thinking about the semantics

That's fair. I think adding more arguments to this type of command would work better as a slash command anyway

cascer1 commented 1 year ago

@p5nbTgip0r could you also have a look, mostly at the database part? You're more familiar with how we interact with the database in the bot.

cascer1 commented 1 year ago

I'm dropping the username search feature for now, I don't really want to spend the time thinking about the semantics

That's fair. I think adding more arguments to this type of command would work better as a slash command anyway

I like the idea of having a slash alternative for each new command we add anyway. Can we also turn this into a slash command?

p5nbTgip0r commented 1 year ago

I like the idea of having a slash alternative for each new command we add anyway. Can we also turn this into a slash command?

I could handle this if wanted

cascer1 commented 1 year ago

I like the idea of having a slash alternative for each new command we add anyway. Can we also turn this into a slash command?

I could handle this if wanted

Sounds good. Feel free to do it in a separate PR too if you like.

davidlenfesty commented 1 year ago

Thanks for the feedback! I think basically all of the suggestions were me not knowing where to look/thinking I should even look for better solutions, my first time touching Kotlin so I was kind of fumbling around in the dark. I've kind of run out of energy for now to do anything with slash commands for now, so I'll leave it to y'all.

p5nbTgip0r commented 1 year ago

Thanks for the feedback! I think basically all of the suggestions were me not knowing where to look/thinking I should even look for better solutions, my first time touching Kotlin so I was kind of fumbling around in the dark. I've kind of run out of energy for now to do anything with slash commands for now, so I'll leave it to y'all.

No worries, you did a great job! Thank you for contributing!! ❤️

I'll let @cascer1 do one last check over the small changes I did, but otherwise LGTM to me. I'll make a slash command for it in another PR once I have a bit of spare time.