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
|
||||
# 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"
|
||||
|
|
|
@ -4,19 +4,9 @@ require 'discordrb'
|
|||
require 'set'
|
||||
require './auth'
|
||||
|
||||
bot = Discordrb::Bot.new token: TOKEN
|
||||
bot = Discordrb::Commands::CommandBot.new token: TOKEN, prefix: PREFIX
|
||||
|
||||
$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|
|
||||
chan = bot.channel CHANNEL
|
||||
|
@ -24,8 +14,10 @@ bot.ready do |event|
|
|||
bot.watching = "Messages in #" + chan.name
|
||||
end
|
||||
|
||||
def convertLink(link)
|
||||
end
|
||||
|
||||
bot.message do |event|
|
||||
freeLinkCreator(event)
|
||||
if CHANNELS.include? event.channel.id then
|
||||
if $messages.include? event.content then
|
||||
msg = event.message
|
||||
|
@ -38,14 +30,11 @@ bot.message do |event|
|
|||
end
|
||||
end
|
||||
|
||||
bot.reaction_add do |event|
|
||||
if $messagesWithSocialLink.include? event.message.id then
|
||||
#begin
|
||||
# TODO:
|
||||
# [ ] Get Link in message
|
||||
# [ ] Refactor freeLink freeLinkCreator
|
||||
# [ ] Make $messagesWithSocialLink unnessecairy
|
||||
#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
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
this is a test message
|
||||
this is another test message
|
||||
this is a third test message
|
||||
test
|
||||
https://twitter.com
|
||||
this is a third test messag
|
||||
lol
|
||||
yay
|
||||
|
|
Loading…
Reference in a new issue