edi 0.4.0 → 0.4.1

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: 601cdae478aa39f3a62c7fa674c5611004d72d5c
4
- data.tar.gz: 4c663b2a26f1006c0ab47c63f3e323b68b4fd985
3
+ metadata.gz: ef25fec135979397b1fea972687189980ee8a5fb
4
+ data.tar.gz: 9c041ea28f1aef74c9d53d7be8cd798e5cb87aa8
5
5
  SHA512:
6
- metadata.gz: 430594d7295f5dc3827b2d4cf1d29e988d1599eb3b0cfbd6b8e6f1f12ffd4ba32348abae9b92f11205f52b6efb5ef581d87cd4b90723a3d1fb0a3c87cdc67291
7
- data.tar.gz: bb11a163d75bb8eb35bce7949ed1cbc1891ea89833ead95b1c0607c98f8516c9a3d40068204c8a65b486b8e079e8a3a4714fd6b5b9e84742c9c64e2378edd607
6
+ metadata.gz: 85899c1736993aae9099e35cbbe0a161c3ecf711f3452a075550b9b6b652b93dc3b9db3a63d5267628a20f478117b074c27b2c5d1f9a70308a84180ce31ca273
7
+ data.tar.gz: 757cdb058ef18868bef48b1b38e79955d23b0d7f9af18e81f23c27032138392601dbac4c9052380396a8246ba84da7a058414d6602debc539b747d951d7da14c
data/README.md CHANGED
@@ -18,11 +18,11 @@ $ edi new my-bot
18
18
 
19
19
  ### Registering Services
20
20
 
21
- `/bot/server.rb` is the main brain of your edi bot. Here you can register which services you want to be available on your chatbot.
21
+ `bot/core.rb` is the main brain of your edi bot. Here you can register which services you want to be available on your chatbot.
22
22
 
23
23
  ```ruby
24
- class Server < EDI::Server
25
- register_services :tweet_that, :img_flip, :urban_dictionary, :weather
24
+ class Core < EDI::Core
25
+ register_services :tweet_that, :img_flip, :urban_dictionary, :weather, :joke
26
26
  end
27
27
  ```
28
28
 
@@ -38,7 +38,7 @@ class MyService < EDI::Service
38
38
  end
39
39
  ```
40
40
 
41
- If a service is Registered in `bot/server.rb` but does not have it's expected environment, edi will throw an exception and respond with a polite refusal to execute the service. This message can be set in your EDI configuration. The enviornment method will also create a getter method for each environment variable.
41
+ If a service is Registered in `bot/core.rb` but does not have it's expected environment, edi will throw an exception and respond with a polite refusal to execute the service. This message can be set in your EDI configuration. The enviornment method will also create a getter method for each environment variable.
42
42
 
43
43
  ### Service Routing
44
44
 
@@ -91,13 +91,12 @@ You can do actions before or after the service is run, but before edi responds.
91
91
 
92
92
  ```ruby
93
93
  class Joke < EDI::Service
94
- include Postable
95
94
  before_invoke :setup
96
95
  invoke_with :punch
97
96
 
98
97
  def setup
99
- post_to_slack(message: "What do you call a fish with no eyes?", channel: "##{channel_name}")
100
- sleep 1
98
+ EDI.send_message("What do you call a fish with no eyes?", channel: channel)
99
+ sleep 2
101
100
  end
102
101
 
103
102
  def punch
@@ -111,7 +110,7 @@ end
111
110
  Since EDI is, under the hood, a web socket client, it can be deployed to any internet connected computer, and does not require a web server. Simple run
112
111
 
113
112
  ```shell
114
- $ edi start -D
113
+ $ edi start
115
114
  ```
116
115
 
117
116
  And EDI will connect to slack and will stay connected for the life of the process.
@@ -129,21 +128,6 @@ When these things are done, we'll be ready for 1.0
129
128
  - [x] Boot Process for the Generated App
130
129
  - [x] Switch from sinatra-based incoming and outgoing webhooks to websocket-based implementation
131
130
 
132
- ## Upcoming Features
133
-
134
- This stuff isn't true yet, think of this section as a scratchpad for designs to be.
135
-
136
- ### Messages
137
-
138
- You can make special classes that model special messages you'd like EDI to send into slack. These have all the functionality of Slack's Message Attachments for making richly formatted messages.
139
-
140
- ```ruby
141
- class CiMessage < EDI::Message
142
- channel "#general"
143
-
144
- end
145
- ```
146
-
147
131
  ## Contributing
148
132
 
