Class: DSU3::Channel

Inherits:
DObject show all
Defined in:
lib/dsu3/data/channel.rb

Overview

Channel object

Instance Attribute Summary

Attributes inherited from DObject

#id, #net

Instance Method Summary collapse

Methods inherited from DObject

#initialize

Constructor Details

This class inherits a constructor from DSU3::DObject

Instance Method Details

#message(message_id) ⇒ Object

Returns Message instance

Parameters:

  • message (String, Integer)

    Message ID



29
30
31
# File 'lib/dsu3/data/channel.rb', line 29

def message(message_id)
  DSU3::Message.new(self, message_id)
end

#send(message) ⇒ Object

Sends a message to a channel

Parameters:

  • message (String, Integer)

    Message contents



13
14
15
# File 'lib/dsu3/data/channel.rb', line 13

def send(message)
  @net.request { DSU3::API::Channel.send(_1, @id, message) }
end

#spam(message) ⇒ Object #spam(&block) ⇒ Object

Overloads:

  • #spam(message) ⇒ Object

    Spams to a channel

    Parameters:

    • message (String)

      Message contents

  • #spam(&block) ⇒ Object

    Every time the decisive moment to send a message comes up, this function calls our block and pigeonholes the value returned by it



23
24
25
# File 'lib/dsu3/data/channel.rb', line 23

def spam(message)
  @net.request(loop: true) { DSU3::API::Channel.send(_1, @id, message || yield) }
end

#typeObject

Types text into a channel



7
8
9
# File 'lib/dsu3/data/channel.rb', line 7

def type
  @net.request(loop: true, cooldown: 9) { DSU3::API::Channel.type(_1, @id) }
end