add networking stuff
This commit is contained in:
parent
efa6ada5bb
commit
22a226402c
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
jon.sqlite
|
jon.sqlite
|
||||||
Gemfile.lock
|
Gemfile.lock
|
||||||
.idea
|
.idea
|
||||||
|
iplocation.bin
|
9
bot.rb
9
bot.rb
@ -13,11 +13,18 @@ bot.message do |event|
|
|||||||
end
|
end
|
||||||
|
|
||||||
bot.command :help do |event, *message|
|
bot.command :help do |event, *message|
|
||||||
event.author.pm("You've asked for help. In order not to flood the channel where you sent the command, I have sent the list of commands here, in your PMs. Enjoy! \n\n**Quote system**\n```;quote <category> - displays a quote from the category\n;addquote <category> <quote> - adds a quote into a category\n;quotecategories - shows all categories\n;showquote <id> - shows the quote with the id provided```")
|
event.author.pm("You've asked for help. In order not to flood the channel where you sent the command, I have sent the list of commands here, in your PMs. Enjoy!
|
||||||
|
|
||||||
|
**Quote system**\n```;quote <category> - displays a quote from the category\n;addquote <category> <quote> - adds a quote into a category\n;quotecategories - shows all categories\n;showquote <id> - shows the quote with the id provided```
|
||||||
|
**Networking related commands**\n```;ip <ips> - Display basic information about an IP address. You can input multiple IPs. We are required to state that the information provided by this command comes from the IP2Location database.```
|
||||||
|
|
||||||
|
")
|
||||||
event.message.delete
|
event.message.delete
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
require_relative 'systems/quote'
|
require_relative 'systems/quote'
|
||||||
|
require_relative 'systems/network'
|
||||||
bot.include! QuoteSystem
|
bot.include! QuoteSystem
|
||||||
|
bot.include! NetworkModule
|
||||||
bot.run
|
bot.run
|
||||||
|
21
systems/network.rb
Normal file
21
systems/network.rb
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
# 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
|
Loading…
Reference in New Issue
Block a user