diff --git a/bot.rb b/bot.rb index 7489637..5f69fb0 100644 --- a/bot.rb +++ b/bot.rb @@ -8,6 +8,8 @@ PIN_EMOJI = '📌' TRIM_MESSAGE_LENGTH = 500 +$sentence = {} + bot.reaction_add do |event| next unless [BOOKMARK_EMOJI, PIN_EMOJI].include? event.emoji.name @@ -57,4 +59,25 @@ bot.reaction_remove do |event| nil end +bot.message(in: Integer(ENV['SENTENCE_CHANNEL'])) do |event| + if event.message.content == "." + if $sentence.empty? + next + end + event << "Congratulations, your sentence is: #{$sentence.values.join(" ").}" + $sentence.clear + next + end + + $sentence[event.message.id] = event.message.content +end + +bot.message_delete(in: Integer(ENV['SENTENCE_CHANNEL'])) do |event| + $sentence.delete(event.id) +end + +bot.message_edit(in: Integer(ENV['SENTENCE_CHANNEL'])) do |event| + $sentence[event.message.id] = event.message.content +end + bot.run