Add IDs to channels and users
parent
d7509c80d6
commit
9bb1c4dad9
|
@ -4,11 +4,13 @@ module Vrobot4::Server
|
||||||
class User
|
class User
|
||||||
attr_reader :name # @return [String] plaintext name of the user
|
attr_reader :name # @return [String] plaintext name of the user
|
||||||
attr_reader :roles # @return [String] list of user's roles
|
attr_reader :roles # @return [String] list of user's roles
|
||||||
|
attr_reader :id # @return [Integer] unique identifier for the user
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generic channel information. May be extended.
|
# Generic channel information. May be extended.
|
||||||
class Channel
|
class Channel
|
||||||
attr_reader :name # @return [String] plaintext name of the channel
|
attr_reader :name # @return [String] plaintext name of the channel
|
||||||
|
attr_reader :id # @return [Integer] unique identifier for the channel
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generic event information. May not be extended.
|
# Generic event information. May not be extended.
|
||||||
|
@ -34,12 +36,12 @@ module Vrobot4::Server
|
||||||
@reply_b = info[:reply_b]
|
@reply_b = info[:reply_b]
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sends a message to the channel this message originated from.
|
# Sends a message to the originating channel.
|
||||||
def reply *args
|
def reply *args
|
||||||
@reply.call args.join(" ")
|
@reply.call args.join(" ")
|
||||||
end
|
end
|
||||||
|
|
||||||
# Sends a large message to the channel this message originated from.
|
# Sends a large message to the originating channel.
|
||||||
def reply_b *args
|
def reply_b *args
|
||||||
@reply_b.call args.join(" ")
|
@reply_b.call args.join(" ")
|
||||||
end
|
end
|
||||||
|
|
|
@ -106,13 +106,14 @@ class Sv_Discord < Vrobot4::Server::AudioServer
|
||||||
def initialize user, ops, hop
|
def initialize user, ops, hop
|
||||||
@real = user
|
@real = user
|
||||||
@name = user.name
|
@name = user.name
|
||||||
|
@id = user.id
|
||||||
@roles = "v"
|
@roles = "v"
|
||||||
if user.is_a? Discordrb::Member
|
if user.is_a? Discordrb::Member
|
||||||
if user.owner?
|
if user.owner?
|
||||||
@roles += "Ooh"
|
@roles += "Ooh"
|
||||||
elsif ops && ops.select {|role| user.role? role}.any?
|
elsif ops and ops.any? {|role| user.role? role}
|
||||||
@roles += "oh"
|
@roles += "oh"
|
||||||
elsif hop && hop.select {|role| user.role? role}.any?
|
elsif hop and hop.any? {|role| user.role? role}
|
||||||
@roles += "h"
|
@roles += "h"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -127,6 +128,7 @@ class Sv_Discord < Vrobot4::Server::AudioServer
|
||||||
def initialize chan
|
def initialize chan
|
||||||
@real = chan
|
@real = chan
|
||||||
@name = "#" + chan.name
|
@name = "#" + chan.name
|
||||||
|
@id = chan.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -90,6 +90,7 @@ class Sv_IRC < Vrobot4::Server::Server
|
||||||
def initialize user, chan
|
def initialize user, chan
|
||||||
@real = user
|
@real = user
|
||||||
@name = user.nick
|
@name = user.nick
|
||||||
|
@id = user.nick.downcase.hash
|
||||||
if user.oper? then @roles = "Oohv"
|
if user.oper? then @roles = "Oohv"
|
||||||
elsif chan.opped? user then @roles = "ohv"
|
elsif chan.opped? user then @roles = "ohv"
|
||||||
elsif chan.half_opped? user then @roles = "hv"
|
elsif chan.half_opped? user then @roles = "hv"
|
||||||
|
@ -106,6 +107,7 @@ class Sv_IRC < Vrobot4::Server::Server
|
||||||
def initialize chan
|
def initialize chan
|
||||||
@real = chan
|
@real = chan
|
||||||
@name = chan.name.downcase
|
@name = chan.name.downcase
|
||||||
|
@id = chan.name.downcase.hash
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue