A SMAC/X datalinks bot for Discord.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
913 B

#!/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 << "```"
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('12:30') # what time of day the message should send
# start tomorrow if start_time has passed
start_time += Rufus::Scheduler.parse('1d') if start_time < Time.now
scheduler.every '1d', first_at: start_time do
bot.send_message(852541842511495210, random_quote(quotes))
bot.message(with_text: 'Ping!') do |event|
event.respond random_quote(quotes)
pp bot