skype_bot 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a03d772b5abd91c6c8d895f55d583fb08873314a
4
- data.tar.gz: bb50576e96b07f8fbe53adb6cb591817edd6bf2e
3
+ metadata.gz: d3d9b5126b4cde9b2cdd812112532f7d99222389
4
+ data.tar.gz: fe10629998d37c84b413bd6c62d18ceec70fe8bb
5
5
  SHA512:
6
- metadata.gz: 0a298a2b7b6b01cefa30270e585d021b9f15861126d13ad6fc60f5d9c69ffb54fde5a45d533e1c3a6598bf116b0a3a58c058e8375d52c34fea6b7646687cb71f
7
- data.tar.gz: 8f5d756b0a6f7a0abca476dff820e01a269dc077ba21dd305968c323b0e5c82c59caf1e15be274c3e8afb330aa2f9c2c7cccb7e60aee8722901ada67c015ad27
6
+ metadata.gz: b02f3f75ca4ca16f8a60f81f2ae535d3675db7f4378c5eb735b5bc50c88d24879ebae2342636a22354d0bf9e972f5452c4b9e1a29a38c029ea82601a90b9ee9f
7
+ data.tar.gz: bbe441f731945e907798865c950de0242dd1e9887555d0b87a0cb021eec02f507b5984205af7486abba5927b689503aa07f7bedc3a020c5222b7c16385121953
@@ -2,11 +2,11 @@ module SkypeBot
2
2
  module Activity
3
3
  extend self
4
4
 
5
- CONVERSATION_URL = 'https://apis.skype.com/v2/conversations'
5
+ CONVERSATION_URL = 'https://skype.botframework.com/v3/conversations'
6
6
 
7
7
  def text_message(uid, content)
8
8
  token = Auth.get_token
9
- body = { message: { content: content } }.to_json
9
+ body = payload(uid, content).to_json
10
10
  headers = { Authorization: "Bearer #{token}", 'Content-Type': 'application/json' }
11
11
  url = activity_url(uid)
12
12
 
@@ -18,5 +18,17 @@ module SkypeBot
18
18
  def activity_url(uid)
19
19
  "#{CONVERSATION_URL}/#{uid}/activities"
20
20
  end
21
+
22
+ def payload(uid, content)
23
+ {
24
+ type: 'message',
25
+ agent: 'botbuilder',
26
+ source: 'skype',
27
+ text: content,
28
+ from: { id: "#{Config.skype_number}:#{Config.app_id}" },
29
+ recipient: { id: uid },
30
+ channelData: {}
31
+ }
32
+ end
21
33
  end
22
34
  end
@@ -4,6 +4,7 @@ module SkypeBot
4
4
  mattr_accessor :bot_id
5
5
  mattr_accessor :app_id
6
6
  mattr_accessor :app_secret
7
+ mattr_accessor :skype_number
7
8
 
8
9
  mattr_accessor :scope
9
10
  @@scope = 'https://graph.microsoft.com/.default'
@@ -3,21 +3,18 @@ module SkypeBot
3
3
  attr_accessor :payload
4
4
 
5
5
  def initialize(data)
6
- @payload = data['_json']
6
+ @payload = data['skype']
7
7
  end
8
8
 
9
9
  def execute
10
- payload.map do |event|
11
- {
12
- action: event['action'],
13
- type: event['activity'].underscore,
14
- from: event['from'],
15
- display_name: event['fromDisplayName'],
16
- to: event['to'],
17
- time: Time.parse(event['time']),
18
- content: event['content']
19
- }
20
- end
10
+ {
11
+ type: payload['type'].underscore,
12
+ from: payload['from']['id'],
13
+ display_name: payload['from']['name'],
14
+ to: payload['recipient']['id'],
15
+ time: Time.parse(payload['timestamp']),
16
+ content: payload['text']
17
+ }
21
18
  end
22
19
  end
23
20
  end
@@ -1,3 +1,3 @@
1
1
  module SkypeBot
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: skype_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - MQuy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-24 00:00:00.000000000 Z
11
+ date: 2016-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler