cinch-strawpoll 0.0.9 → 0.1.6
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 +4 -4
- data/.gitattributes +17 -0
- data/README.md +22 -11
- data/bin/htmldiff +6 -5
- data/bin/ldiff +6 -5
- data/bin/rake +6 -5
- data/bin/rspec +6 -5
- data/cinch-strawpoll.gemspec +32 -30
- data/lib/cinch/plugins/strawpoll.rb +59 -57
- data/lib/cinch/plugins/strawpoll/api.rb +35 -0
- data/lib/cinch/plugins/strawpoll/version.rb +10 -7
- metadata +19 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b720770da56c8fb949a017cc17458585dae6818d
|
4
|
+
data.tar.gz: b9fe95e703b1136f9f5956f90f9aed7134f75f39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3504195cd83234c735f2fe0bbcc6b5ab37f983a286ee6a76218ccae2c8bd6e01a85b8375b1e44614c01401a9aca0f724d47a6e5105cf914dd40b93ef90ec8c8
|
7
|
+
data.tar.gz: 72dcb15ce4c37a07a5302d918fa357bd174f57a1143b19629bfb8d834c68afb5d40710002db69ccb50761cf88fd73938ef01012bf400be93f7f8f054233c274d
|
data/.gitattributes
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Auto detect text files and perform LF normalization
|
2
|
+
* text=auto
|
3
|
+
|
4
|
+
# Custom for Visual Studio
|
5
|
+
*.cs diff=csharp
|
6
|
+
|
7
|
+
# Standard to msysgit
|
8
|
+
*.doc diff=astextplain
|
9
|
+
*.DOC diff=astextplain
|
10
|
+
*.docx diff=astextplain
|
11
|
+
*.DOCX diff=astextplain
|
12
|
+
*.dot diff=astextplain
|
13
|
+
*.DOT diff=astextplain
|
14
|
+
*.pdf diff=astextplain
|
15
|
+
*.PDF diff=astextplain
|
16
|
+
*.rtf diff=astextplain
|
17
|
+
*.RTF diff=astextplain
|
data/README.md
CHANGED
@@ -1,17 +1,23 @@
|
|
1
|
+
[![Chatrealm IRC][irc-chatrealm-badge]][irc-chatrealm-link]
|
2
|
+
[![Support tinnvec][support-tinnvec-badge]][support-tinnvec-link]
|
3
|
+
|
1
4
|
# cinch-strawpoll
|
2
5
|
Strawpoll plugin for Cinch. http://strawpoll.me
|
3
6
|
|
4
7
|
## Installation
|
8
|
+
|
5
9
|
In your `Gemfile`
|
6
|
-
```
|
10
|
+
```Ruby
|
7
11
|
gem 'cinch-strawpoll'
|
8
12
|
```
|
9
|
-
|
10
|
-
|
11
|
-
|
13
|
+
|
14
|
+
Don't forget to `bundle install`
|
15
|
+
```Shell
|
16
|
+
bundle install
|
12
17
|
```
|
18
|
+
|
13
19
|
Add to your bot config
|
14
|
-
```
|
20
|
+
```Ruby
|
15
21
|
require 'cinch'
|
16
22
|
require 'cinch/plugins/strawpoll'
|
17
23
|
...
|
@@ -25,8 +31,8 @@ bot = Cinch::Bot.new do
|
|
25
31
|
c.plugins.options = {
|
26
32
|
...
|
27
33
|
Cinch::Plugins::Strawpoll => {
|
28
|
-
repeat_time:
|
29
|
-
repeat_count:
|
34
|
+
repeat_time: 60, # Seconds to wait between poll notifications
|
35
|
+
repeat_count: 3 # Total number of poll notifications
|
30
36
|
}
|
31
37
|
}
|
32
38
|
end
|
@@ -34,10 +40,15 @@ end
|
|
34
40
|
```
|
35
41
|
|
36
42
|
## Usage
|
37
|
-
```
|
43
|
+
```IRC
|
38
44
|
!poll <title> | <option>, <option>
|
39
45
|
```
|
40
|
-
|
46
|
+
Request a strawpoll using `<title>` and a minimum of 2 `<option>` separated by commas.
|
47
|
+
|
48
|
+
Announcements will be made `repeat_count` times, one every `repeat_time` seconds.
|
49
|
+
|
50
|
+
[irc-chatrealm-link]: http://irc.chatrealm.net
|
51
|
+
[irc-chatrealm-badge]: https://img.shields.io/badge/irc-chatrealm-orange.svg?style=flat-square
|
41
52
|
|
42
|
-
|
43
|
-
|
53
|
+
[support-tinnvec-link]: http://tinnvec.com/support
|
54
|
+
[support-tinnvec-badge]: https://img.shields.io/badge/Support-tinnvec-blue.svg?style=flat-square
|
data/bin/htmldiff
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
#
|
3
4
|
# This file was generated by Bundler.
|
4
5
|
#
|
@@ -6,11 +7,11 @@
|
|
6
7
|
# this file is here to facilitate running it.
|
7
8
|
#
|
8
9
|
|
9
|
-
require
|
10
|
-
ENV[
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
11
12
|
Pathname.new(__FILE__).realpath)
|
12
13
|
|
13
|
-
require
|
14
|
-
require
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
15
16
|
|
16
|
-
load Gem.bin_path(
|
17
|
+
load Gem.bin_path("cinch-strawpoll", "htmldiff")
|
data/bin/ldiff
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
#
|
3
4
|
# This file was generated by Bundler.
|
4
5
|
#
|
@@ -6,11 +7,11 @@
|
|
6
7
|
# this file is here to facilitate running it.
|
7
8
|
#
|
8
9
|
|
9
|
-
require
|
10
|
-
ENV[
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
11
12
|
Pathname.new(__FILE__).realpath)
|
12
13
|
|
13
|
-
require
|
14
|
-
require
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
15
16
|
|
16
|
-
load Gem.bin_path(
|
17
|
+
load Gem.bin_path("cinch-strawpoll", "ldiff")
|
data/bin/rake
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
#
|
3
4
|
# This file was generated by Bundler.
|
4
5
|
#
|
@@ -6,11 +7,11 @@
|
|
6
7
|
# this file is here to facilitate running it.
|
7
8
|
#
|
8
9
|
|
9
|
-
require
|
10
|
-
ENV[
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
11
12
|
Pathname.new(__FILE__).realpath)
|
12
13
|
|
13
|
-
require
|
14
|
-
require
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
15
16
|
|
16
|
-
load Gem.bin_path(
|
17
|
+
load Gem.bin_path("cinch-strawpoll", "rake")
|
data/bin/rspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
#
|
3
4
|
# This file was generated by Bundler.
|
4
5
|
#
|
@@ -6,11 +7,11 @@
|
|
6
7
|
# this file is here to facilitate running it.
|
7
8
|
#
|
8
9
|
|
9
|
-
require
|
10
|
-
ENV[
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
11
12
|
Pathname.new(__FILE__).realpath)
|
12
13
|
|
13
|
-
require
|
14
|
-
require
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
15
16
|
|
16
|
-
load Gem.bin_path(
|
17
|
+
load Gem.bin_path("cinch-strawpoll", "rspec")
|
data/cinch-strawpoll.gemspec
CHANGED
@@ -1,30 +1,32 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
# file: cinch-strawpoll.gemspec
|
3
|
+
|
4
|
+
lib = File.expand_path('../lib', __FILE__)
|
5
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
+
require 'cinch/plugins/strawpoll/version'
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = 'cinch-strawpoll'
|
10
|
+
spec.version = Cinch::Plugins::Strawpoll::VERSION
|
11
|
+
spec.authors = ['Alex Hanna']
|
12
|
+
spec.email = ['tinnvec@gmail.com']
|
13
|
+
spec.description = 'A Strawpoll plugin for Cinch.'
|
14
|
+
spec.summary = 'A Cinch plugin for creating polls on http://strawpoll.me'
|
15
|
+
spec.homepage = 'https://github.com/tinnvec/cinch-strawpoll'
|
16
|
+
spec.license = 'MIT'
|
17
|
+
|
18
|
+
spec.files = `git ls-files`.split("\n")
|
19
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
spec.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
# Gem dependencies
|
24
|
+
spec.add_dependency 'cinch', '~> 2.3.1', '>= 2.3.1'
|
25
|
+
spec.add_dependency 'cinch-authentication', '~> 0.1.1'
|
26
|
+
spec.add_dependency 'httparty', '~> 0.13.7'
|
27
|
+
spec.add_dependency 'json', '~> 1.8.3', '>= 1.8.3'
|
28
|
+
|
29
|
+
# Development dependencies
|
30
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
31
|
+
spec.add_development_dependency 'rake', '~> 0'
|
32
|
+
end
|
@@ -1,57 +1,59 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
# file: lib/cinch/plugins/strawpoll.rb
|
3
|
+
|
4
|
+
require 'cinch'
|
5
|
+
require 'cinch/extensions/authentication'
|
6
|
+
|
7
|
+
require 'strawpoll/api'
|
8
|
+
|
9
|
+
module Cinch
|
10
|
+
module Plugins
|
11
|
+
class Strawpoll
|
12
|
+
include Cinch::Plugin
|
13
|
+
include Cinch::Extensions::Authentication
|
14
|
+
|
15
|
+
enable_authentication
|
16
|
+
|
17
|
+
set :plugin_name, 'strawpoll'
|
18
|
+
set :help, '!poll <title> | <choice>, <choice> - Request a ' +
|
19
|
+
'strawpoll using <title> and a minimum of 2 <choice> ' +
|
20
|
+
'separated by commas.'
|
21
|
+
|
22
|
+
match(/(poll?)\s(.+)\|(.+)/)
|
23
|
+
|
24
|
+
def initialize(*args)
|
25
|
+
super
|
26
|
+
@repeat_time = config[:repeat_time] || 60
|
27
|
+
@repeat_count = config[:repeat_count] || 3
|
28
|
+
@allow_pol = config[:allow_pol] || false
|
29
|
+
|
30
|
+
@strawpoll_api = Cinch::Plugins::Strawpoll::Api.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def execute(m, mode, title, choices_string)
|
34
|
+
return if mode == 'pol' && !@allow_pol
|
35
|
+
|
36
|
+
choices = choices_string.split(',').collect { |o| o = o.strip }
|
37
|
+
choices << 'pol pot' if mode == 'pol' && @allow_pol
|
38
|
+
|
39
|
+
response = @strawpoll_api.create_poll(title.strip, choices)
|
40
|
+
|
41
|
+
if !response['id'].nil? && @repeat_count > 0
|
42
|
+
Thread.new(Channel(m.channel)) do |channel|
|
43
|
+
@repeat_count.times do
|
44
|
+
announcement = Format(:white, :blue, " VOTE ")
|
45
|
+
announcement += " #{title.strip}"
|
46
|
+
announcement += " https://strawpoll.me/#{response['id']}"
|
47
|
+
channel.send(announcement)
|
48
|
+
sleep @repeat_time
|
49
|
+
end
|
50
|
+
end
|
51
|
+
else
|
52
|
+
m.user.notice "Error: #{response['error']}"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# file: lib/cinch/plugins/strawpoll/api.rb
|
3
|
+
|
4
|
+
require 'httparty'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
module Cinch
|
8
|
+
module Plugins
|
9
|
+
module Strawpoll
|
10
|
+
class Api
|
11
|
+
include HTTParty
|
12
|
+
|
13
|
+
base_uri 'https://strawpoll.me/api/v2'
|
14
|
+
|
15
|
+
def create_poll(title, choices)
|
16
|
+
response = create_poll_request(title, choices)
|
17
|
+
return response
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def create_poll_request(title, choices)
|
23
|
+
options = {
|
24
|
+
headers: { 'Content-Type' => 'application/json' },
|
25
|
+
body: {
|
26
|
+
title: title, options: choices, multi: false
|
27
|
+
}.to_json
|
28
|
+
}
|
29
|
+
response = self.class.post('/polls', options)
|
30
|
+
return JSON.parse(response)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-strawpoll
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Hanna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cinch
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: 0.1.1
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: httparty
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 0.13.7
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 0.13.7
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: json
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -92,20 +106,6 @@ dependencies:
|
|
92
106
|
- - "~>"
|
93
107
|
- !ruby/object:Gem::Version
|
94
108
|
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
109
|
description: A Strawpoll plugin for Cinch.
|
110
110
|
email:
|
111
111
|
- tinnvec@gmail.com
|
@@ -117,6 +117,7 @@ executables:
|
|
117
117
|
extensions: []
|
118
118
|
extra_rdoc_files: []
|
119
119
|
files:
|
120
|
+
- ".gitattributes"
|
120
121
|
- ".gitignore"
|
121
122
|
- Gemfile
|
122
123
|
- LICENSE
|
@@ -127,6 +128,7 @@ files:
|
|
127
128
|
- bin/rspec
|
128
129
|
- cinch-strawpoll.gemspec
|
129
130
|
- lib/cinch/plugins/strawpoll.rb
|
131
|
+
- lib/cinch/plugins/strawpoll/api.rb
|
130
132
|
- lib/cinch/plugins/strawpoll/version.rb
|
131
133
|
homepage: https://github.com/tinnvec/cinch-strawpoll
|
132
134
|
licenses:
|
@@ -148,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
150
|
version: '0'
|
149
151
|
requirements: []
|
150
152
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.
|
153
|
+
rubygems_version: 2.5.1
|
152
154
|
signing_key:
|
153
155
|
specification_version: 4
|
154
156
|
summary: A Cinch plugin for creating polls on http://strawpoll.me
|