|
@@ -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
|