Sha256: 46a9b56d584303af4eecb8bda1870db6cc64f57638dbb8487857c002dcceea9b
Contents?: true
Size: 975 Bytes
Versions: 35
Compression:
Stored size: 975 Bytes
Contents
class QwtfDiscordBotDashboard THIRTY_SECONDS = 30 def run bot = Discordrb::Commands::CommandBot.new( token: QwtfDiscordBot.config.token, client_id: QwtfDiscordBot.config.client_id, help_command: false, prefix: proc do |message| match = /^\!(\w+)(.*)/.match(message.content) if match first = match[1] rest = match[2] # Return the modified string with the first word lowercase: "#{first.downcase}#{rest}" end end ) bot.run(true) @dashboards ||= QwtfDiscordBot.config.dashboards.map do |dashboard_config| Dashboard.new(dashboard_config, bot) end every(THIRTY_SECONDS) do @dashboards.each do |dashboard| dashboard.update end end end private def every(n_seconds) loop do before = Time.now yield interval = n_seconds - (Time.now - before) sleep(interval) if interval > 0 end end end
Version data entries
35 entries across 35 versions & 1 rubygems