synthetic 0.1.0
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 +7 -0
- data/.gitignore +17 -0
- data/CHANGES.md +6 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +22 -0
- data/Rakefile +1 -0
- data/bin/synthetic +35 -0
- data/lib/synthetic/bot.rb +68 -0
- data/lib/synthetic/configuration/bot.rb +11 -0
- data/lib/synthetic/controller.rb +4 -0
- data/lib/synthetic/version.rb +4 -0
- data/lib/synthetic.rb +2 -0
- data/synthetic.gemspec +26 -0
- metadata +143 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: df6b95d2c2b85ab76e23ea2837633066ca4f9d4b
|
4
|
+
data.tar.gz: 5ec543d4af20f3ccd38f5cd45b1644a41e88bd5f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1c031184d81ab4d2a5a3de399c71b1f1bbc177a9796994af77ac9ecdc40e4de90b27e9019dc1ec37ac9963cd25e8b22d9e78ceedd18981fdc072ca482ac1ab58
|
7
|
+
data.tar.gz: 15b99274c69570c41f921c6690b96f3bde3b2dbcd4fbb96478fbbc0df911fd93a1ea8265f0151361167af10e96a74557001711bc5752b968a9a8b94e3d9aee1a
|
data/.gitignore
ADDED
data/CHANGES.md
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Justin Workman
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Synthetic Bot Framework
|
2
|
+
=======================
|
3
|
+
|
4
|
+
Synthetic is an IRC bot framework based on Cinch and Wit. It is in the early
|
5
|
+
development stages.
|
6
|
+
|
7
|
+
Installation and usage examples will be provided before the first stable
|
8
|
+
release, but for now you're on your own.
|
9
|
+
|
10
|
+
## Contributing
|
11
|
+
|
12
|
+
1. Fork it
|
13
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
14
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
15
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
16
|
+
5. Create new Pull Request
|
17
|
+
|
18
|
+
## License
|
19
|
+
|
20
|
+
Copyright © 2013 [Justin Workman](mailto:xtagon@gmail.com)
|
21
|
+
|
22
|
+
MIT License, see LICENSE.txt
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/bin/synthetic
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'slop'
|
4
|
+
|
5
|
+
Slop.parse help: true do
|
6
|
+
# Version
|
7
|
+
# -------
|
8
|
+
on :v, :version, 'Print the version.' do
|
9
|
+
require 'synthetic/version'
|
10
|
+
puts "Synthetic v#{Synthetic::VERSION}"
|
11
|
+
end
|
12
|
+
|
13
|
+
# Start
|
14
|
+
# -----
|
15
|
+
command 'start' do
|
16
|
+
on :w=, :wit_token=, 'Wit access token (required)'
|
17
|
+
on :r=, :root=, "Your bot's root directory (default current directory)", default: ENV['PWD']
|
18
|
+
on :s=, :server=, 'IRC server (default localhost)', default: 'localhost'
|
19
|
+
on :p=, :port=, 'Server port (default 6667)', default: 6667, as: Integer
|
20
|
+
on :c=, :channels=, 'List of channels to join', as: Array, default: []
|
21
|
+
on :n=, :nicks=, 'Bot nick(s)', as: Array, default: ['SynthBot']
|
22
|
+
on :u=, :user=, 'Bot User Name', default: 'SynthBot'
|
23
|
+
on :R=, :realname=, 'Bot Real Name', default: 'SynthBot'
|
24
|
+
on :P=, :password=, 'Bot Password', default: nil
|
25
|
+
on :m=, :modes=, 'Modes', as: Array, default: []
|
26
|
+
on :i=, :ping=, 'Ping interval (in seconds)', as: Integer, default: 120
|
27
|
+
|
28
|
+
run do |options, args|
|
29
|
+
abort options.help if options[:wit_token].nil?
|
30
|
+
|
31
|
+
require 'synthetic'
|
32
|
+
Synthetic::Bot.new(options.to_hash).start
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Synthetic
|
2
|
+
require 'cinch'
|
3
|
+
require 'cinch/wit'
|
4
|
+
|
5
|
+
require 'synthetic/configuration/bot'
|
6
|
+
require 'synthetic/controller'
|
7
|
+
|
8
|
+
require 'yaml'
|
9
|
+
|
10
|
+
class Bot < Cinch::Bot
|
11
|
+
def initialize(options={})
|
12
|
+
super()
|
13
|
+
|
14
|
+
# Override Cinch's bot configuration with our own extended one
|
15
|
+
@config = Synthetic::Configuration::Bot.new
|
16
|
+
|
17
|
+
# Configure any known bot options that were passed, ignoring unknown keys
|
18
|
+
options.select do |key, value|
|
19
|
+
Cinch::Configuration::Bot::KnownOptions.include?(key)
|
20
|
+
end.each do |key, value|
|
21
|
+
@config[key] = value
|
22
|
+
end
|
23
|
+
|
24
|
+
# Enable Wit for Cinch
|
25
|
+
@config.plugins.plugins << Cinch::Plugins::Wit
|
26
|
+
@config.plugins.options[Cinch::Plugins::Wit][:access_token] = options[:wit_token]
|
27
|
+
|
28
|
+
# Load bot app
|
29
|
+
load_root!
|
30
|
+
|
31
|
+
# Catch intent events and route to their designated controller
|
32
|
+
on :intent do |msg, wit|
|
33
|
+
if msg.bot.routes.has_key?(wit['intent'])
|
34
|
+
controller = msg.bot.routes[wit['intent']].new
|
35
|
+
controller.send(wit['intent'], msg, wit)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
attr_accessor :routes
|
41
|
+
|
42
|
+
private
|
43
|
+
|
44
|
+
def load_root!
|
45
|
+
# Add the bot root directory to load path
|
46
|
+
if File.directory?(@config[:root]) && !$LOAD_PATH.include?(@config[:root])
|
47
|
+
$LOAD_PATH.unshift(@config[:root])
|
48
|
+
end
|
49
|
+
|
50
|
+
# Require source files in the bot root directory
|
51
|
+
matcher = /\A#{Regexp.escape(@config[:root])}\/(.*)\.rb\Z/
|
52
|
+
Dir.glob("#{@config[:root]}/app/**/*.rb").sort.each do |file|
|
53
|
+
debug "Requiring '#{file.sub(matcher, '\1')}'"
|
54
|
+
require file.sub(matcher, '\1')
|
55
|
+
end
|
56
|
+
|
57
|
+
# Load routes config file
|
58
|
+
@routes = Hash.new
|
59
|
+
routes_config = YAML.load_file "#{@config[:root]}/config/routes.yml"
|
60
|
+
routes_config.each do |route|
|
61
|
+
intents = (route['intent'] || []) + (route['intents'] || [])
|
62
|
+
intents.each do |intent|
|
63
|
+
@routes[intent] = Object.const_get(route['to'].capitalize + 'Controller')
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/synthetic.rb
ADDED
data/synthetic.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'synthetic/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'synthetic'
|
7
|
+
spec.version = Synthetic::VERSION
|
8
|
+
spec.authors = ['Justin Workman']
|
9
|
+
spec.email = ['xtagon@gmail.com']
|
10
|
+
spec.summary = "Synthetic is an IRC bot framework based on Cinch and Wit."
|
11
|
+
spec.description = spec.summary
|
12
|
+
spec.license = 'MIT'
|
13
|
+
|
14
|
+
spec.files = `git ls-files`.split($/)
|
15
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
16
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_runtime_dependency 'cinch', '~> 2.0'
|
20
|
+
spec.add_runtime_dependency 'cinch-wit', '~> 0.0.2'
|
21
|
+
spec.add_runtime_dependency 'slop', '~> 3.4'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'pry-debugger'
|
25
|
+
spec.add_development_dependency 'rake'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,143 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: synthetic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Justin Workman
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: cinch
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: cinch-wit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.0.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.0.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: slop
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.4'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.4'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry-debugger
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: Synthetic is an IRC bot framework based on Cinch and Wit.
|
98
|
+
email:
|
99
|
+
- xtagon@gmail.com
|
100
|
+
executables:
|
101
|
+
- synthetic
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- .gitignore
|
106
|
+
- CHANGES.md
|
107
|
+
- Gemfile
|
108
|
+
- LICENSE.txt
|
109
|
+
- README.md
|
110
|
+
- Rakefile
|
111
|
+
- bin/synthetic
|
112
|
+
- lib/synthetic.rb
|
113
|
+
- lib/synthetic/bot.rb
|
114
|
+
- lib/synthetic/configuration/bot.rb
|
115
|
+
- lib/synthetic/controller.rb
|
116
|
+
- lib/synthetic/version.rb
|
117
|
+
- synthetic.gemspec
|
118
|
+
homepage:
|
119
|
+
licenses:
|
120
|
+
- MIT
|
121
|
+
metadata: {}
|
122
|
+
post_install_message:
|
123
|
+
rdoc_options: []
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - '>='
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - '>='
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '0'
|
136
|
+
requirements: []
|
137
|
+
rubyforge_project:
|
138
|
+
rubygems_version: 2.0.3
|
139
|
+
signing_key:
|
140
|
+
specification_version: 4
|
141
|
+
summary: Synthetic is an IRC bot framework based on Cinch and Wit.
|
142
|
+
test_files: []
|
143
|
+
has_rdoc:
|