fbwish 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +48 -2
- data/lib/fbwish/version.rb +1 -1
- data/lib/fbwish.rb +10 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmRhNzNhMmZhOGU2MWFhZjM2YjliNDI5N2NkMmMxY2MxNTE3NTNlOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTI2Y2UzYmRiNjE3NmZiMjg2ODljZGJmZjE0OTNhZTZlMzBjYzE4ZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDI3MTlhNzI2MzNjYjQ0OTgxNDNlNTMwMjJmMzVjZjM2MDUwNjJmOTIzNDE1
|
10
|
+
MTdmZmQ2Y2M1OWNlZDcyYmYwOTlkMThmYTI2ZTEwMThlZmNmODEyMjM0ZmNj
|
11
|
+
MWFjYTFiYTg4NzVmZjQ5ODAxZmU2ZWExYjBlYzQ2MzIxOGNmYjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTYwOWEyZDljNmY3YTA4MWMzNjk4ZDUzNDMyYmQ4OGIwOTBhZmY5ZjZjMzQ5
|
14
|
+
YjA1OWE2Y2ZkZDYyMmFkNGZjOWVlZDU2ZmNkZmVlMGE3YTcwODE2MWU1OTQ0
|
15
|
+
NzY2ZjYyNTVlOTJhMjU1NTZlOTI2YjcwM2ExOWNkNzcyOWRlMzY=
|
data/README.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
Ruby Gem to automate facebook like & comment on the birthday wishes using Graph API.
|
4
4
|
|
5
|
+
If you have alot of friends in your facebook network & when they wish you on your birthday, it's pretty cumbersome to reply to each one of them. This gem helps you in automating your replies by liking & commenting on those wishes using facebook's graph API (powered by ruby gem [koala](https://github.com/arsduo/koala)).
|
6
|
+
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
@@ -18,11 +20,55 @@ Or install it yourself as:
|
|
18
20
|
|
19
21
|
## Usage
|
20
22
|
|
21
|
-
|
23
|
+
Getting your facebook access token
|
24
|
+
|
25
|
+
1. Goto [Graph API Explorer](https://developers.facebook.com/tools/explorer)
|
26
|
+
2. Click `Get Access Token`
|
27
|
+
3. Make sure only `publish_actions` & `read_stream` is checked under **Extended Permissions** tab. Also nothing should be checked under **User Data Permissions** tab.
|
28
|
+
4. Click `Get Access Token` button.
|
29
|
+
5. Allow access when a popup is displayed.
|
30
|
+
6. Copy the generated access token.
|
31
|
+
|
32
|
+
#### Final step
|
33
|
+
```ruby
|
34
|
+
require('fbwish')
|
35
|
+
wisher = Fbwish::Wisher.new({
|
36
|
+
# A valid ruby regular expression based on the wishes you've received.
|
37
|
+
matcher: /(happy)|(birthday)|(b[\']?day)|(B[\']?DAY)|(hbd)/i,
|
38
|
+
# Set of replies that you'd like to wish
|
39
|
+
replies: ["Thank you :D", "Thanks :D", "Thx a lot :-)", "Hey, thx !!! :-)","Thnk U !!!", "Hey Thanks ! :D "],
|
40
|
+
access_token: "PASTE YOUR ACCESS TOKEN HERE",
|
41
|
+
# Number of people who wished you on your birthday, you'll know this
|
42
|
+
# on your timeline when facebook says "foo, bar & 254 others wished you"
|
43
|
+
wish_count: 256
|
44
|
+
})
|
45
|
+
wisher.wish_em_all! # Sit back & relax ;-)
|
46
|
+
```
|
47
|
+
|
48
|
+
### Advanced stuff
|
49
|
+
Sometimes people wish you in multiple languages & you might want to reply back in the same language. In that case you might want to namespace corresponding `matcher` & `replies` as follows:
|
50
|
+
```ruby
|
51
|
+
require('fbwish')
|
52
|
+
wisher = Fbwish::Wisher.new({
|
53
|
+
matcher: {
|
54
|
+
# regex to match english wishes
|
55
|
+
en: /(happy)|(birthday)|(b[\']?day)|(B[\']?DAY)|(hbd)/i,
|
56
|
+
# regex to match tamil wishes (or your own language )
|
57
|
+
tam: /(iniya)|(inya)|(இனிய)|(பிறந்தநாள்)|(வாழ்த்துக்கள்)/i
|
58
|
+
},
|
59
|
+
replies: {
|
60
|
+
# namespace with the same key i.e. "en"
|
61
|
+
en: ["Thank you :D", "Thanks :D", "Thx a lot :-)"],
|
62
|
+
tam: ["நன்றி !!! :D"]
|
63
|
+
},
|
64
|
+
access_token: "PASTE YOUR ACCESS TOKEN HERE",
|
65
|
+
wish_count: 256
|
66
|
+
})
|
67
|
+
```
|
22
68
|
|
23
69
|
## Contributing
|
24
70
|
|
25
|
-
1. Fork it ( https://github.com/
|
71
|
+
1. Fork it ( https://github.com/mudassir0909/fbwish/fork )
|
26
72
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
73
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
74
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/fbwish/version.rb
CHANGED
data/lib/fbwish.rb
CHANGED
@@ -3,23 +3,28 @@ require "koala"
|
|
3
3
|
|
4
4
|
module Fbwish
|
5
5
|
class Wisher
|
6
|
+
|
7
|
+
attr_accessor :graph, :matcher, :replies, :wish_count
|
8
|
+
|
6
9
|
def initialize(options={})
|
7
|
-
required_options = [:access_token, :matcher, :replies]
|
8
|
-
unspecified_options =
|
10
|
+
required_options = [:access_token, :matcher, :replies, :wish_count]
|
11
|
+
unspecified_options = required_options.reject{ |key| options[key] }
|
9
12
|
|
10
13
|
unless unspecified_options.empty?
|
11
|
-
raise ArgumentError
|
14
|
+
raise ArgumentError, "Following options are required: #{unspecified_options.join(', ')}"
|
12
15
|
end
|
13
16
|
|
14
17
|
self.graph = Koala::Facebook::API.new(options[:access_token])
|
15
18
|
self.matcher = options[:matcher]
|
16
19
|
self.replies = options[:replies]
|
20
|
+
self.wish_count = options[:wish_count]
|
17
21
|
end
|
18
22
|
|
19
23
|
def wish_em_all!
|
20
24
|
wishes = nil
|
25
|
+
iteration_count = (wish_count.to_f / 25).ceil
|
21
26
|
|
22
|
-
1.upto(
|
27
|
+
1.upto(iteration_count) do |idx|
|
23
28
|
wishes = wishes.next_page rescue graph.get_connections('me', 'feed')
|
24
29
|
|
25
30
|
wishes.each do |wish|
|
@@ -42,7 +47,7 @@ module Fbwish
|
|
42
47
|
end
|
43
48
|
|
44
49
|
def like_and_comment(wish)
|
45
|
-
if matcher.is_a?(
|
50
|
+
if matcher.is_a?(Hash)
|
46
51
|
matcher.each do |locale, regex|
|
47
52
|
if regex.match(wish['message'])
|
48
53
|
like(wish)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fbwish
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mudassir Ali
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|