Sha256: 05c8d05d90230bbaeec68afe82bf4e31916576cbea236aed14a04d77b151654f

Contents?: true

Size: 863 Bytes

Versions: 21

Compression:

Stored size: 863 Bytes

Contents

require 'uri'
require 'net/http'
require 'ostruct'
require 'discourse_api'
require 'action_view'

module Plugins
  class Libsecure
    include Cinch::Plugin
    include Cinch::Helpers
    include ActionView::Helpers::DateHelper

    enable_acl(:nobody)

    self.plugin_name = 'DarkScience #libsecure'
    self.help = '?latest'

    match 'latest', method: :fetch_latest

    def fetch_latest(m)
      return unless m.channel == '#libsecure' || m.channel == '#bots'

      client = DiscourseApi::Client.new('https://libsecure.so', Config.secrets[:libsecure], Config.secrets[:libsecure_user] )
      parser = client.latest_topics.sort_by { |hash| hash['last_posted_at'] }
      data = parser.last

      m.reply "Latest → #{data['title']} -- https://libsecure.so/t/#{data['id']}"
    end

  end
end

# AutoLoad
Bot.config.plugins.plugins.push Plugins::Libsecure

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
zetabot-0.0.22 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.21 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.19 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.18 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.17 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.16 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.15 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.14 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.13 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.12 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.11 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.10 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.9 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.8 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.7 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.6 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.5 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.4 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.3 lib/Zeta/plugins/libsecure.rb
zetabot-0.0.2 lib/Zeta/plugins/libsecure.rb