discord webhook
This commit is contained in:
parent
0142f6859f
commit
e180adf0f1
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
config.yml
|
2
config.yml.example
Normal file
2
config.yml.example
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
discord_webhook: ""
|
||||||
|
discord_token: ""
|
15
questbook.rb
15
questbook.rb
|
@ -6,6 +6,7 @@ require 'json'
|
||||||
require 'formdata'
|
require 'formdata'
|
||||||
require 'nokogiri'
|
require 'nokogiri'
|
||||||
require 'digest'
|
require 'digest'
|
||||||
|
require 'yaml'
|
||||||
require_relative 'plugins/link_info'
|
require_relative 'plugins/link_info'
|
||||||
require_relative 'plugins/help'
|
require_relative 'plugins/help'
|
||||||
|
|
||||||
|
@ -25,6 +26,12 @@ class QuestBook
|
||||||
include Cinch::Plugin
|
include Cinch::Plugin
|
||||||
|
|
||||||
listen_to :questbook
|
listen_to :questbook
|
||||||
|
|
||||||
|
def initialize(m)
|
||||||
|
@config = YAML.load_file('config.yml')
|
||||||
|
super(m)
|
||||||
|
end
|
||||||
|
|
||||||
def listen(m)
|
def listen(m)
|
||||||
params = FormData.new
|
params = FormData.new
|
||||||
params.append('msg', '')
|
params.append('msg', '')
|
||||||
|
@ -53,6 +60,14 @@ class QuestBook
|
||||||
if msg[2] != @last and print then
|
if msg[2] != @last and print then
|
||||||
Channel('#questbook').send("#{who}: #{msg}")
|
Channel('#questbook').send("#{who}: #{msg}")
|
||||||
@last = msg[2]
|
@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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue