FEATURE: Added command to get privacy friendly links
This commit is contained in:
parent
dbfcc836af
commit
ed19b99d99
3 changed files with 26 additions and 23 deletions
|
@ -6,3 +6,17 @@ TOKEN = "YOUR_TOKEN_HERE"
|
||||||
CHANNEL = 536907792859267083
|
CHANNEL = 536907792859267083
|
||||||
# All channels to watch
|
# All channels to watch
|
||||||
CHANNELS = [ 536907792859267083, 560880728796168221 ]
|
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"
|
||||||
|
|
|
@ -4,19 +4,9 @@ require 'discordrb'
|
||||||
require 'set'
|
require 'set'
|
||||||
require './auth'
|
require './auth'
|
||||||
|
|
||||||
bot = Discordrb::Bot.new token: TOKEN
|
bot = Discordrb::Commands::CommandBot.new token: TOKEN, prefix: PREFIX
|
||||||
|
|
||||||
$messages = Set.new
|
$messages = Set.new
|
||||||
$messagesWithSocialLink = Set.new
|
|
||||||
|
|
||||||
def freeLinkCreator(event)
|
|
||||||
msg = event.message.content
|
|
||||||
$messagesWithSocialLink.each do |platform|
|
|
||||||
if msg.include? platform then
|
|
||||||
$messagesWithSocialLink << event.message.id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
bot.ready do |event|
|
bot.ready do |event|
|
||||||
chan = bot.channel CHANNEL
|
chan = bot.channel CHANNEL
|
||||||
|
@ -24,8 +14,10 @@ bot.ready do |event|
|
||||||
bot.watching = "Messages in #" + chan.name
|
bot.watching = "Messages in #" + chan.name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def convertLink(link)
|
||||||
|
end
|
||||||
|
|
||||||
bot.message do |event|
|
bot.message do |event|
|
||||||
freeLinkCreator(event)
|
|
||||||
if CHANNELS.include? event.channel.id then
|
if CHANNELS.include? event.channel.id then
|
||||||
if $messages.include? event.content then
|
if $messages.include? event.content then
|
||||||
msg = event.message
|
msg = event.message
|
||||||
|
@ -38,14 +30,11 @@ bot.message do |event|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
bot.reaction_add do |event|
|
bot.command :cleanlink do |event, link|
|
||||||
if $messagesWithSocialLink.include? event.message.id then
|
ALTPLATFORMS.each do |platform, alternative|
|
||||||
#begin
|
if link.start_with? platform.to_s then
|
||||||
# TODO:
|
return link.gsub(Regexp.new(Regexp.escape(platform)), alternative)
|
||||||
# [ ] Get Link in message
|
end
|
||||||
# [ ] Refactor freeLink freeLinkCreator
|
|
||||||
# [ ] Make $messagesWithSocialLink unnessecairy
|
|
||||||
#end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
this is a test message
|
this is a test message
|
||||||
this is another test message
|
this is another test message
|
||||||
this is a third test message
|
this is a third test messag
|
||||||
test
|
lol
|
||||||
https://twitter.com
|
yay
|
||||||
|
|
Loading…
Reference in a new issue