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)
-
+ (Object) from(message)
Find or create a DirectMessage.
Instance Method Summary (collapse)
-
- (Object) make_request
Finds or creates a Request sourced from this DirectMessage.
-
- (Object) text
The plain text.
-
- (Object) user
Finds or creates a KnownUser connected to this DirectMessage.
-
- (Object) username
Finds the user’s screen_name.
Class Method Details
+ (Object) from(message)
Find or create a DirectMessage.
132 133 134 135 |
# File 'lib/safubot/twitter.rb', line 132 def from() DirectMessage.where('raw.id' => ['id']||.id).first || DirectMessage.create(:raw => ['attrs']||) end |
Instance Method Details
- (Object) make_request
Finds or creates a Request sourced from this DirectMessage.
154 155 156 |
# File 'lib/safubot/twitter.rb', line 154 def make_request self.request || Request.create(:user => user, :source => self, :text => self.text) end |
- (Object) text
The plain text.
139 140 141 |
# File 'lib/safubot/twitter.rb', line 139 def text self.raw['text'] end |
- (Object) user
Finds or creates a KnownUser connected to this DirectMessage.
149 150 151 |
# File 'lib/safubot/twitter.rb', line 149 def user KnownUser.by_twitter(username) end |
- (Object) username
Finds the user’s screen_name.
144 145 146 |
# File 'lib/safubot/twitter.rb', line 144 def username self.raw['sender']['screen_name'] end |