Compare commits
7 commits
main
...
free-link-
Author | SHA1 | Date | |
---|---|---|---|
a8532979e5 | |||
6142c10f01 | |||
1a093362de | |||
ed19b99d99 | |||
dbfcc836af | |||
fd437af411 | |||
927407d572 |
125
.gitignore
vendored
125
.gitignore
vendored
|
@ -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
|
||||
|
|
|
@ -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
26
lib/auth.rb.example
Normal 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 = "👀"
|
||||
|
|
@ -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|
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue