cinch-strawpoll 0.0.9

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7dcf12ae48ab7672ee9e49cb92a18780b73a8054
4
+ data.tar.gz: c19b56cb8e4e37be079e1597fe381f496ed431a6
5
+ SHA512:
6
+ metadata.gz: 62ab5e1b3c570207ad6414e60f2a4e9430f88d030e715b6977c7d38a203a231b34547ae22548c444f565493af90384e183c8bd147d19a13d9eadef5a04e11e8e
7
+ data.tar.gz: 253a3720057ab89cdb4926f0ba50a6279f432512f025424288c2fa7b74d70dc69f9ff08c6f55ae80b4b3ab3dee2dc5ee560e251d16429f0ce0edfac32f839e9c
data/.gitignore ADDED
@@ -0,0 +1,35 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /vendor/bundle
26
+ /lib/bundler/man/
27
+
28
+ # for a library or gem, you might want to ignore these files since the code is
29
+ # intended to run in multiple environments; otherwise, check them in:
30
+ Gemfile.lock
31
+ .ruby-version
32
+ .ruby-gemset
33
+
34
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
35
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Gem's dependencies are in gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Alex Hanna
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ <>
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # cinch-strawpoll
2
+ Strawpoll plugin for Cinch. http://strawpoll.me
3
+
4
+ ## Installation
5
+ In your `Gemfile`
6
+ ```ruby
7
+ gem 'cinch-strawpoll'
8
+ ```
9
+ Don't forget to `bundle`
10
+ ```bash
11
+ $ bundle
12
+ ```
13
+ Add to your bot config
14
+ ```ruby
15
+ require 'cinch'
16
+ require 'cinch/plugins/strawpoll'
17
+ ...
18
+ bot = Cinch::Bot.new do
19
+ configure do |c|
20
+ ...
21
+ c.plugins.plugins = [
22
+ ...
23
+ Cinch::Plugins::Strawpoll
24
+ ]
25
+ c.plugins.options = {
26
+ ...
27
+ Cinch::Plugins::Strawpoll => {
28
+ repeat_time: 60 # Seconds to wait between poll notifications
29
+ repeat_count: 3 # Total number of poll notifications
30
+ }
31
+ }
32
+ end
33
+ end
34
+ ```
35
+
36
+ ## Usage
37
+ ```
38
+ !poll <title> | <option>, <option>
39
+ ```
40
+ Requests a straw poll using `<title>` and a minimum of 2 `<option>` separated by commas.
41
+
42
+ ## Support
43
+ Like my code? Want to support my coffee habit? http://tinnvec.com/support
data/bin/htmldiff ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'htmldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'htmldiff')
data/bin/ldiff ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'ldiff' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('diff-lcs', 'ldiff')
data/bin/rake ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rake' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rake', 'rake')
data/bin/rspec ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require 'pathname'
10
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require 'rubygems'
14
+ require 'bundler/setup'
15
+
16
+ load Gem.bin_path('rspec-core', 'rspec')
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cinch/plugins/strawpoll/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cinch-strawpoll'
8
+ spec.version = Cinch::Plugins::Strawpoll::VERSION
9
+ spec.authors = ['Alex Hanna']
10
+ spec.email = ['tinnvec@gmail.com']
11
+ spec.description = 'A Strawpoll plugin for Cinch.'
12
+ spec.summary = 'A Cinch plugin for creating polls on http://strawpoll.me'
13
+ spec.homepage = 'https://github.com/tinnvec/cinch-strawpoll'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split("\n")
17
+ spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ # Gem dependencies
22
+ spec.add_dependency 'cinch', '~> 2.3.1', '>= 2.3.1'
23
+ spec.add_dependency 'cinch-authentication', '~> 0.1.1'
24
+ spec.add_dependency 'json', '~> 1.8.3', '>= 1.8.3'
25
+
26
+ # Development dependencies
27
+ spec.add_development_dependency 'bundler', '~> 1.3'
28
+ spec.add_development_dependency 'rake', '~> 0'
29
+ spec.add_development_dependency 'rspec', '~> 0'
30
+ end
@@ -0,0 +1,57 @@
1
+ require 'cinch'
2
+ require 'cinch/extensions/authentication'
3
+ require 'json'
4
+ require 'net/http'
5
+ require 'uri'
6
+
7
+ module Cinch
8
+ module Plugins
9
+
10
+ class Strawpoll
11
+ include Cinch::Plugin
12
+ include Cinch::Extensions::Authentication
13
+
14
+ enable_authentication
15
+ set :plugin_name, 'strawpoll'
16
+ set :help, <<-HELP.gsub(/^ {6}/, '')
17
+ !poll <title> | <option>, <option>
18
+ Requests a straw poll using <title> and a minimum of 2 <option> separated by commas.
19
+ HELP
20
+
21
+ def initialize(*args)
22
+ super
23
+ @repeat_time = config[:repeat_time] || 60
24
+ @repeat_count = config[:repeat_count] || 3
25
+ @allow_pol = config[:allow_pol] || false
26
+ end
27
+
28
+ match /(poll?)\s(.+)\|(.+)/
29
+ def execute(m, mode, title, options_string)
30
+ return if mode == "pol" && !@allow_pol
31
+ options = options_string.split(",").collect { |o| o = o.strip }
32
+ options << "pol pot" if mode == "pol" && @allow_pol
33
+ response = request_poll(title.strip, options)
34
+ unless response['id'].nil?
35
+ 3.times do
36
+ Channel(@bot.channels.first).send "#{Format(:white, :blue, " VOTE ")} #{title.strip} https://strawpoll.me/#{response['id']}"
37
+ sleep 60
38
+ end
39
+ else
40
+ m.user.notice "Error: #{response['error']}"
41
+ end
42
+ end
43
+
44
+ private
45
+
46
+ def request_poll(title, options)
47
+ uri = URI('https://strawpoll.me/api/v2/polls/')
48
+ req = Net::HTTP::Post.new(uri.path, { 'Content-Type' => 'application/json' })
49
+ req.body = { title: title, options: options, multi: false }.to_json
50
+ @bot.debug "Request body: #{req.body}"
51
+ res = Net::HTTP.start(uri.host, uri.port, :use_ssl => true) { |http| http.request req }
52
+ JSON.parse(res.body)
53
+ end
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,7 @@
1
+ module Cinch
2
+ module Plugins
3
+ module Strawpoll
4
+ VERSION = '0.0.9'
5
+ end
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cinch-strawpoll
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
5
+ platform: ruby
6
+ authors:
7
+ - Alex Hanna
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-04 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.3.1
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.3.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 2.3.1
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.3.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: cinch-authentication
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.1.1
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.1.1
47
+ - !ruby/object:Gem::Dependency
48
+ name: json
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: 1.8.3
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.8.3
57
+ type: :runtime
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: 1.8.3
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.8.3
67
+ - !ruby/object:Gem::Dependency
68
+ name: bundler
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '1.3'
74
+ type: :development
75
+ prerelease: false
76
+ version_requirements: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '1.3'
81
+ - !ruby/object:Gem::Dependency
82
+ name: rake
83
+ requirement: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - "~>"
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - "~>"
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ description: A Strawpoll plugin for Cinch.
110
+ email:
111
+ - tinnvec@gmail.com
112
+ executables:
113
+ - htmldiff
114
+ - ldiff
115
+ - rake
116
+ - rspec
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - ".gitignore"
121
+ - Gemfile
122
+ - LICENSE
123
+ - README.md
124
+ - bin/htmldiff
125
+ - bin/ldiff
126
+ - bin/rake
127
+ - bin/rspec
128
+ - cinch-strawpoll.gemspec
129
+ - lib/cinch/plugins/strawpoll.rb
130
+ - lib/cinch/plugins/strawpoll/version.rb
131
+ homepage: https://github.com/tinnvec/cinch-strawpoll
132
+ licenses:
133
+ - MIT
134
+ metadata: {}
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.4.6
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: A Cinch plugin for creating polls on http://strawpoll.me
155
+ test_files: []