Add IDs to channels and users

master
Marrub 2017-08-15 16:48:43 -04:00
parent d7509c80d6
commit 9bb1c4dad9
3 changed files with 10 additions and 4 deletions

View File

@ -4,11 +4,13 @@ module Vrobot4::Server
class User
attr_reader :name # @return [String] plaintext name of the user
attr_reader :roles # @return [String] list of user's roles
attr_reader :id # @return [Integer] unique identifier for the user
end
# Generic channel information. May be extended.
class Channel
attr_reader :name # @return [String] plaintext name of the channel
attr_reader :id # @return [Integer] unique identifier for the channel
end
# Generic event information. May not be extended.
@ -34,12 +36,12 @@ module Vrobot4::Server
@reply_b = info[:reply_b]
end
# Sends a message to the channel this message originated from.
# Sends a message to the originating channel.
def reply *args
@reply.call args.join(" ")
end
# Sends a large message to the channel this message originated from.
# Sends a large message to the originating channel.
def reply_b *args
@reply_b.call args.join(" ")
end

View File

@ -106,13 +106,14 @@ class Sv_Discord < Vrobot4::Server::AudioServer
def initialize user, ops, hop
@real = user
@name = user.name
@id = user.id
@roles = "v"
if user.is_a? Discordrb::Member
if user.owner?
@roles += "Ooh"
elsif ops && ops.select {|role| user.role? role}.any?
elsif ops and ops.any? {|role| user.role? role}
@roles += "oh"
elsif hop && hop.select {|role| user.role? role}.any?
elsif hop and hop.any? {|role| user.role? role}
@roles += "h"
end
end
@ -127,6 +128,7 @@ class Sv_Discord < Vrobot4::Server::AudioServer
def initialize chan
@real = chan
@name = "#" + chan.name
@id = chan.id
end
end
end

View File

@ -90,6 +90,7 @@ class Sv_IRC < Vrobot4::Server::Server
def initialize user, chan
@real = user
@name = user.nick
@id = user.nick.downcase.hash
if user.oper? then @roles = "Oohv"
elsif chan.opped? user then @roles = "ohv"
elsif chan.half_opped? user then @roles = "hv"
@ -106,6 +107,7 @@ class Sv_IRC < Vrobot4::Server::Server
def initialize chan
@real = chan
@name = chan.name.downcase
@id = chan.name.downcase.hash
end
end
end