discord_archiver 0.1.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/.gitattributes +2 -0
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/LICENSE +20 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/bin/discord_archiver +13 -0
- data/discord_archiver.gemspec +21 -0
- data/lib/discord_archiver.rb +66 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1e76822312d779bf46ac1a8235189b8bf4fe6b8154a80d18bf3d1679cb09507d
|
4
|
+
data.tar.gz: 3679540d7aea546675549825bb935b6eaf3151bad4df7ac4a96482095ce99be1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: acff1469f863e53d57b148c07c3b5cefd96dcf5108e0d3f8208f05082937c56935db5d7ceafda979a1c11b49c3d445c3f57743d714c0ba9be2838c17e915f4b6
|
7
|
+
data.tar.gz: ee1d53a854883e65867d25802a031c21c7a4580b84f5e33ec05325a7e2fa77150f3c7f6bd206e316b6f0702754b650bf6f569e961dc53d3f44c27c89c00101e5
|
data/.gitattributes
ADDED
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2018 TheAssailant <theassailant@protonmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
File without changes
|
data/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'discord_archiver'
|
5
|
+
|
6
|
+
ARCHIVE_TOKEN = ENV["DISCORD_ARCHIVE_TOKEN"]
|
7
|
+
SERVER_ID = ENV["DISCORD_ARCHIVE_SERVER_ID"]
|
8
|
+
CHANNEL_NAME = ENV["DISCORD_ARCHIVE_CHANNEL_NAME"]
|
9
|
+
CHANNEL_GROUP = ENV["DISCORD_ARCHIVE_CHANNEL_GROUP"]
|
10
|
+
OG_CHANNEL_GROUP = ENV["DISCORD_ARCHIVE_ORIGINAL_CHANNEL_GROUP"]
|
11
|
+
|
12
|
+
archiver = DiscordArchiver.setup(ARCHIVE_TOKEN, SERVER_ID, CHANNEL_NAME, CHANNEL_GROUP, OG_CHANNEL_GROUP)
|
13
|
+
archiver.start
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "discord_archiver"
|
3
|
+
s.version = "0.1.1"
|
4
|
+
s.authors = "TheAssailant"
|
5
|
+
s.email = "theassailant@protonmail.com"
|
6
|
+
s.summary = %q{Archives a specified channel in a Discord server.}
|
7
|
+
s.homepage = "https://github.com/TheAssailant/discord_archiver"
|
8
|
+
s.license = "MIT"
|
9
|
+
|
10
|
+
s.executables << "discord_archiver"
|
11
|
+
s.require_paths = ['lib']
|
12
|
+
|
13
|
+
s.required_ruby_version = "~> 2.3"
|
14
|
+
|
15
|
+
s.add_dependency "discordrb", "~> 3.3.0"
|
16
|
+
|
17
|
+
s.add_development_dependency "bundler", "~> 1.15"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- test/*`.split("\n")
|
21
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'discordrb'
|
2
|
+
|
3
|
+
class DiscordArchiver
|
4
|
+
@archive_token
|
5
|
+
@server_id
|
6
|
+
@channel_name
|
7
|
+
@channel_group
|
8
|
+
@og_channel_group
|
9
|
+
|
10
|
+
def self.setup(archive_token, server_id, channel_name, channel_group, og_channel_group)
|
11
|
+
@archive_token = archive_token
|
12
|
+
@server_id = server_id
|
13
|
+
@channel_name = channel_name
|
14
|
+
@channel_group = channel_group
|
15
|
+
@og_channel_group = og_channel_group
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.start
|
20
|
+
puts "-" * 80
|
21
|
+
if @archive_token && @server_id && @channel_name && @channel_group && @og_channel_group
|
22
|
+
bot = Discordrb::Bot.new token: @archive_token
|
23
|
+
bot.run(true)
|
24
|
+
puts "Logged in as #{bot.profile.username}."
|
25
|
+
check_servers bot.servers
|
26
|
+
|
27
|
+
target_server = bot.servers[@server_id.to_i]
|
28
|
+
|
29
|
+
channels = target_server.channels
|
30
|
+
channel = channels.find { |c| c.name == @channel_name }
|
31
|
+
parent_channel = channels.find { |c| c.name == @channel_group }
|
32
|
+
|
33
|
+
archive_channel channel, parent_channel
|
34
|
+
create_new_channel(target_server)
|
35
|
+
bot.stop
|
36
|
+
else
|
37
|
+
puts "You don't have the proper environment variables set for Discord."
|
38
|
+
puts "Add the environment variables and try again."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.check_servers(servers)
|
43
|
+
if servers.count == 0
|
44
|
+
abort "Bot is not a member of any servers. Please add bot to a server and try again."
|
45
|
+
elsif servers.include? @server_id
|
46
|
+
abort "Bot is not a member of the specified server. Please add bot to server and try again."
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.archive_channel(channel, parent_category)
|
51
|
+
puts "Now moving #{@channel_name} to #{@channel_group}."
|
52
|
+
channel.name = "#{channel.name}-#{Time.now.strftime("%Y-%m-%d")}"
|
53
|
+
channel.category = parent_category.id
|
54
|
+
if channel.sync
|
55
|
+
puts "#{@channel_name} is now archived"
|
56
|
+
else
|
57
|
+
puts "There may have been an issue archiving and syncing permissions for #{@channel_name}"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def self.create_new_channel(server)
|
62
|
+
puts "Creating new channel: #{@channel_name}"
|
63
|
+
parent = server.channels.find { |channel| channel.name == @og_channel_group }
|
64
|
+
server.create_channel(@channel_name, parent: parent)
|
65
|
+
end
|
66
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: discord_archiver
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TheAssailant
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: discordrb
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.3.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.3.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.15'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.15'
|
41
|
+
description:
|
42
|
+
email: theassailant@protonmail.com
|
43
|
+
executables:
|
44
|
+
- discord_archiver
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitattributes"
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/discord_archiver
|
55
|
+
- discord_archiver.gemspec
|
56
|
+
- lib/discord_archiver.rb
|
57
|
+
homepage: https://github.com/TheAssailant/discord_archiver
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.3'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.7.8
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Archives a specified channel in a Discord server.
|
81
|
+
test_files: []
|