bender-bot 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 96464ae31bbfe17baeab335880504aa1900a363a
4
+ data.tar.gz: 6c140ca83b456be05cd33c7f7c24d27c28d00fe8
5
+ SHA512:
6
+ metadata.gz: 7e29c40bb49d93c64bcc04c9292f557ba021a51a222a65d9a5e44ab2006fdc6dc5f2aff5dd3db5b6588bb1c0115655987fea8da34685be5fd77a25ac98636fbc
7
+ data.tar.gz: 1c5505dbe45432ace49b97196ca3f89a182622f19eb48b23f29fa72862891734f83f5948af7781e77691efbcd44e75b444f63f33f690e941804d12e8266fea50
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2015 Sean Clemmer
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any
4
+ purpose with or without fee is hereby granted, provided that the above
5
+ copyright notice and this permission notice appear in all copies.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
+ PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # Bender ![Version](https://img.shields.io/gem/v/bender.svg?style=flat-square)
2
+
3
+ Yet another HipChat bot.
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bender'
3
+ Bender::Main.start ARGV
@@ -0,0 +1 @@
1
+ require_relative 'bender/main'
@@ -0,0 +1,34 @@
1
+ require 'thread'
2
+
3
+ require 'robut'
4
+ require 'robut/storage/yaml_store'
5
+
6
+ Bot = Robut # alias
7
+
8
+
9
+
10
+ module Bot
11
+ def self.run!
12
+ Bot::Plugin.plugins = [ Bot::Plugin::Bender ]
13
+ Bot::Web.set :connection, Bot::Connection.new.connect
14
+ end
15
+ end
16
+
17
+
18
+ module Bot
19
+ module Plugin
20
+ class Bender
21
+ include Bot::Plugin
22
+
23
+
24
+ def handle time, sender, message
25
+ if message =~ /bender/
26
+ reply 'What, %s?! (%s)' % [ sender, time ]
27
+ end
28
+
29
+ return true
30
+ end
31
+
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,108 @@
1
+ require 'logger'
2
+
3
+ require 'tilt/erb'
4
+
5
+ require_relative 'metadata'
6
+ require_relative 'mjolnir'
7
+ require_relative 'web'
8
+ require_relative 'bot'
9
+
10
+
11
+ module Bender
12
+ class Main < Mjolnir
13
+
14
+ desc 'version', 'Echo the application version'
15
+ def version
16
+ puts VERSION
17
+ end
18
+
19
+
20
+ desc 'art', 'View the application art'
21
+ def art
22
+ puts "\n%s\n" % ART
23
+ end
24
+
25
+
26
+
27
+ desc 'bot', 'Start Bender HipChat bot and Web server'
28
+ option :bind, \
29
+ type: :string,
30
+ aliases: %w[ -b ],
31
+ desc: 'Set Sinatra interface',
32
+ default: '0.0.0.0'
33
+ option :port, \
34
+ type: :numeric,
35
+ aliases: %w[ -o ],
36
+ desc: 'Set Sinatra port',
37
+ default: 4567
38
+ option :environment, \
39
+ type: :string,
40
+ aliases: %w[ -e ],
41
+ desc: 'Set Sinatra environment',
42
+ default: 'development'
43
+ option :jid, \
44
+ type: :string,
45
+ aliases: %w[ -j ],
46
+ desc: 'Set HipChat JID',
47
+ required: true
48
+ option :password, \
49
+ type: :string,
50
+ aliases: %w[ -p ],
51
+ desc: 'Set HipChat password',
52
+ required: true
53
+ option :nick, \
54
+ type: :string,
55
+ aliases: %w[ -n ],
56
+ desc: 'Set HipChat nick name',
57
+ required: true
58
+ option :mention, \
59
+ type: :string,
60
+ aliases: %w[ -m ],
61
+ desc: 'Set HipChat mention name',
62
+ required: true
63
+ option :rooms, \
64
+ type: :string,
65
+ aliases: %w[ -r ],
66
+ desc: 'Set HipChat rooms (comma-separated)',
67
+ required: true
68
+ option :database, \
69
+ type: :string,
70
+ aliases: %w[ -d ],
71
+ desc: 'Set path to application database',
72
+ required: true
73
+ include_common_options
74
+ def start
75
+ Bot::Connection.configure do |config|
76
+ config.jid = options.jid
77
+ config.password = options.password
78
+ config.nick = options.mention
79
+ config.mention_name = options.nick
80
+ config.rooms = options.rooms.split(',')
81
+
82
+ Bot::Storage::YamlStore.file = options.database
83
+ config.store = Bot::Storage::YamlStore
84
+
85
+ config.logger = log
86
+ end
87
+
88
+ Bot.run!
89
+
90
+
91
+ Web.set :environment, options.environment
92
+ Web.set :port, options.port
93
+ Web.set :bind, options.bind
94
+ Web.set :store, options.database
95
+
96
+ if log.level >= ::Logger::DEBUG
97
+ Web.set :raise_errors, true
98
+ Web.set :dump_errors, true
99
+ Web.set :show_exceptions, true
100
+ Web.set :logging, ::Logger::DEBUG
101
+ end
102
+
103
+ Web.run!
104
+ end
105
+
106
+
107
+ end
108
+ end
@@ -0,0 +1,39 @@
1
+ module Bender
2
+ # Project root
3
+ ROOT = File.dirname(__FILE__), '..', '..'
4
+
5
+ # Pull the project version out of the VERSION file
6
+ VERSION = File.read(File.join(ROOT, 'VERSION')).strip
7
+
8
+ # We don't really do all that much, be humble
9
+ SUMMARY = 'Yet another HipChat bot'
10
+
11
+ # Your benevolent dictator for life
12
+ AUTHOR = 'Sean Clemmer'
13
+
14
+ # Turn here to strangle your dictator
15
+ EMAIL = 'sclemmer@bluejeans.com'
16
+
17
+ # Like the MIT license, but even simpler
18
+ LICENSE = 'ISC'
19
+
20
+ # If you really just can't get enough
21
+ HOMEPAGE = 'https://github.com/sczizzo/bender'
22
+
23
+ # Bundled extensions
24
+ TRAVELING_RUBY_VERSION = '20150210-2.2.0'
25
+ THIN_VERSION = '1.6.3'
26
+ EM_VERSION = '1.0.4'
27
+
28
+ # Every project deserves its own ASCII art
29
+ ART = <<-'EOART' % VERSION
30
+ ,, ,,
31
+ *MM `7MM
32
+ MM MM
33
+ MM,dMMb. .gP"Ya `7MMpMMMb. ,M""bMM .gP"Ya `7Mb,od8
34
+ MM `Mb ,M' Yb MM MM ,AP MM ,M' Yb MM' "'
35
+ MM M8 8M"""""" MM MM 8MI MM 8M"""""" MM
36
+ MM. ,M9 YM. , MM MM `Mb MM YM. , MM
37
+ P^YbmdP' `Mbmmd'.JMML JMML.`Wbmd"MML.`Mbmmd'.JMML. v%s
38
+ EOART
39
+ end
@@ -0,0 +1,56 @@
1
+ require 'slog'
2
+ require 'thor'
3
+
4
+
5
+ # Thor's hammer! Like Thor with better logging
6
+ class Mjolnir < Thor
7
+
8
+ # Common options for Thor commands
9
+ COMMON_OPTIONS = {
10
+ log: {
11
+ type: :string,
12
+ aliases: %w[ -L ],
13
+ desc: 'Log to file instead of STDOUT',
14
+ default: ENV['BENDER_LOG'] || nil
15
+ },
16
+ debug: {
17
+ type: :boolean,
18
+ aliases: %w[ -V ],
19
+ desc: 'Enable DEBUG-level logging',
20
+ default: ENV['BENDER_DEBUG'] || false
21
+ },
22
+ trace: {
23
+ type: :boolean,
24
+ aliases: %w[ -VV ],
25
+ desc: 'Enable TRACE-level logging',
26
+ default: ENV['BENDER_TRACE'] || false
27
+ }
28
+ }
29
+
30
+ # Decorate Thor commands with the options above
31
+ def self.include_common_options
32
+ COMMON_OPTIONS.each do |name, spec|
33
+ option name, spec
34
+ end
35
+ end
36
+
37
+
38
+ no_commands do
39
+
40
+ # Construct a Logger given the command-line options
41
+ def log
42
+ return @logger if defined? @logger
43
+ level = :info
44
+ level = :debug if options.debug?
45
+ level = :trace if options.trace?
46
+ device = options.log || $stderr
47
+ pretty = device.tty? rescue false
48
+ @logger = Slog.new \
49
+ out: device,
50
+ level: level,
51
+ colorize: pretty,
52
+ prettify: pretty
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,36 @@
1
+ require 'pathname'
2
+ require 'thread'
3
+ require 'json'
4
+
5
+ require 'sinatra/base'
6
+
7
+ require_relative 'metadata'
8
+
9
+ Thread.abort_on_exception = true
10
+
11
+
12
+ module Bender
13
+ class Web < Sinatra::Application
14
+ set :root, File.join(Bender::ROOT, 'web')
15
+
16
+ get '/v' do
17
+ content_type :text
18
+ VERSION
19
+ end
20
+
21
+ get '/' do
22
+ erb :app
23
+ end
24
+
25
+ get '/favicon.ico' do
26
+ send_file File.join(settings.root, 'favicon.ico'), \
27
+ disposition: 'inline'
28
+ end
29
+
30
+ get %r|/app/(.*)| do |fn|
31
+ send_file File.join(settings.root, 'app', fn), \
32
+ disposition: 'inline'
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ ;(function(){
2
+ jQuery(document).ready(function($){
3
+ // TODO
4
+ });
5
+ })();
File without changes
Binary file
@@ -0,0 +1 @@
1
+ Heyo!
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Bender</title>
5
+ <meta charset="utf-8" />
6
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
7
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
8
+ <meta name="description" content="Weave." />
9
+ <meta name="author" content="Sean Clemmer" />
10
+ <link rel="icon" href="/favicon.ico" />
11
+ <link href="//maxcdn.bootstrapcdn.com/bootswatch/3.3.4/superhero/bootstrap.min.css" rel="stylesheet" />
12
+ <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet" />
13
+ <link href="/app/style/bender.css" rel="stylesheet" />
14
+ </head>
15
+ <body>
16
+ <%= yield %>
17
+ <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
18
+ <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
19
+ <script src="/app/bender.js"></script>
20
+ </body>
21
+ </html>
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bender-bot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sean Clemmer
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: slog
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sinatra
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: sclemmer-robut
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.5.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.5.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: eventmachine
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.4
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.4
83
+ - !ruby/object:Gem::Dependency
84
+ name: thin
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 1.6.3
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 1.6.3
97
+ description: Yet another HipChat bot.
98
+ email: sclemmer@bluejeans.com
99
+ executables:
100
+ - bender
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - LICENSE
105
+ - Readme.md
106
+ - VERSION
107
+ - bin/bender
108
+ - lib/bender.rb
109
+ - lib/bender/bot.rb
110
+ - lib/bender/main.rb
111
+ - lib/bender/metadata.rb
112
+ - lib/bender/mjolnir.rb
113
+ - lib/bender/web.rb
114
+ - web/app/bender.js
115
+ - web/app/style/bender.css
116
+ - web/public/favicon.ico
117
+ - web/views/app.erb
118
+ - web/views/layout.erb
119
+ homepage: https://github.com/sczizzo/bender
120
+ licenses:
121
+ - ISC
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.4.5
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Yet another HipChat bot
143
+ test_files: []