class Cinch::Plugins::Strawpoll
Strawpoll
plugin
Constants
- VERSION
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/cinch/plugins/strawpoll.rb, line 26 def initialize(*args) super @repeat_time = config[:repeat_time] || 60 @repeat_count = config[:repeat_count] || 3 @allow_pol = config[:allow_pol] || false @strawpoll_api = StrawpollApi.new end
Public Instance Methods
execute(_m, mode, _title, choices_string)
click to toggle source
# File lib/cinch/plugins/strawpoll.rb, line 34 def execute(_m, mode, _title, choices_string) return if mode == 'pol' && !@allow_pol choices = choices_string.split(',').collect(&:strip) choices << 'pol pot' if mode == 'pol' && @allow_pol response = @strawpoll_api.create_poll(title.strip, choices) return if @repeat_count < 1 do_announcements(response['id'], title, choices) end
Private Instance Methods
do_announcements(poll_id, title)
click to toggle source
# File lib/cinch/plugins/strawpoll.rb, line 45 def do_announcements(poll_id, title) if poll_id.nil? m.user.notice "Error: #{response['error']}" return end Thread.new(Channel(channel)) do |c| @repeat_count.times do c.send(format_announcement(title, poll_id)) sleep @repeat_time end end end
format_announcement(title, poll_id)
click to toggle source
# File lib/cinch/plugins/strawpoll.rb, line 58 def format_announcement(title, poll_id) "#{Format(:white, :blue, ' VOTE ')}#{title.strip}" \ " https://strawpoll.me/#{poll_id}" end