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.

31 lines
667 B

  1. function User(socket) {
  2. this.registered = false
  3. this.nickname = ""
  4. this.connection = socket
  5. this.realname = ""
  6. this.username = ""
  7. this.setNickname = function(nickname) {
  8. this.nickname = nickname
  9. }
  10. this.getNickname = function(nickname) {
  11. return this.nickname
  12. }
  13. this.register = function(username, realname) {
  14. this.username = username
  15. this.realname = realname
  16. this.registered = true
  17. }
  18. this.getAddress = function() {
  19. return this.connection.address().address
  20. }
  21. this.sendMsg = function(from, message) {
  22. this.connection.write(`:${from.nickname} PRIVMSG ${this.nickname} :${message}`)
  23. }
  24. }
  25. module.exports = User