added start time feature
parent
b7cb80d3a9
commit
52bca3ee2d
22
bot.rb
22
bot.rb
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue