Class: Dashboard
- Inherits:
-
Object
- Object
- Dashboard
- Defined in:
- lib/dashboard.rb
Instance Method Summary collapse
-
#initialize(dashboard_config, bot) ⇒ Dashboard
constructor
A new instance of Dashboard.
- #update ⇒ Object
Constructor Details
#initialize(dashboard_config, bot) ⇒ Dashboard
Returns a new instance of Dashboard.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/dashboard.rb', line 2 def initialize(dashboard_config, bot) @server = bot.server(dashboard_config["server_id"]) @endpoints = dashboard_config["endpoints"] @messages = {} channel_name = dashboard_config["name"] old_dashboard_channel = @server.channels.find do |chan| chan.name == channel_name end @channel = if old_dashboard_channel = JSON.parse( Discordrb::API::Channel.( "Bot #{QwtfDiscordBot.config.token}", old_dashboard_channel.id, 100 ) ) .each do || sleep 2 old_dashboard_channel.(['id']).delete end old_dashboard_channel else @server.create_channel(channel_name).tap do |channel| channel.topic = "QWTF Bot Dashboard" end end end |
Instance Method Details
#update ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/dashboard.rb', line 35 def update @endpoints.each do |endpoint| qstat_request = QstatRequest.new(endpoint) if qstat_request.is_empty? if @messages[endpoint] @messages[endpoint].delete @messages.delete(endpoint) end next end = qstat_request. @messages[endpoint] = if @messages[endpoint] @messages[endpoint].edit(nil, ) else @channel.(nil, ) end end end |