Module: IIRC::IRCv3::LabeledRequests
- Included in:
- IIRC::IRCv3Bot
- Defined in:
- lib/iirc/modules/ircv3/labeled_requests.rb
Instance Method Summary collapse
- #configure_labeled_requests ⇒ Object private
- #dispatch_replies(evt) ⇒ Object private
- #labeled_request(line) ⇒ Object
- #labeled_requests ⇒ Object
Instance Method Details
#configure_labeled_requests ⇒ Object (private)
16 17 18 |
# File 'lib/iirc/modules/ircv3/labeled_requests.rb', line 16 def configure_labeled_requests hook :dispatch_replies end |
#dispatch_replies(evt) ⇒ Object (private)
20 21 22 23 24 |
# File 'lib/iirc/modules/ircv3/labeled_requests.rb', line 20 def dispatch_replies(evt) if evt.['label'] labeled_requests.delete(evt.['label'])&.call(evt) end end |
#labeled_request(line) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/iirc/modules/ircv3/labeled_requests.rb', line 4 def labeled_request(line) SecureRandom.alphanumeric(8).tap { |id| labeled_requests[id] = -> evt { yield evt } self << "@label=#{id} #{line}" } end |
#labeled_requests ⇒ Object
11 12 13 |
# File 'lib/iirc/modules/ircv3/labeled_requests.rb', line 11 def labeled_requests @requests ||= {} end |