add sentence game

This commit is contained in:
Lera Elvoé 2023-02-11 18:28:31 +03:00
parent 8829c57dd7
commit ba2f91d620
Signed by: yagich
SSH Key Fingerprint: SHA256:6xjGb6uA7lAVcULa7byPEN//rQ0wPoG+UzYVMfZnbvc

23
bot.rb
View File

@ -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