Compare commits

...

7 commits

Author SHA1 Message Date
Nikurasu a8532979e5 FIX: dos2unixed everything 2021-11-20 15:26:25 +01:00
Nikurasu 6142c10f01 FEATURE: clean links of message at specific reaction 2021-11-20 14:34:06 +01:00
Nikurasu 1a093362de FEATURE: clean links of message at specific reaction 2021-11-20 14:32:57 +01:00
Nikurasu ed19b99d99 FEATURE: Added command to get privacy friendly links 2021-10-31 17:40:48 +01:00
nikurasu dbfcc836af FEATURE: Added Detection of Social Media Links 2021-10-30 09:53:45 +02:00
nikurasu fd437af411 FIX: Ignoring auth.rb 2021-10-28 08:18:30 +02:00
nikurasu 927407d572 FEATURE: made auth.rb template 2021-10-28 08:14:20 +02:00
5 changed files with 118 additions and 73 deletions

125
.gitignore vendored
View file

@ -1,63 +1,62 @@
# ---> Ruby
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/
# Used by dotenv library to load environment variables.
# .env
# Ignore Byebug command history file.
.byebug_history
## Specific to RubyMotion:
.dat*
.repl_history
build/
*.bridgesupport
build-iPhoneOS/
build-iPhoneSimulator/
## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/
## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/
## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/
# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*
# no token leaks
/lib/auth.rb
# emacs
*~
# ---> Ruby
*.gem
*.rbc
/.config
/coverage/
/InstalledFiles
/pkg/
/spec/reports/
/spec/examples.txt
/test/tmp/
/test/version_tmp/
/tmp/
# Used by dotenv library to load environment variables.
# .env
# Ignore Byebug command history file.
.byebug_history
## Specific to RubyMotion:
.dat*
.repl_history
build/
*.bridgesupport
build-iPhoneOS/
build-iPhoneSimulator/
## Specific to RubyMotion (use of CocoaPods):
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
# vendor/Pods/
## Documentation cache and generated files:
/.yardoc/
/_yardoc/
/doc/
/rdoc/
## Environment normalization:
/.bundle/
/vendor/bundle
/lib/bundler/man/
# for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# Gemfile.lock
# .ruby-version
# .ruby-gemset
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
.rvmrc
# Used by RuboCop. Remote config files pulled in from inherit_from directive.
# .rubocop-https?--*
# no token leaks
lib/auth.rb
# emacs

View file

@ -1,8 +0,0 @@
#!/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 ]

26
lib/auth.rb.example Normal file
View file

@ -0,0 +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 = "👀"

View file

@ -4,7 +4,7 @@ require 'discordrb'
require 'set'
require './auth'
bot = Discordrb::Bot.new token: TOKEN
bot = Discordrb::Commands::CommandBot.new token: TOKEN, prefix: PREFIX
$messages = Set.new
@ -14,6 +14,25 @@ bot.ready do |event|
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
@ -27,6 +46,14 @@ bot.message do |event|
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|

View file

@ -1,3 +1,4 @@
this is a test message
this is another test message
this is a third test message
this is a third test messag
Hey https://www.youtube.com/watch?v=RhsWlk0yDW4