Add Discord server implementation
parent
51c9d0fdd5
commit
772c33a956
|
@ -1,13 +1,28 @@
|
|||
require 'discordrb'
|
||||
|
||||
class Sv_Discord < Vrobot4::Server::Server
|
||||
Vrobot4::Server.add_server_type self, "Discord"
|
||||
|
||||
def initialize info
|
||||
super()
|
||||
Vrobot4.log :INFO, "Sv_Discord:", info["serverid"]
|
||||
@bot = Discordrb::Bot.new \
|
||||
token: info["apikey"],
|
||||
client_id: info["client"]
|
||||
|
||||
@bot.message do |evt|
|
||||
m = Vrobot4::Server::Message.new(evt.message.content)
|
||||
if m.msg.start_with? '.'
|
||||
argv = m.msg.split
|
||||
cnam = argv.shift[1..-1]
|
||||
onCommand m, cnam, argv
|
||||
else
|
||||
onMessage m
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def connect
|
||||
puts "connected"
|
||||
@bot.run
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue