discord_webhooks 0.0.1
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 +7 -0
- data/lib/discord_webhooks/embed.rb +27 -0
- data/lib/discord_webhooks/message.rb +24 -0
- data/lib/discord_webhooks.rb +34 -0
- metadata +88 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3777d5dd34f84db595ab27dd1f3fc13854bbaf51f3d82646a76e3fb0d6c3f1cb
|
|
4
|
+
data.tar.gz: 4aacf4fc50078492e39358f4d42b5d9a5286bba9ec885d13c0eec0b7b74e5e06
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9c800fa43684b718c6b637fc15e3271025acd0f649046d8e5e4db052684df1cea0417f80198c98ee39b749c865c804115a202eba6a1f0f7b1b8ee8d99ade2c9b
|
|
7
|
+
data.tar.gz: 2be1a237aa9f90a9e589c1cd016306b6051f37a5455bfaf9f43f7749ff75ed5293f711bcc9d1e8e69f9c2abcb83e4548c418fe0bb963a7da9ed7244fccd89121
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module DiscordWebHooks
|
|
2
|
+
class Embed
|
|
3
|
+
def initialize(title:"",description:"",color:000000,author:{},fields:[],footer:"",timestamp:"")
|
|
4
|
+
@title = title
|
|
5
|
+
@description = description
|
|
6
|
+
@color = color
|
|
7
|
+
@author = author
|
|
8
|
+
@fields = fields
|
|
9
|
+
@footer = footer
|
|
10
|
+
@timestamp = timestamp
|
|
11
|
+
|
|
12
|
+
@hash = {
|
|
13
|
+
title: @title,
|
|
14
|
+
description: @description,
|
|
15
|
+
color: @color,
|
|
16
|
+
author: @author,
|
|
17
|
+
fields: @fields,
|
|
18
|
+
footer: @footer,
|
|
19
|
+
timestamp: @timestamp
|
|
20
|
+
}
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def to_h
|
|
24
|
+
@hash
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module DiscordWebHooks
|
|
2
|
+
class Message
|
|
3
|
+
def initialize(text:,embeds:[])
|
|
4
|
+
@text = text
|
|
5
|
+
@message = {
|
|
6
|
+
content: text,
|
|
7
|
+
embeds: embeds.map{|e|e.to_h}
|
|
8
|
+
}
|
|
9
|
+
@json = @message.to_json
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def send(webhook)
|
|
13
|
+
webhook_url = URI.parse(webhook)
|
|
14
|
+
|
|
15
|
+
request = Net::HTTP::Post.new(webhook_url.path, {'Content-Type' => 'application/json'})
|
|
16
|
+
|
|
17
|
+
request.body = @json
|
|
18
|
+
|
|
19
|
+
response = Net::HTTP.start(webhook_url.host, webhook_url.port, use_ssl: true) do |http|
|
|
20
|
+
http.request(request)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module DiscordWebHooks
|
|
2
|
+
@@files = ["message.rb", "embed.rb"] # All gem files
|
|
3
|
+
@@exe = [] # All executables
|
|
4
|
+
|
|
5
|
+
def self.version
|
|
6
|
+
"0.0.1"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.executables
|
|
10
|
+
@@exe
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.file_paths(relative:false)
|
|
14
|
+
x = @@files.map do |f|
|
|
15
|
+
"#{"lib/" unless relative}discord_webhooks/#{f}"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
if relative
|
|
19
|
+
return x
|
|
20
|
+
else
|
|
21
|
+
return x + ['lib/discord_webhooks.rb']
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# Additional Requires
|
|
27
|
+
require 'json'
|
|
28
|
+
require 'net/http'
|
|
29
|
+
require 'uri'
|
|
30
|
+
|
|
31
|
+
DiscordWebHooks.file_paths(relative:true).each do |f|
|
|
32
|
+
require_relative f
|
|
33
|
+
end
|
|
34
|
+
|
metadata
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: discord_webhooks
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Matthias Lee
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2023-11-21 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: net-http
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.1.1
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.1.1
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: json
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 2.5.1
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 2.5.1
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: uri
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 0.10.1
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 0.10.1
|
|
55
|
+
description: Gem that allows for easy interface with Discord's webhooks to send messages
|
|
56
|
+
to server channels
|
|
57
|
+
email: matthias@matthiasclee.com
|
|
58
|
+
executables: []
|
|
59
|
+
extensions: []
|
|
60
|
+
extra_rdoc_files: []
|
|
61
|
+
files:
|
|
62
|
+
- lib/discord_webhooks.rb
|
|
63
|
+
- lib/discord_webhooks/embed.rb
|
|
64
|
+
- lib/discord_webhooks/message.rb
|
|
65
|
+
homepage: https://github.com/Matthiasclee/discordwebhooks
|
|
66
|
+
licenses:
|
|
67
|
+
- CC-BY-NC-SA-4.0
|
|
68
|
+
metadata: {}
|
|
69
|
+
post_install_message:
|
|
70
|
+
rdoc_options: []
|
|
71
|
+
require_paths:
|
|
72
|
+
- lib
|
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
74
|
+
requirements:
|
|
75
|
+
- - ">="
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: '0'
|
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
requirements: []
|
|
84
|
+
rubygems_version: 3.2.3
|
|
85
|
+
signing_key:
|
|
86
|
+
specification_version: 4
|
|
87
|
+
summary: Discord webhooks interface for ruby
|
|
88
|
+
test_files: []
|