mirror of
https://github.com/thewesker/twitter_ebooks.git
synced 2025-12-20 12:21:11 -05:00
Merge pull request #1 from michenriksen/master
Make event handlers optional to define
This commit is contained in:
@@ -70,13 +70,13 @@ module Ebooks
|
|||||||
@stream.on_event(:follow) do |event|
|
@stream.on_event(:follow) do |event|
|
||||||
next if event[:source][:screen_name] == @username
|
next if event[:source][:screen_name] == @username
|
||||||
log "Followed by #{event[:source][:screen_name]}"
|
log "Followed by #{event[:source][:screen_name]}"
|
||||||
@on_follow.call(event[:source])
|
@on_follow.call(event[:source]) if @on_follow
|
||||||
end
|
end
|
||||||
|
|
||||||
@stream.on_direct_message do |dm|
|
@stream.on_direct_message do |dm|
|
||||||
next if dm[:sender][:screen_name] == @username # Don't reply to self
|
next if dm[:sender][:screen_name] == @username # Don't reply to self
|
||||||
log "DM from @#{dm[:sender][:screen_name]}: #{dm[:text]}"
|
log "DM from @#{dm[:sender][:screen_name]}: #{dm[:text]}"
|
||||||
@on_message.call(dm)
|
@on_message.call(dm) if @on_message
|
||||||
end
|
end
|
||||||
|
|
||||||
@stream.userstream do |ev|
|
@stream.userstream do |ev|
|
||||||
@@ -110,9 +110,9 @@ module Ebooks
|
|||||||
# - Or soft-retweeted by somebody else
|
# - Or soft-retweeted by somebody else
|
||||||
if mentions.map(&:downcase).include?(@username.downcase) && !ev[:retweeted_status] && !ev[:text].start_with?('RT ')
|
if mentions.map(&:downcase).include?(@username.downcase) && !ev[:retweeted_status] && !ev[:text].start_with?('RT ')
|
||||||
log "Mention from @#{ev[:user][:screen_name]}: #{ev[:text]}"
|
log "Mention from @#{ev[:user][:screen_name]}: #{ev[:text]}"
|
||||||
@on_mention.call(ev, meta)
|
@on_mention.call(ev, meta) if @on_mention
|
||||||
else
|
else
|
||||||
@on_timeline.call(ev, meta)
|
@on_timeline.call(ev, meta) if @on_timeline
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user