jon/systems/network.rb

21 lines
644 B
Ruby
Raw Permalink Normal View History

2024-10-04 19:02:48 +03:00
# 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