Class: Xasin::Telegram::OnMessage

Inherits:
OnTelegramEvent show all
Defined in:
lib/xasin/telegram/OnMessage.rb

Instance Attribute Summary

Attributes inherited from OnTelegramEvent

#priority

Instance Method Summary collapse

Methods inherited from OnTelegramEvent

#<=>

Constructor Details

#initialize(options) ⇒ OnMessage

Returns a new instance of OnMessage.



6
7
8
9
10
11
12
13
# File 'lib/xasin/telegram/OnMessage.rb', line 6

def initialize(options)
	super()

	@block = options[:block]
	@regexp = options[:regexp]

	@priority += 1 if @regexp
end

Instance Method Details

#nomp_message(message) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/xasin/telegram/OnMessage.rb', line 15

def nomp_message(message)
	if @regexp
		match = @regexp.match message.to_s

		if match
			@block.call message, match
			message.handled = true
		end
	else
		@block.call message
	end
end