Class: Safubot::Twitter::DirectMessage
- Inherits:
-
Object
- Object
- Safubot::Twitter::DirectMessage
- Includes:
- MongoMapper::Document
- Defined in:
- lib/safubot/twitter.rb
Overview
DirectMessage is a Request source. All DirectMessages are made into Requests as they are received.
Class Method Summary collapse
-
.from(message) ⇒ Object
Find or create a DirectMessage.
Instance Method Summary collapse
-
#make_request ⇒ Object
Finds or creates a Request sourced from this DirectMessage.
-
#text ⇒ Object
The plain text.
-
#user ⇒ Object
Finds or creates a KnownUser connected to this DirectMessage.
-
#username ⇒ Object
Finds the user’s screen_name.
Class Method Details
.from(message) ⇒ Object
Find or create a DirectMessage.
133 134 135 136 |
# File 'lib/safubot/twitter.rb', line 133 def from() DirectMessage.where('raw.id' => ['id']||.id).first || DirectMessage.create(:raw => ['attrs']||) end |
Instance Method Details
#make_request ⇒ Object
Finds or creates a Request sourced from this DirectMessage.
155 156 157 |
# File 'lib/safubot/twitter.rb', line 155 def make_request self.request || self.request = Request.create(:user => user, :source => self, :text => self.text) end |
#text ⇒ Object
The plain text.
140 141 142 |
# File 'lib/safubot/twitter.rb', line 140 def text self.raw['text'] end |
#user ⇒ Object
Finds or creates a KnownUser connected to this DirectMessage.
150 151 152 |
# File 'lib/safubot/twitter.rb', line 150 def user KnownUser.by_twitter(username) end |
#username ⇒ Object
Finds the user’s screen_name.
145 146 147 |
# File 'lib/safubot/twitter.rb', line 145 def username self.raw['sender']['screen_name'] end |