forked from yagich/potomark-bot-rb
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
6a02eeb05f | |||
61e8ff8b34 | |||
1d65101e33 | |||
133806aaa4 | |||
679603e0a9 | |||
f4522bddce | |||
e2240a75f1 | |||
ad9b7de2fc | |||
4bfe4ef9d6 | |||
e5d0af7431 | |||
e56aac740b | |||
738c4efa3b | |||
e26d385aed | |||
5af24f2f02 | |||
83f6a5db1a | |||
ce02f1aeb5 | |||
122447095b | |||
0529dbac85 |
15
README.md
15
README.md
@ -1,16 +1,25 @@
|
|||||||
# potomark is a simple bookmarking discord bot.
|
# potomark is a simple bookmarking and pinning discord bot.
|
||||||
there's no configuration besides a `.env` file that stores the bot's token.
|
there's no configuration besides a `.env` file with two keys:
|
||||||
|
|
||||||
|
- the bot's token `DISCORD_TOKEN`,
|
||||||
|
- channel id for a sentence game `SENTENCE_CHANNEL`. if you don't want to enable the sentence game, set the key to `-1`.
|
||||||
|
|
||||||
## why?
|
## why?
|
||||||
because we needed a tiny, self hostable bot to remember things of importance for our equally tiny discord server.
|
because we needed a tiny, self hostable bot to remember things of importance for our equally tiny discord server.
|
||||||
|
|
||||||
## what it do?
|
## what it do?
|
||||||
DMs a user a link to any message they reacte with 🔖 to (tip: you can change the `EMOJI` constant in `bot.rb` to any built-in emoji). also sends part of the message for quick access. that's it.
|
- DMs a user a link to any message they react with 🔖 to (tip: you can change the `BOOKMARK_EMOJI` constant in `bot.rb` to any built-in emoji). this also sends part of the message for quick access,
|
||||||
|
- lets users pin messages to the channel by reacting with 📌 on that message (change `PIN_EMOJI` to change the emoji). if there are no more of that emoji reactions on the message, it gets unpinned.
|
||||||
|
- lets users make sentences one word (or more) at a time in `SENTENCE_CHANNEL`. to finish a sentence, send either of these as a message: `?`, `!`, `.`, `...`, `?!`
|
||||||
|
|
||||||
## how?
|
## how?
|
||||||
requires [ruby](https://www.ruby-lang.org/) >= 3.0 and [bundler](https://bundler.io) >= 2.3.19. the only two dependencies are `dotenv` and `discordrb`, as specified in the `Gemfile`.
|
requires [ruby](https://www.ruby-lang.org/) >= 3.0 and [bundler](https://bundler.io) >= 2.3.19. the only two dependencies are `dotenv` and `discordrb`, as specified in the `Gemfile`.
|
||||||
|
|
||||||
|
quick setup:
|
||||||
```bash
|
```bash
|
||||||
|
$ git clone https://git.poto.cafe/yagich/potomark-bot-rb.git && cd potomark-bot-rb
|
||||||
$ echo 'DISCORD_TOKEN=YOUR.DISCORD.TOKEN.HERE' > .env
|
$ echo 'DISCORD_TOKEN=YOUR.DISCORD.TOKEN.HERE' > .env
|
||||||
|
$ echo 'SENTENCE_CHANNEL=SENTENCE_GAME_CHANNEL_ID' >> .env
|
||||||
$ bundle install
|
$ bundle install
|
||||||
$ ruby bot.rb
|
$ ruby bot.rb
|
||||||
```
|
```
|
||||||
|
25
bot.rb
25
bot.rb
@ -6,6 +6,11 @@ bot = Discordrb::Bot.new token: ENV['DISCORD_TOKEN']
|
|||||||
BOOKMARK_EMOJI = '🔖'
|
BOOKMARK_EMOJI = '🔖'
|
||||||
PIN_EMOJI = '📌'
|
PIN_EMOJI = '📌'
|
||||||
|
|
||||||
|
ADMIN_PASTA = 'Thats not how it works, thats an abuse of power and if you keep doing that you will quickly find yourself no longer a moderator at some point.'
|
||||||
|
ADMIN_PASTER = 'tahts not how itwh orksm, thas and buse fo bpower and ify oyu keep y doing that oyu woubll qucikyl find you slefo no l ogner a nmoderarort at so meo poitn.'
|
||||||
|
YUM = 'completely consequences'
|
||||||
|
AULT = '# IN VR'
|
||||||
|
|
||||||
TRIM_MESSAGE_LENGTH = 500
|
TRIM_MESSAGE_LENGTH = 500
|
||||||
|
|
||||||
$sentence = {}
|
$sentence = {}
|
||||||
@ -60,11 +65,11 @@ bot.reaction_remove do |event|
|
|||||||
end
|
end
|
||||||
|
|
||||||
bot.message(in: Integer(ENV['SENTENCE_CHANNEL'])) do |event|
|
bot.message(in: Integer(ENV['SENTENCE_CHANNEL'])) do |event|
|
||||||
if event.message.content == "."
|
if ['?', '!', '.', '...', '?!'].include? event.message.content
|
||||||
if $sentence.empty?
|
if $sentence.empty?
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
event << "Congratulations, your sentence is: #{$sentence.values.join(" ")}."
|
event << "Congratulations, your sentence is: #{$sentence.values.join(" ").gsub(/\s([^\w\s])/, '\1')}#{event.message.content}"
|
||||||
$sentence.clear
|
$sentence.clear
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
@ -80,4 +85,20 @@ bot.message_edit(in: Integer(ENV['SENTENCE_CHANNEL'])) do |event|
|
|||||||
$sentence[event.message.id] = event.message.content
|
$sentence[event.message.id] = event.message.content
|
||||||
end
|
end
|
||||||
|
|
||||||
|
bot.message(with_text: '!abuse') do |event|
|
||||||
|
event << ADMIN_PASTA
|
||||||
|
end
|
||||||
|
|
||||||
|
bot.message(with_text: '!abue') do |event|
|
||||||
|
event << ADMIN_PASTER
|
||||||
|
end
|
||||||
|
|
||||||
|
bot.message(with_text: '!yum') do |event|
|
||||||
|
event << YUM
|
||||||
|
end
|
||||||
|
|
||||||
|
bot.message(with_text: '!ault') do |event|
|
||||||
|
event << AULT
|
||||||
|
end
|
||||||
|
|
||||||
bot.run
|
bot.run
|
||||||
|
Loading…
Reference in New Issue
Block a user