Browse Source

Initial commit

Frans Bergman 6 years ago
commit
309c24ce04
4 changed files with 159 additions and 0 deletions
  1. 52 0
      .gitignore
  2. 3 0
      config.yaml.sample
  3. 6 0
      copypastas.json
  4. 98 0
      main.rb

+ 52 - 0
.gitignore

@@ -0,0 +1,52 @@
+*.swp
+
+*.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
+
+## 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

+ 3 - 0
config.yaml.sample

@@ -0,0 +1,3 @@
+settings:
+    token: INSERT_TOKEN_HERE
+    prefix: .

File diff suppressed because it is too large
+ 6 - 0
copypastas.json


+ 98 - 0
main.rb

@@ -0,0 +1,98 @@
+require 'yaml'
+require 'discordrb'
+require 'icunicode'
+require 'open-uri'
+require 'fileutils'
+require 'securerandom'
+require 'net/http'
+require 'json'
+
+settings = YAML.load(File.read "config.yaml")['settings']
+bot = Discordrb::Commands::CommandBot.new token: settings['token'], prefix: settings['prefix']
+
+bot.command(:translit) do |_event, script, *text|
+    _event.message.mentions.each do |user|
+        member = user.on(_event.channel.server)
+        original_name = member.nick
+        original_name ||= member.username
+        transliterated = original_name.transliterate(script).force_encoding("UTF-8")
+        member.nick = transliterated
+        _event.send_message("Congratulations on your new nickname, #{member.mention}")
+    end
+    _event.send_message("Translitterated: #{text.join(' ').transliterate(script).force_encoding("UTF-8")}")
+    "Finished translitting"
+end
+
+bot.command(:reset) do |_event|
+    _event.message.mentions.each do |user|
+        user.on(_event.channel.server).nickname = nil
+    end
+
+    "Finished resetting"
+end
+
+bot.command(:loli) do |_event|
+    "https://tankernn.eu/~frans/files/loli_police_#{rand(1..3)}.png"
+end
+
+bot.command(:reap) do |_event, stop_id|
+    next "No stop_id supplied" if stop_id == nil
+    FileUtils::mkdir_p("/tmp/tankbot_images/")
+    stop = false
+    earliest_message_id = nil
+    control_message = _event.send_message("Reaping images sent by #{_event.author.mention}. React to this message to stop.")
+    until stop
+        messages = _event.channel.history(100, earliest_message_id)
+        messages.select{ |message| message.author === _event.author }.each do |message|
+            puts "#{message.id}, #{stop_id}"
+            if control_message.reactions? or message.id == stop_id
+                stop = true
+                break
+            end
+            message.attachments.select{ |attachment| attachment.image? }.each do |attachment|
+                control_message.edit(control_message.content + "\nDownloading **#{attachment.filename}**... (#{message.timestamp.strftime("%F")})")
+                open("/tmp/tankbot_images/#{attachment.id}-#{attachment.filename}", 'wb') do |file|
+                    file << open(attachment.url).read
+                end
+            end
+        end
+        stop = messages.length < 100
+        earliest_message_id = messages.last.id
+    end
+    filename = "#{SecureRandom.uuid}.tar.gz"
+    `tar -czf /var/www/scr/#{filename} /tmp/tankbot_images`
+    FileUtils::rm_rf("/tmp/tankbot_images")
+    control_message.edit("https://scr.tankernn.eu/#{filename}")
+end
+
+bot.command(:neko) do |_event, keyword|
+    url = "https://nekos.life/api/v2/img/"
+    options = ["cum", "les", "meow", "tickle", "lewd", "feed", "bj",
+               "nsfw_neko_gif", "poke", "anal", "slap", "avatar", "pussy",
+               "lizard", "classic", "kuni", "pat", "kiss", "neko", "cuddle",
+               "fox_girl", "boobs", "random_hentai_gif", "hug"]
+    if options.include? keyword then
+        response = JSON.parse(Net::HTTP.get(URI("#{url}#{keyword}")))
+        "Here's your lewds!  °˖✧◝(⁰▿⁰)◜✧˖°\n#{response['url']}"
+    else
+        "No such tag. Please specify one of `#{options.join(", ")}`"
+    end
+end
+
+bot.command(:lmgtfy) do |_event, *args|
+    "http://lmgtfy.com/?s=d&q=#{args.join('+')}"
+end
+
+bot.command(:copypasta) do |_event, keyword|
+    pastafile = "copypastas.json"
+    file = File.read pastafile
+    pastas = JSON.parse file
+    if pastas.include? keyword then
+        pastas[keyword]
+    else
+        "No such pasta. Available pastas include `#{pastas.keys.join(", ")}`"
+    end
+end
+
+
+bot.run

Some files were not shown because too many files changed in this diff