21 lines
644 B
Ruby
21 lines
644 B
Ruby
# frozen_string_literal: true
|
|
|
|
require 'discordrb'
|
|
require 'ip2location_ruby'
|
|
module NetworkModule
|
|
extend Discordrb::Commands::CommandContainer
|
|
command :ip do |event, *message|
|
|
database = Ip2location.new.open("#{__dir__}/../iplocation.bin")
|
|
records = []
|
|
for ip in message do
|
|
records.push(database.get_all(ip).merge!("ip" => ip))
|
|
end
|
|
response = ""
|
|
for record in records do
|
|
response = response + "**:flag_#{record['country_short'].downcase}: #{record['ip']}**\n**Region**: #{record['region']}\n**City**: #{record['city']}\n\n"
|
|
end
|
|
event.channel.send(response)
|
|
database.close()
|
|
nil
|
|
end
|
|
end |