Java IRC bot
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.

MyInfo.java 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. package com.dmdirc.parser.irc;
  23. /**
  24. * Contains User information.
  25. *
  26. * @author Shane Mc Cormack
  27. * @author Chris Smith
  28. * @see IRCParser
  29. */
  30. public final class MyInfo {
  31. /** Character to prepend to nickname if in use (Default "_"). */
  32. private char prependChar = '_';
  33. /** Nickname to attempt to use on IRC. */
  34. private String nickname;
  35. /**
  36. * Alternative nickname to attempt to use on IRC.
  37. * If the first nickname is in use, and a NickInUse message is recieved before 001, we
  38. * will attempt to use this nickname instead.<br>
  39. * If this also fails, we will start prepending the prependChar character (_) to the main nickname
  40. */
  41. private String altNickname;
  42. /** Realname string to use */
  43. private String realname;
  44. /** Username to use, this doesn't matter when an ident server is running*/
  45. private String username;
  46. /**
  47. * Create a new MyInfo object.
  48. */
  49. public MyInfo() {
  50. String result;
  51. try {
  52. result = System.getProperty("user.name");
  53. } catch (SecurityException e) {
  54. result = null;
  55. }
  56. if (result == null || result.isEmpty()) {
  57. nickname = "IRCParser";
  58. username = "IRCParser";
  59. realname = "DMDIrc IRCParser";
  60. altNickname = "IRC-Parser";
  61. } else {
  62. nickname = result;
  63. username = nickname;
  64. realname = nickname+" - DMDIrc";
  65. altNickname = nickname+"-";
  66. }
  67. }
  68. /**
  69. * Set the Nickname.
  70. *
  71. * @param newValue Value to set to.
  72. */
  73. public void setNickname(final String newValue) {
  74. if (newValue != null && !newValue.isEmpty()) {
  75. nickname = newValue;
  76. }
  77. }
  78. /**
  79. * Get the Nickname.
  80. *
  81. * @return Current Nickname
  82. */
  83. public String getNickname() { return nickname; }
  84. /**
  85. * Set the Alternative Nickname.
  86. *
  87. * @param newValue Value to set to.
  88. */
  89. public void setAltNickname(final String newValue) {
  90. if (newValue != null && !newValue.isEmpty()) {
  91. altNickname = newValue;
  92. }
  93. }
  94. /**
  95. * Get the Alternative Nickname.
  96. *
  97. * @return Current Nickname
  98. */
  99. public String getAltNickname() { return altNickname; }
  100. /**
  101. * Set the Realname.
  102. *
  103. * @param newValue Value to set to.
  104. */
  105. public void setRealname(final String newValue) {
  106. if (newValue != null && !newValue.isEmpty()) {
  107. realname = newValue;
  108. }
  109. }
  110. /**
  111. * Get the Realname.
  112. *
  113. * @return Current Realname
  114. */
  115. public String getRealname() { return realname; }
  116. /**
  117. * Set the Username.
  118. *
  119. * @param newValue Value to set to.
  120. */
  121. public void setUsername(final String newValue) {
  122. if (newValue != null && !newValue.isEmpty()) {
  123. username = newValue;
  124. }
  125. }
  126. /**
  127. * Get the Username.
  128. *
  129. * @return Current Username
  130. */
  131. public String getUsername() { return username; }
  132. /**
  133. * Set the Prepend Character.
  134. *
  135. * @param newValue Value to set to.
  136. */
  137. public void setPrependChar(final char newValue) { prependChar = newValue; }
  138. /**
  139. * Get the Prepend Character.
  140. *
  141. * @return Current Prepend Character
  142. */
  143. public char getPrependChar() { return prependChar; }
  144. }