Compare commits

..

No commits in common. "0af5981abe5bddc6eedb79711421550594719b3c" and "d1e1ecdb1973be54989014efbd2b4a2261277ea5" have entirely different histories.

3 changed files with 5 additions and 22 deletions

View File

@ -170,8 +170,7 @@ module Backend_Discord
serv: serv,
bot: self,
reply: -> (text) {evt.channel.send text},
reply_b: -> (text) {evt.channel.send "```\n#{text}```"},
real: evt.message
reply_b: -> (text) {evt.channel.send "```\n#{text}```"}
serv.handle_text_cmd m
end

View File

@ -8,16 +8,12 @@ class Mod_NSFW < Vrobot4::Module::Module
def initialize info
super
register :c_danbooru, "danbooru", "Queries Danbooru for an image."
register :c_saucenao, "saucenao", "Queries SauceNao for an image."
register :c_deletethis, "deletethis", "Deletes the last image by you."
register :c_danbooru, "danbooru", "Queries Danbooru for a random image."
register :c_saucenao, "saucenao", "Queries SauceNao for an image."
@disallowed = info[:danbooru_filters]
@danbooru_login = info[:danbooru_login]
@danbooru_api_key = info[:danbooru_api_key]
@saucenao_api_key = info[:saucenao_api_key]
@culling_cache = {}
end
def c_danbooru m, argv
@ -34,7 +30,7 @@ class Mod_NSFW < Vrobot4::Module::Module
api_key: @danbooru_api_key,
}
parm[:tags] = argv unless argv.empty?
uri = URI "https://danbooru.donmai.us/posts.json"
uri = URI("https://danbooru.donmai.us/posts.json")
uri.query = URI.encode_www_form parm
res = Net::HTTP.get_response(uri)
@ -46,7 +42,7 @@ class Mod_NSFW < Vrobot4::Module::Module
src = obj["source"]
src = "none provided" if src.empty?
if !tags.match(disallow_regex) && url && !url.empty?
@culling_cache[m.user.id] = m.reply "#{url}\n(source: <#{src}>)"
m.reply "#{url}\n(source: <#{src}>)"
return
end
end
@ -80,15 +76,6 @@ class Mod_NSFW < Vrobot4::Module::Module
raise ArgumentError, "Couldn't process request. Error code: #{res}"
end
end
def c_deletethis m, argv
if cull = @culling_cache[m.user.id]
m.real.delete
cull.delete
else
m.reply "No images to delete."
end
end
end
## EOF

View File

@ -22,7 +22,6 @@ module Vrobot4::Server
attr_reader :chan # @return [Channel] channel this message was sent to
attr_reader :serv # @return [Server] server this message was sent to
attr_reader :bot # @return [Vrobot4::Robots::Bot] bot this was sent to
attr_reader :real # @return the original message, if any
# @param info [Hash] A hash containing message info. Keys may be omitted.
# [:msg] Plaintext of message.
@ -32,7 +31,6 @@ module Vrobot4::Server
# [:bot] Bot this message was sent to.
# [:reply] Method that sends a message to the specified channel.
# [:reply_b] Method that sends a large message to the specified channel.
# [:real] The original message, if any.
def initialize(**info)
@msg = info[:msg]
@user = info[:user]
@ -41,7 +39,6 @@ module Vrobot4::Server
@bot = info[:bot]
@reply = info[:reply]
@reply_b = info[:reply_b]
@real = info[:real]
end
# Sends a message to the originating channel.