added start time feature

master
s00ner 2021-10-13 15:22:31 -04:00
parent b7cb80d3a9
commit 52bca3ee2d
1 changed files with 21 additions and 1 deletions

22
bot.rb
View File

@ -1,12 +1,32 @@
#!/bin/env ruby
require 'discordrb'
require 'rufus-scheduler'
# fetches a random quote from quotes
def random_quote(quotes)
quote = "**Quote of the Day**"
quote << "```"
quotes.sample.split("\n")[2..].each { | line | quote << line.delete("^") + "\n" }
quote << "```"
end
token = File.read("./token").strip
bot = Discordrb::Bot.new token: token
quotes = File.read("Game Files/blurbsx.txt").split("##")
quotes.delete_at(0) # Remove empty first item
scheduler = Rufus::Scheduler.new
start_time = Rufus::Scheduler.parse('08:00') # what time of day the message should send
scheduler.every '1d', first_at start_time do
bot.send_message(852541842511495210, random_quote(quotes))
end
bot.message(with_text: 'Ping!') do |event|
event.respond 'Pong!'
event.respond random_quote(quotes)
pp bot
end
bot.run