149
133
  1. Fork it ( https://github.com/DVG/EDI/fork )
@@ -1,3 +1,3 @@
1
1
  module EDI
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
@@ -0,0 +1 @@
1
+ variables.sh
@@ -1,6 +1,6 @@
1
1
  class Core < EDI::Core
2
2
  # Use `register_services` to enable services in your EDI Bot. Available built-in services are:
3
- # :dice, :eightball, :fact, :giphy, :i_heart_quotes
3
+ # :dice, :eightball, :fact, :giphy, :i_heart_quotes, :img_flip, :tweet_that, :weather
4
4
  # You can make your own services with `edi generate service my_service`
5
5
  register_services :fact
6
6
  end
@@ -2,7 +2,8 @@ require 'bundler/setup'
2
2
  Bundler.require(:default)
3
3
  EDI.configure do |config|
4
4
  config.root = File.expand_path "./"
5
- # Your bot's name, not required for anything, but you can use it to have your bot speak it's name
5
+ # Your bot's name. Defaults to "EDI". Used to determine if your bot should respond to a given message, and can also be used
6
+ # to have your bot speak it's name via EDI.bot_name
6
7
  # config.bot_name = "EDI"
7
8
 
8
9
  # Default response is what EDI will say in response to a message that doesn't have a registered service.
@@ -23,8 +24,5 @@ EDI.configure do |config|
23
24
 
24
25
  # Add additional autoload directories to autoload_paths
25
26
  # config.autoload_paths += "bot/models"
26
-
27
- # Default channel to post to using the post_to_slack method
28
- # config.default_channel = "#general"
29
27
  end
30
28
  EDI.bootstrap
@@ -0,0 +1,26 @@
1
+ # Use this shell script to set up your environment variables.
2
+ # Run cp variables.sh.example variables.sh
3
+
4
+ # Slack API Token. Generate token at https://api.slack.com/web
5
+ export SLACK_TOKEN=
6
+
7
+ # Bot User Integration Token. Create your bot user integration at https://YOURTEAM.slack.com/services/new#diy
8
+ export SLACK_EDI_TOKEN=
9
+
10
+ # Giphy Service Configuration. Public Beta API Key Included Below
11
+ export GIPHY_API_KEY=dc6zaTOxFJmzC
12
+ export GIPHY_API_VERSION=v1
13
+
14
+ # Tweet That Service Variables
15
+ export TWITTER_ACCESS_TOKEN=
16
+ export TWITTER_CONSUMER_KEY=
17
+ export TWITTER_CONSUMER_SECRET=
18
+ export TWITTER_HANDLE=
19
+ export TWITTER_TOKEN_SECRET=
20
+
21
+ # ImgFlip Service Variables. Set up a User at https://imgflip.com/signup
22
+ export IMGFLIP_USER=
23
+ export IMGFLIP_PASSWORD=
24
+
25
+ # ZIP Code to use as the default location for the weather service.
26
+ export DEFAULT_LOCATION=90210
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - DVG
@@ -288,7 +288,6 @@ files:
288
288
  - ".rspec"
289
289
  - ".ruby-version"
290
290
  - ".travis.yml"
291
- - ":w"
292
291
  - Gemfile
293
292
  - Guardfile
294
293
  - LICENSE.txt
@@ -391,6 +390,7 @@ files:
391
390
  - spec/support/fixtures/vcr_cassettes/weather.yml
392
391
  - spec/support/shared_contexts/server.rb
393
392
  - spec/support/shared_contexts/service.rb
393
+ - templates/project/.gitignore
394
394
  - templates/project/Gemfile
395
395
  - templates/project/boot.rb
396
396
  - templates/project/bot/core.rb
@@ -398,6 +398,7 @@ files:
398
398
  - templates/project/config/.gitkeep
399
399
  - templates/project/config/environment.rb
400
400
  - templates/project/config/initializers/.gitkeep
401
+ - templates/project/variables.sh.example
401
402
  - templates/services/%name%.rb.tt
402
403
  homepage: https://github.com/DVG/edi.git
403
404
  licenses:
data/:w DELETED
@@ -1,57 +0,0 @@
1
- require 'faye/websocket'
2
- require 'eventmachine'
3
-
4
- module Websocket
5
- class Client
6
- attr_accessor :ws_url, :client, :id
7
-
8
- def initialize
9
- self.id = 1
10
- end
11
-
12
- def connect
13
- connection = EDI.get("https://slack.com/api/rtm.start?token=#{EDI.bot_token}").response
14
- require 'byebug'
15
- debugger
16
- self.ws_url = connection["url"]
17
- EM.run {
18
-
19
- self.client = Faye::WebSocket::Client.new(ws_url)
20
-
21
- client.on :open do |event|
22
- puts "EDI is now online"
23
- end
24
-
25
- # Respond to Messages
26
- client.on :message do |event|
27
- incoming_message = Slack::WebsocketIncomingMessage.new(event.data)
28
- if incoming_message.should_respond?
29
- puts "EDI received message #{incoming_message.text} in channel #{incoming_message.channel}"
30
- response_text = ""
31
- service = Proc.new { response_text = EDI.runner.new(message: incoming_message).execute }
32
- response = Proc.new { client.send Slack::WebsocketOutgoingMessage.new(text: response_text, channel: incoming_message.channel, id: id).to_json if response_text }
33
- EM.defer service, response
34
- increment_id
35
- end
36
- end
37
-
38
- # Kepp Websocket Connection Alive
39
- EM.add_periodic_timer(1) do
40
- client.ping
41
- end
42
- }
43
- end
44
-
45
- def send_message(message)
46
- client.send Slack::WebsocketOutgoingMessage.new(text: message, channel: "D046WN43L", id: id).to_json
47
- increment_id
48
- end
49
-
50
- private
51
-
52
- # There has to be a way to do this better
53
- def increment_id
54
- self.id += 1
55
- end
56
- end
57
- end