hipbot-plugins 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -2
- data/Gemfile +6 -0
- data/lib/hipbot-plugins.rb +1 -0
- data/lib/hipbot-plugins/human.rb +4 -2
- data/lib/hipbot-plugins/rapportive.rb +89 -0
- data/lib/hipbot-plugins/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7413e3e88a6f97c43b264b0fa154dd172483f4a0
|
4
|
+
data.tar.gz: 724a3bfcaf01d8569ca719ac9aa01368cd62012a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef6004a04df220d9079fc4bb37dad49ba69bf1f4a98c09058d530748cb51b6ad5c6637e809286424cc3eb80ee0d9fa3cf8e337d524b9a9d193e9f4288ea9c3cd
|
7
|
+
data.tar.gz: 835a112d937fdd52ccf5ae58a38665d81d6e7f0cac6eba61e87d7d357c03b1e06fa4e70032b16566fa9fda93e668b9fde17c1124d878917fbb3b54c9573155cf
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/lib/hipbot-plugins.rb
CHANGED
data/lib/hipbot-plugins/human.rb
CHANGED
@@ -20,8 +20,10 @@ module Hipbot
|
|
20
20
|
end
|
21
21
|
|
22
22
|
desc 'slaps given user eg. `slap @admin`'
|
23
|
-
on /slap (.+)/ do
|
24
|
-
|
23
|
+
on /slap (.+)/ do
|
24
|
+
message.mentions.each do |mention|
|
25
|
+
reply("/me slaps #{mention} around a bit with a large trout.")
|
26
|
+
end
|
25
27
|
end
|
26
28
|
|
27
29
|
desc 'randomly chooses by default 1 person from online users eg. `choose 3`'
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'open-uri'
|
2
|
+
|
3
|
+
module Hipbot
|
4
|
+
module Plugins
|
5
|
+
class Rapportive
|
6
|
+
include Hipbot::Plugin
|
7
|
+
|
8
|
+
desc 'do something'
|
9
|
+
on /^raport (\S*) (\S*) from (.*)/ do |firstname, lastname, domain|
|
10
|
+
raport = Rapportive.new(firstname, lastname, domain)
|
11
|
+
reply(raport.to_s)
|
12
|
+
end
|
13
|
+
|
14
|
+
class Rapportive
|
15
|
+
attr_accessor :firstname, :lastname, :domain
|
16
|
+
|
17
|
+
def initialize(firstname, lastname, domain)
|
18
|
+
self.firstname = firstname
|
19
|
+
self.lastname = lastname
|
20
|
+
self.domain = domain
|
21
|
+
end
|
22
|
+
|
23
|
+
def to_s
|
24
|
+
return "Sorry, I could not find email address" if profile.nil?
|
25
|
+
"Found it! Email #{profile['contact']['email']} is valid."
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def session_token
|
31
|
+
begin
|
32
|
+
@token ||= open(session_token_url).read
|
33
|
+
JSON.parse(@token).fetch(:session_token) { "" }
|
34
|
+
rescue OpenURI::HTTPError
|
35
|
+
""
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def session_token_url
|
40
|
+
"https://rapportive.com/login_status?user_email=#{random_email}"
|
41
|
+
end
|
42
|
+
|
43
|
+
def profile
|
44
|
+
emails.each do |email|
|
45
|
+
begin
|
46
|
+
body = open(profiles_url(email), "X-Session-Token" => session_token).read
|
47
|
+
contact = JSON.parse(body)
|
48
|
+
return contact if found?(contact)
|
49
|
+
rescue OpenURI::HTTPError
|
50
|
+
nil # returns nil for check in to_s method - requests limit reached
|
51
|
+
end
|
52
|
+
end
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def profiles_url(email)
|
57
|
+
"https://profiles.rapportive.com/contacts/email/#{email}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def emails
|
61
|
+
[
|
62
|
+
"#{firstname}.#{lastname}",
|
63
|
+
"#{firstname}#{lastname}",
|
64
|
+
"#{firstname_letter}#{lastname}",
|
65
|
+
"#{firstname_letter}.#{lastname}",
|
66
|
+
"#{firstname}",
|
67
|
+
"#{lastname}",
|
68
|
+
"#{firstname}-#{lastname}",
|
69
|
+
"#{firstname}_#{lastname}"
|
70
|
+
].map do |email|
|
71
|
+
email + '@' + domain
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def firstname_letter
|
76
|
+
self.firstname[0]
|
77
|
+
end
|
78
|
+
|
79
|
+
def random_email
|
80
|
+
SecureRandom.hex + '@gmail.com'
|
81
|
+
end
|
82
|
+
|
83
|
+
def found?(contact)
|
84
|
+
contact['contact']['first_name'] != "" && contact['contact']['last_name'] != ""
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hipbot-plugins
|
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
|
- Bartosz Kopiński
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hipbot
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- lib/hipbot-plugins/help.rb
|
126
126
|
- lib/hipbot-plugins/human.rb
|
127
127
|
- lib/hipbot-plugins/meme_generator.rb
|
128
|
+
- lib/hipbot-plugins/rapportive.rb
|
128
129
|
- lib/hipbot-plugins/urban_dictionary.rb
|
129
130
|
- lib/hipbot-plugins/version.rb
|
130
131
|
- lib/hipbot-plugins/wolfram_alpha.rb
|