From ba2f91d6202a141221d440b29b2133776e2f9936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lera=20Elvo=C3=A9?= Date: Sat, 11 Feb 2023 18:28:31 +0300 Subject: [PATCH] add sentence game --- bot.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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