FIX: dos2unixed everything

This commit is contained in:
Nikurasu 2021-11-20 15:26:25 +01:00
parent 6142c10f01
commit a8532979e5
2 changed files with 110 additions and 110 deletions

View file

@ -1,26 +1,26 @@
#!/usr/bin/ruby
TOKEN = "YOUR_TOKEN_HERE"
# Channel to bootstrap db form (and to display in status)
CHANNEL = 536907792859267083
# All channels to watch
CHANNELS = [ 536907792859267083, 560880728796168221 ]
# Specify the alternatives to use
ALTPLATFORMS = {
"https://twitter.com"=> "https://nitter.net",
"https://www.youtube.com" => "https://yewtu.be",
"https://youtube.com" => "https://yewtu.be",
"https://imgur.com" => "https://imgin.voidnet.tech",
"https://www.reddit.com" => "https://teddit.net",
"https://reddit.com" => "https://teddit.net",
}
# Set the Prefix
PREFIX = "r9k!"
# Set the emoji for clean links
EMOJI = "👀"
#!/usr/bin/ruby
TOKEN = "YOUR_TOKEN_HERE"
# Channel to bootstrap db form (and to display in status)
CHANNEL = 536907792859267083
# All channels to watch
CHANNELS = [ 536907792859267083, 560880728796168221 ]
# Specify the alternatives to use
ALTPLATFORMS = {
"https://twitter.com"=> "https://nitter.net",
"https://www.youtube.com" => "https://yewtu.be",
"https://youtube.com" => "https://yewtu.be",
"https://imgur.com" => "https://imgin.voidnet.tech",
"https://www.reddit.com" => "https://teddit.net",
"https://reddit.com" => "https://teddit.net",
}
# Set the Prefix
PREFIX = "r9k!"
# Set the emoji for clean links
EMOJI = "👀"

View file

@ -1,84 +1,84 @@
#!/usr/bin/ruby
require 'discordrb'
require 'set'
require './auth'
bot = Discordrb::Commands::CommandBot.new token: TOKEN, prefix: PREFIX
$messages = Set.new
bot.ready do |event|
chan = bot.channel CHANNEL
bot.online
bot.watching = "Messages in #" + chan.name
end
bot.reaction_add do |event|
if event.emoji.name == EMOJI
cleanlinks = []
ALTPLATFORMS.each do |platform, alternative|
linkstemp = event.message.content.scan(/(?<=#{platform})\S+/)
linkstemp.each do |link|
cleanlinks << alternative + link
end
end
if cleanlinks != []
message = "Your cleaned links:\n"
cleanlinks.each do |link|
message += "\n" + link
end
bot.send_temporary_message(event.channel, message, 60)
end
end
end
bot.message do |event|
if CHANNELS.include? event.channel.id then
if $messages.include? event.content then
msg = event.message
if msg.attachments.length.zero? then
msg.delete "r9k"
end
else
$messages << event.content
end
end
end
bot.command :cleanlink do |event, link|
ALTPLATFORMS.each do |platform, alternative|
if link.start_with? platform.to_s then
return link.gsub(Regexp.new(Regexp.escape(platform)), alternative)
end
end
end
def init_messages
msg_count = 0
File.foreach("messages.db") do |entry|
$messages << entry.chop.gsub("\v", "\n")
msg_count += 1
end
puts "Read #{msg_count.to_s} messages from database"
end
def save_messages
File.open("messages.db", "w") do |file|
$messages.each do |msg|
file.write msg.gsub("\n", "\v") + "\n"
end
end
end
Signal.trap("INT") do
save_messages
exit
end
Signal.trap("TERM") do
save_messages
exit
end
init_messages
bot.run
#!/usr/bin/ruby
require 'discordrb'
require 'set'
require './auth'
bot = Discordrb::Commands::CommandBot.new token: TOKEN, prefix: PREFIX
$messages = Set.new
bot.ready do |event|
chan = bot.channel CHANNEL
bot.online
bot.watching = "Messages in #" + chan.name
end
bot.reaction_add do |event|
if event.emoji.name == EMOJI
cleanlinks = []
ALTPLATFORMS.each do |platform, alternative|
linkstemp = event.message.content.scan(/(?<=#{platform})\S+/)
linkstemp.each do |link|
cleanlinks << alternative + link
end
end
if cleanlinks != []
message = "Your cleaned links:\n"
cleanlinks.each do |link|
message += "\n" + link
end
bot.send_temporary_message(event.channel, message, 60)
end
end
end
bot.message do |event|
if CHANNELS.include? event.channel.id then
if $messages.include? event.content then
msg = event.message
if msg.attachments.length.zero? then
msg.delete "r9k"
end
else
$messages << event.content
end
end
end
bot.command :cleanlink do |event, link|
ALTPLATFORMS.each do |platform, alternative|
if link.start_with? platform.to_s then
return link.gsub(Regexp.new(Regexp.escape(platform)), alternative)
end
end
end
def init_messages
msg_count = 0
File.foreach("messages.db") do |entry|
$messages << entry.chop.gsub("\v", "\n")
msg_count += 1
end
puts "Read #{msg_count.to_s} messages from database"
end
def save_messages
File.open("messages.db", "w") do |file|
$messages.each do |msg|
file.write msg.gsub("\n", "\v") + "\n"
end
end
end
Signal.trap("INT") do
save_messages
exit
end
Signal.trap("TERM") do
save_messages
exit
end
init_messages
bot.run