make vrobot able to do nothing on servers not in the config hash

master
an 2020-01-16 20:35:41 -05:00
parent 41a779f58b
commit b0d44bd02b
1 changed files with 13 additions and 12 deletions

View File

@ -162,17 +162,18 @@ module Backend_Discord
@real.message do |evt|
if evt.server
serv = get_server evt.server
if serv
m = Vrobot4::Server::Message.new \
msg: evt.message.content,
user: User.new(evt.user, @ops, @hop),
chan: Channel.new(evt.channel),
serv: serv,
bot: self,
reply: -> (text) {evt.channel.send text},
reply_b: -> (text) {evt.channel.send "```\n#{text}```"}
m = Vrobot4::Server::Message.new \
msg: evt.message.content,
user: User.new(evt.user, @ops, @hop),
chan: Channel.new(evt.channel),
serv: serv,
bot: self,
reply: -> (text) {evt.channel.send text},
reply_b: -> (text) {evt.channel.send "```\n#{text}```"}
serv.handle_text_cmd m
serv.handle_text_cmd m
end
end
end
end
@ -192,11 +193,11 @@ module Backend_Discord
@servers[serv.id] = Server.new @info[serv.id] || {}, self, serv
end
# Finds a server in the hash, potentially adding it.
# Finds a server in the hash, or nil.
# @param serv [Discordrb::Server] server instance
# @return [Server]
def get_server serv
@servers[serv.id] || add_server(serv)
@servers[serv.id]
end
end
end