discord webhook
This commit is contained in:
parent
0142f6859f
commit
e180adf0f1
|
@ -0,0 +1 @@
|
|||
config.yml
|
|
@ -0,0 +1,2 @@
|
|||
discord_webhook: ""
|
||||
discord_token: ""
|
15
questbook.rb
15
questbook.rb
|
@ -6,6 +6,7 @@ require 'json'
|
|||
require 'formdata'
|
||||
require 'nokogiri'
|
||||
require 'digest'
|
||||
require 'yaml'
|
||||
require_relative 'plugins/link_info'
|
||||
require_relative 'plugins/help'
|
||||
|
||||
|
@ -25,6 +26,12 @@ class QuestBook
|
|||
include Cinch::Plugin
|
||||
|
||||
listen_to :questbook
|
||||
|
||||
def initialize(m)
|
||||
@config = YAML.load_file('config.yml')
|
||||
super(m)
|
||||
end
|
||||
|
||||
def listen(m)
|
||||
params = FormData.new
|
||||
params.append('msg', '')
|
||||
|
@ -53,6 +60,14 @@ class QuestBook
|
|||
if msg[2] != @last and print then
|
||||
Channel('#questbook').send("#{who}: #{msg}")
|
||||
@last = msg[2]
|
||||
# discord webhook
|
||||
http = Net::HTTP.new('discordapp.com', 443)
|
||||
http.use_ssl = true
|
||||
params = FormData.new
|
||||
params.append('content', msg[2])
|
||||
params.append('username', msg[1])
|
||||
req = params.post_request("api/webhooks/#{@config.discord_webhook}/#{@config.discord_token}")
|
||||
http.request(req)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue