You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
52 lines
1.2 KiB
function User(socket) {
|
|
this.registered = false
|
|
this.authenticated = false
|
|
this.nickname = ""
|
|
this.connection = socket
|
|
this.realname = ""
|
|
this.username = ""
|
|
|
|
this.setNickname = function(nickname) {
|
|
this.nickname = nickname
|
|
}
|
|
|
|
this.getNickname = function(nickname) {
|
|
return this.nickname
|
|
}
|
|
this.setPassword = function (password) {
|
|
this.password = password
|
|
}
|
|
|
|
this.register = function(username, realname) {
|
|
if (!this.authenticated) {
|
|
this.connection.destroy()
|
|
}
|
|
this.username = username
|
|
this.realname = realname
|
|
this.registered = true
|
|
}
|
|
|
|
this.getAddress = function() {
|
|
return this.connection.address().address
|
|
}
|
|
this.setNickname = function (nickname) {
|
|
this.nickname = nickname
|
|
}
|
|
this.setRealName = function (realname) {
|
|
this.realname = realname
|
|
}
|
|
|
|
this.closeConnection = function () {
|
|
this.connection.destroy()
|
|
}
|
|
|
|
|
|
this.sendMsg = function (from, message) {
|
|
this.connection.write(`:${from.nickname} PRIVMSG ${this.nickname} :${message}\r\n`, "ascii")
|
|
}
|
|
this.sendRaw = function(message) {
|
|
this.connection.write(`${message}\r\n`, "ascii")
|
|
}
|
|
}
|
|
|
|
module.exports = User
|