commit f06a13fe5e654526a1f38b757031bf21d793729e Author: Minh Bui Date: Tue Jan 7 13:52:19 2020 -0700 Adding project diff --git a/README.md b/README.md new file mode 100644 index 0000000..0df6ed6 --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +## ChatApplication with 4 bots. + +A typical multi-threaded Chat Client/Server Java application + +## Features +. Simple authentication with server. Users' info is stored as text file on the server side. + + + +## How To Run +The server and client are initially configured to run locally. To run it on a different network, port forwarding is advised. We also need to change the hostName variable in SignInView.java. The client needs to know the server's WAN address. + +First run the server, and then run the client. + +## Bots +You can add more bots to the server as long as the bot implements the Bot.java interface. The new bot should also be instantiated in ChatServer.java file and assigned to a command character. diff --git a/Sprint Documentation.txt b/Sprint Documentation.txt new file mode 100644 index 0000000..2a934db --- /dev/null +++ b/Sprint Documentation.txt @@ -0,0 +1,38 @@ +Sprint planning: + +1st Sprint: + a. UML diagram + b. Commands/responses for each bot + c. A topic for each bot + +2nd Sprint: + a. Superbot implementation + b. Expected commands should be responded + c. Basic GUI of the chatting room + +3rd Sprint: + a. One bot fully implemented + b. Enable users authentication + c. SignIn/signUp GUI + +4th Sprint: + a. Networking works + b. All bots are fully implemented + c. Documentations + d. potenial Wow factors + port forwarding that enable the server can be connected from different Internet + NLU chatbot invoked by !ttm [message] using aim and alive bot's library. + + +Sprint Review: + +1st Sprint: +In the first sprint, we have showed our UML diagram to the SL and each of us has picked a topic. We have topics about moba game, NBA, music player and makeups. The SL thought we were kind of ahead. + +2nd Sprint: +In the second sprint, we have implemented one bot that can respond some default commands in a chatroom. Michael told us to implement all four bots for the next sprints. + +3rd Sprint: +We were a little bit delayed since we did not have four fully implemented bots. However, we have done with the signIn and signUp. + + diff --git a/doc/ChatBotProgramDesign.xml b/doc/ChatBotProgramDesign.xml new file mode 100644 index 0000000..097ee79 --- /dev/null +++ b/doc/ChatBotProgramDesign.xml @@ -0,0 +1 @@ +7Vxtb+I4EP41kXY/9JQXwsvHAtveSa20Krt7nw0xxFon5hxT2v76Gyc2JLVpw22A3p0rpMbjiZPM84zHMzF40SR7uuVond6zBFMv9JMnL5p6YRj0wj78k5LnSjKIokqw4iRRSnvBjLxgJfSVdEMSXDQUBWNUkHVTuGB5jheiIUOcs21Tbclo86prtMKGYLZA1JT+SRKRKmng+/uO3zFZperSw1h1zNHi54qzTa6u54XRsvyrujOkx1L6RYoStq2Joi9eNOGMieooe5pgKm2rzVadd3Ogd3ffHOeizQmD4agfBPFo6ffxaIiHV8GgGuIR0Y0yxhhuBs7I1hRnMGwBjRnmBFHyguZgsepBxLM2XrElGUU5tMapyCgIAzhcslzMlJJsw+mrHI4XMCTmIHjEXBCA4Fp1CLYG6SIlNLlDz2wjn6cQYF/dGqeMkxcYFulrQDcXik1AwbrGTJ4JYh+kHBeg81UbKdiJ7lAhlM6CUYrWBZnvbjhDfEVyMIZgmVLST3pDKJ0wynhpAI04jCqJgBOtrbGuxs/IQh1TNMd0vGOOHilnpQ0LwdlPXBveL/92PZqgpZFrN6JOl3a/QRmh0hV/YJ6gHGk4KksFoWrbrmESSnFMwoWfaiJFsFvMMiz4M6io3khxXc0FYU9NDtu9Z4UDpZPWnCrqKSFS3rzaDb1nNBwoUrck+O7+9wS/KmeSLEN5UtwRSYFrkFzPwb5oIe7R2gv7KJNspJJ2M8FJvvLCibwMWEV3rsTOXjVvACOJpic0AdUwmchpD6F4KQ76R7FGC7ibu1Jn2ttLHpQhpWibEoFnIJf3tIUpG2QMxlvSko8pSRKcl3wVSKCK8hL8NSPS3+E54jF8AI6J/1vsxVP58PE42LfhI9U5cCiXZiMlWzD40xYXwsqjw1PP+8zSVGrJJK3XLZEiK5E2BeZtWFQyR1LoO5zgOHQxDsXhJTkUGxzywrFcsRAslyySQeJ5bcZYx4jTMWIwvCQj+o4RH44Rgd+7JCV6jhIfjxJ6VXsRSgQjCyVeoU/J6xSsVb7wDvQZAEbxHutvkgrTq8DgQ2TyIbLgXOY+X1lBBGFyfF7pvsL/MhDHLZeXw1M4vX/A6VdYPOBiDYbAn3QmorOXz9VkoMVuOjgfV/oXjRBm0WZHlu85+WuDd5RxFLkYRUZnjBiBOX1MUiQmlMAj3X7/w0C+VrT7N1TqKtE9emooHlu/OwChpd51sLg17DWrW8EoNlAO+rag0QXKZi3rqJXh+Z37Io78HsC+HeHDRSYroJ24bdh6XfdfX8z9GmiWqo7dCzvAzKwDVk4II6Us+SQd8LPzxU5g7Zsh9HS+aKbdMoTOMH+UBVsXPzuJn7HfjJ9R3BLiIOjCd836a/kyCHB+YCwrKrctq/lhvyzbf0s5Rgm0VKUeiBYF0hZX3iT0rv2axHn6m7TodRJ1h70OWGCrubqoezxoQdDSebtw3aF1eq4yHDc9nyi9aT09d5Le2KqcLr051meHnUy0XSyprEVNN9EeD9oZ0xvLfhmX3pwI1nOmN9r1arhWO1Fc5Owmcr6qC7aFVpeAfglb+9akHGW4Wf6v5SoubWkFeuU2HyOammmLRHlOuEinSN5UBfYUCeyg7hzqtjG4E6htW0Dcwul40Cx7u+zVJb+LpdOh3X2CVRNwu7exzhtbABsMzznzmu/b96XhHwRv3SrqROXhs75eDc0Sk6s/HO+4g4+zYmq/be7/HkbfBu2M9YfIVjNy9YeTwHrO+kNk1pUm6rWbi55dRc9G7OxbptootC1+ww5eqkVmfany2ze/IGX9atTrV60ug23Jjujor89Z+dDvgg62XTIu9B4PmmUXqRW0LkLvoS+euNDbPaxmYcIK6z8IvdDc/6BA2Vf71Yboy98= \ No newline at end of file diff --git a/doc/ChatBotResponsesDoc.txt b/doc/ChatBotResponsesDoc.txt new file mode 100644 index 0000000..640ce24 --- /dev/null +++ b/doc/ChatBotResponsesDoc.txt @@ -0,0 +1,23 @@ +List of default commands: +!help - list out the available commands for the current bot. +!info User - prints out the information of User. +!date - prints out the current date. +!whoami - prints out the user's client info such as IP addresses, ... + +Yanghu's chatbot theme: Soccer + +Weixiang's chatbot theme: MOBA game or LoL. + +MingJun's chatbot theme: + +MinhBui's chatbot theme: music bot that supports youtube music +!import [URL] - given a Youtube URL, import the URL to the play list. +!remove [ID]/[Name] - given an ID or name, remove the music from the play list. +!list - lists out the current songs in the playlist. +!play [ID]/[Name] - given a name or an ID, play the song in the list. If nothing is given, resume playing the current song. +!current - displays the current playing song. +!pause - pause the current song +!repeat - toggle repeat mode +!shuffle - shuffle repeat mode +![reponse] - comments on the reponse of an user. (nlp feature) +!rate [User]/[MusicID]/[MusicName] - give a random rate of a music or an user from 0 to 10. diff --git a/doc/javadoc/ChatBotProgramDesign.xml b/doc/javadoc/ChatBotProgramDesign.xml new file mode 100644 index 0000000..097ee79 --- /dev/null +++ b/doc/javadoc/ChatBotProgramDesign.xml @@ -0,0 +1 @@ +7Vxtb+I4EP41kXY/9JQXwsvHAtveSa20Krt7nw0xxFon5hxT2v76Gyc2JLVpw22A3p0rpMbjiZPM84zHMzF40SR7uuVond6zBFMv9JMnL5p6YRj0wj78k5LnSjKIokqw4iRRSnvBjLxgJfSVdEMSXDQUBWNUkHVTuGB5jheiIUOcs21Tbclo86prtMKGYLZA1JT+SRKRKmng+/uO3zFZperSw1h1zNHi54qzTa6u54XRsvyrujOkx1L6RYoStq2Joi9eNOGMieooe5pgKm2rzVadd3Ogd3ffHOeizQmD4agfBPFo6ffxaIiHV8GgGuIR0Y0yxhhuBs7I1hRnMGwBjRnmBFHyguZgsepBxLM2XrElGUU5tMapyCgIAzhcslzMlJJsw+mrHI4XMCTmIHjEXBCA4Fp1CLYG6SIlNLlDz2wjn6cQYF/dGqeMkxcYFulrQDcXik1AwbrGTJ4JYh+kHBeg81UbKdiJ7lAhlM6CUYrWBZnvbjhDfEVyMIZgmVLST3pDKJ0wynhpAI04jCqJgBOtrbGuxs/IQh1TNMd0vGOOHilnpQ0LwdlPXBveL/92PZqgpZFrN6JOl3a/QRmh0hV/YJ6gHGk4KksFoWrbrmESSnFMwoWfaiJFsFvMMiz4M6io3khxXc0FYU9NDtu9Z4UDpZPWnCrqKSFS3rzaDb1nNBwoUrck+O7+9wS/KmeSLEN5UtwRSYFrkFzPwb5oIe7R2gv7KJNspJJ2M8FJvvLCibwMWEV3rsTOXjVvACOJpic0AdUwmchpD6F4KQ76R7FGC7ibu1Jn2ttLHpQhpWibEoFnIJf3tIUpG2QMxlvSko8pSRKcl3wVSKCK8hL8NSPS3+E54jF8AI6J/1vsxVP58PE42LfhI9U5cCiXZiMlWzD40xYXwsqjw1PP+8zSVGrJJK3XLZEiK5E2BeZtWFQyR1LoO5zgOHQxDsXhJTkUGxzywrFcsRAslyySQeJ5bcZYx4jTMWIwvCQj+o4RH44Rgd+7JCV6jhIfjxJ6VXsRSgQjCyVeoU/J6xSsVb7wDvQZAEbxHutvkgrTq8DgQ2TyIbLgXOY+X1lBBGFyfF7pvsL/MhDHLZeXw1M4vX/A6VdYPOBiDYbAn3QmorOXz9VkoMVuOjgfV/oXjRBm0WZHlu85+WuDd5RxFLkYRUZnjBiBOX1MUiQmlMAj3X7/w0C+VrT7N1TqKtE9emooHlu/OwChpd51sLg17DWrW8EoNlAO+rag0QXKZi3rqJXh+Z37Io78HsC+HeHDRSYroJ24bdh6XfdfX8z9GmiWqo7dCzvAzKwDVk4II6Us+SQd8LPzxU5g7Zsh9HS+aKbdMoTOMH+UBVsXPzuJn7HfjJ9R3BLiIOjCd836a/kyCHB+YCwrKrctq/lhvyzbf0s5Rgm0VKUeiBYF0hZX3iT0rv2axHn6m7TodRJ1h70OWGCrubqoezxoQdDSebtw3aF1eq4yHDc9nyi9aT09d5Le2KqcLr051meHnUy0XSyprEVNN9EeD9oZ0xvLfhmX3pwI1nOmN9r1arhWO1Fc5Owmcr6qC7aFVpeAfglb+9akHGW4Wf6v5SoubWkFeuU2HyOammmLRHlOuEinSN5UBfYUCeyg7hzqtjG4E6htW0Dcwul40Cx7u+zVJb+LpdOh3X2CVRNwu7exzhtbABsMzznzmu/b96XhHwRv3SrqROXhs75eDc0Sk6s/HO+4g4+zYmq/be7/HkbfBu2M9YfIVjNy9YeTwHrO+kNk1pUm6rWbi55dRc9G7OxbptootC1+ww5eqkVmfany2ze/IGX9atTrV60ug23Jjujor89Z+dDvgg62XTIu9B4PmmUXqRW0LkLvoS+euNDbPaxmYcIK6z8IvdDc/6BA2Vf71Yboy98= \ No newline at end of file diff --git a/doc/javadoc/ChatBotResponsesDoc.txt b/doc/javadoc/ChatBotResponsesDoc.txt new file mode 100644 index 0000000..640ce24 --- /dev/null +++ b/doc/javadoc/ChatBotResponsesDoc.txt @@ -0,0 +1,23 @@ +List of default commands: +!help - list out the available commands for the current bot. +!info User - prints out the information of User. +!date - prints out the current date. +!whoami - prints out the user's client info such as IP addresses, ... + +Yanghu's chatbot theme: Soccer + +Weixiang's chatbot theme: MOBA game or LoL. + +MingJun's chatbot theme: + +MinhBui's chatbot theme: music bot that supports youtube music +!import [URL] - given a Youtube URL, import the URL to the play list. +!remove [ID]/[Name] - given an ID or name, remove the music from the play list. +!list - lists out the current songs in the playlist. +!play [ID]/[Name] - given a name or an ID, play the song in the list. If nothing is given, resume playing the current song. +!current - displays the current playing song. +!pause - pause the current song +!repeat - toggle repeat mode +!shuffle - shuffle repeat mode +![reponse] - comments on the reponse of an user. (nlp feature) +!rate [User]/[MusicID]/[MusicName] - give a random rate of a music or an user from 0 to 10. diff --git a/doc/javadoc/allclasses-frame.html b/doc/javadoc/allclasses-frame.html new file mode 100644 index 0000000..d0e6155 --- /dev/null +++ b/doc/javadoc/allclasses-frame.html @@ -0,0 +1,19 @@ + + + + + +所有类 + + + + + +

所有类

+
+ +
+ + diff --git a/doc/javadoc/allclasses-noframe.html b/doc/javadoc/allclasses-noframe.html new file mode 100644 index 0000000..53498f0 --- /dev/null +++ b/doc/javadoc/allclasses-noframe.html @@ -0,0 +1,19 @@ + + + + + +所有类 + + + + + +

所有类

+
+ +
+ + diff --git a/doc/javadoc/constant-values.html b/doc/javadoc/constant-values.html new file mode 100644 index 0000000..7c05241 --- /dev/null +++ b/doc/javadoc/constant-values.html @@ -0,0 +1,122 @@ + + + + + +常量字段值 + + + + + + + + +
+ + + + + + + +
+ + +
+

常量字段值

+

目录

+
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/deprecated-list.html b/doc/javadoc/deprecated-list.html new file mode 100644 index 0000000..bdf479a --- /dev/null +++ b/doc/javadoc/deprecated-list.html @@ -0,0 +1,122 @@ + + + + + +已过时的列表 + + + + + + + + +
+ + + + + + + +
+ + +
+

已过时的 API

+

目录

+
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/help-doc.html b/doc/javadoc/help-doc.html new file mode 100644 index 0000000..a6d5678 --- /dev/null +++ b/doc/javadoc/help-doc.html @@ -0,0 +1,223 @@ + + + + + +API 帮助 + + + + + + + + +
+ + + + + + + +
+ + +
+

此 API 文档的组织方式

+
此 API (应用程序编程接口) 文档包含对应于导航栏中的项目的页面, 如下所述。
+
+
+ +此帮助文件适用于使用标准 doclet 生成的 API 文档。
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/index-files/index-1.html b/doc/javadoc/index-files/index-1.html new file mode 100644 index 0000000..eb38b1d --- /dev/null +++ b/doc/javadoc/index-files/index-1.html @@ -0,0 +1,130 @@ + + + + + +C - 索引 + + + + + + + + +
+ + + + + + + +
+ + +
C D G H S W  + + +

C

+
+
createNewCmdsCounter() - 类 中的方法server.Bots.WeixiangBot
+
+
This method is to construct a hashmap to count amount of how many times + the command being called
+
+
+C D G H S W 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/index-files/index-2.html b/doc/javadoc/index-files/index-2.html new file mode 100644 index 0000000..c465457 --- /dev/null +++ b/doc/javadoc/index-files/index-2.html @@ -0,0 +1,129 @@ + + + + + +D - 索引 + + + + + + + + +
+ + + + + + + +
+ + +
C D G H S W  + + +

D

+
+
dateCommand() - 类 中的方法server.Bots.WeixiangBot
+
+
This method is to get the date and return it
+
+
+C D G H S W 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/index-files/index-3.html b/doc/javadoc/index-files/index-3.html new file mode 100644 index 0000000..ad8ef90 --- /dev/null +++ b/doc/javadoc/index-files/index-3.html @@ -0,0 +1,129 @@ + + + + + +G - 索引 + + + + + + + + +
+ + + + + + + +
+ + +
C D G H S W  + + +

G

+
+
getBotSignature() - 类 中的方法server.Bots.WeixiangBot
+
 
+
getResponses(String, User, List<ChatClientThread>) - 类 中的方法server.Bots.WeixiangBot
+
 
+
+C D G H S W 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/index-files/index-4.html b/doc/javadoc/index-files/index-4.html new file mode 100644 index 0000000..80f92fd --- /dev/null +++ b/doc/javadoc/index-files/index-4.html @@ -0,0 +1,127 @@ + + + + + +H - 索引 + + + + + + + + +
+ + + + + + + +
+ + +
C D G H S W  + + +

H

+
+
helpCommand() - 类 中的方法server.Bots.WeixiangBot
+
 
+
+C D G H S W 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/index-files/index-5.html b/doc/javadoc/index-files/index-5.html new file mode 100644 index 0000000..8de5f44 --- /dev/null +++ b/doc/javadoc/index-files/index-5.html @@ -0,0 +1,127 @@ + + + + + +S - 索引 + + + + + + + + +
+ + + + + + + +
+ + +
C D G H S W  + + +

S

+
+
server.Bots - 程序包 server.Bots
+
 
+
+C D G H S W 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/index-files/index-6.html b/doc/javadoc/index-files/index-6.html new file mode 100644 index 0000000..3118956 --- /dev/null +++ b/doc/javadoc/index-files/index-6.html @@ -0,0 +1,133 @@ + + + + + +W - 索引 + + + + + + + + +
+ + + + + + + +
+ + +
C D G H S W  + + +

W

+
+
WeixiangBot - server.Bots中的类
+
 
+
WeixiangBot(char) - 类 的构造器server.Bots.WeixiangBot
+
+
This is constructor that add all the responses to the map.
+
+
whoamiCommand(User) - 类 中的方法server.Bots.WeixiangBot
+
 
+
+C D G H S W 
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/index.html b/doc/javadoc/index.html new file mode 100644 index 0000000..c7ad32e --- /dev/null +++ b/doc/javadoc/index.html @@ -0,0 +1,72 @@ + + + + + +生成的文档 (无标题) + + + + + + +<noscript> +<div>您的浏览器已禁用 JavaScript。</div> +</noscript> +<h2>框架预警</h2> +<p>请使用框架功能查看此文档。如果看到此消息, 则表明您使用的是不支持框架的 Web 客户机。链接到<a href="server/Bots/package-summary.html">非框架版本</a>。</p> + + + diff --git a/doc/javadoc/overview-tree.html b/doc/javadoc/overview-tree.html new file mode 100644 index 0000000..bca0265 --- /dev/null +++ b/doc/javadoc/overview-tree.html @@ -0,0 +1,139 @@ + + + + + +类分层结构 + + + + + + + + +
+ + + + + + + +
+ + +
+

所有程序包的分层结构

+程序包分层结构: + +
+
+

类分层结构

+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/package-list b/doc/javadoc/package-list new file mode 100644 index 0000000..ca803c8 --- /dev/null +++ b/doc/javadoc/package-list @@ -0,0 +1 @@ +server.Bots diff --git a/doc/javadoc/script.js b/doc/javadoc/script.js new file mode 100644 index 0000000..b346356 --- /dev/null +++ b/doc/javadoc/script.js @@ -0,0 +1,30 @@ +function show(type) +{ + count = 0; + for (var key in methods) { + var row = document.getElementById(key); + if ((methods[key] & type) != 0) { + row.style.display = ''; + row.className = (count++ % 2) ? rowColor : altColor; + } + else + row.style.display = 'none'; + } + updateTabs(type); +} + +function updateTabs(type) +{ + for (var value in tabs) { + var sNode = document.getElementById(tabs[value][0]); + var spanNode = sNode.firstChild; + if (value == type) { + sNode.className = activeTableTab; + spanNode.innerHTML = tabs[value][1]; + } + else { + sNode.className = tableTab; + spanNode.innerHTML = "" + tabs[value][1] + ""; + } + } +} diff --git a/doc/javadoc/server/Bots/WeixiangBot.html b/doc/javadoc/server/Bots/WeixiangBot.html new file mode 100644 index 0000000..4075b2b --- /dev/null +++ b/doc/javadoc/server/Bots/WeixiangBot.html @@ -0,0 +1,409 @@ + + + + + +WeixiangBot + + + + + + + + +
+ + + + + + + +
+ + + +
+
server.Bots
+

类 WeixiangBot

+
+
+ +
+
    +
  • +
    +
    +
    public class WeixiangBot
    +extends server.Bots.Bot
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      构造器概要

      + + + + + + + + +
      构造器 
      构造器和说明
      WeixiangBot(char characterId) +
      This is constructor that add all the responses to the map.
      +
      +
    • +
    + +
      +
    • + + +

      方法概要

      + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
      所有方法 实例方法 具体方法 
      限定符和类型方法和说明
      java.util.AbstractMap<java.lang.String,java.lang.Integer>createNewCmdsCounter() +
      This method is to construct a hashmap to count amount of how many times + the command being called
      +
      java.lang.StringdateCommand() +
      This method is to get the date and return it
      +
      java.lang.StringgetBotSignature() 
      server.ResponsegetResponses(java.lang.String message, + server.User user, + java.util.List<server.ChatClientThread> clients) +
      Every Bot's subclass needs to overwrite this method.
      +
      java.lang.StringhelpCommand() 
      java.lang.StringwhoamiCommand(server.User user) 
      +
        +
      • + + +

        从类继承的方法 server.Bots.Bot

        +getBotCharacterId, getDefaultCommandsList, getSmartResponse, infoCommand, setBotCharacterId
      • +
      +
        +
      • + + +

        从类继承的方法 java.lang.Object

        +equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • +
      +
    • +
    +
  • +
+
+
+
    +
  • + +
      +
    • + + +

      构造器详细资料

      + + + +
        +
      • +

        WeixiangBot

        +
        public WeixiangBot(char characterId)
        +
        This is constructor that add all the responses to the map.
        +
        +
        参数:
        +
        characterId - The special character for each ChatBot.
        +
        +
      • +
      +
    • +
    + +
      +
    • + + +

      方法详细资料

      + + + +
        +
      • +

        createNewCmdsCounter

        +
        public java.util.AbstractMap<java.lang.String,java.lang.Integer> createNewCmdsCounter()
        +
        This method is to construct a hashmap to count amount of how many times + the command being called
        +
        +
        返回:
        +
        A HashMap to count each commands that have been used
        +
        +
      • +
      + + + +
        +
      • +

        getBotSignature

        +
        public java.lang.String getBotSignature()
        +
        +
        指定者:
        +
        getBotSignature 在类中 server.Bots.Bot
        +
        返回:
        +
        the string representing the signature of the ChatBot
        +
        +
      • +
      + + + +
        +
      • +

        dateCommand

        +
        public java.lang.String dateCommand()
        +
        This method is to get the date and return it
        +
        +
        指定者:
        +
        dateCommand 在类中 server.Bots.Bot
        +
        返回:
        +
        the string representing the date
        +
        +
      • +
      + + + +
        +
      • +

        whoamiCommand

        +
        public java.lang.String whoamiCommand(server.User user)
        +
        +
        指定者:
        +
        whoamiCommand 在类中 server.Bots.Bot
        +
        参数:
        +
        user - the User object
        +
        返回:
        +
        the string that has a name and IP address
        +
        +
      • +
      + + + +
        +
      • +

        getResponses

        +
        public server.Response getResponses(java.lang.String message,
        +                                    server.User user,
        +                                    java.util.List<server.ChatClientThread> clients)
        +
        从类复制的说明: server.Bots.Bot
        +
        Every Bot's subclass needs to overwrite this method.
        +
        +
        指定者:
        +
        getResponses 在类中 server.Bots.Bot
        +
        参数:
        +
        message - the message from user
        +
        user - the User object
        +
        clients - the list contains the all ChatClientThread who is online
        +
        返回:
        +
        A Response that has two fields, one is the response message, the other is the URL if needed
        +
        +
      • +
      + + + +
        +
      • +

        helpCommand

        +
        public java.lang.String helpCommand()
        +
        +
        覆盖:
        +
        helpCommand 在类中 server.Bots.Bot
        +
        返回:
        +
        The string listing out all available commands
        +
        +
      • +
      +
    • +
    +
  • +
+
+
+ + +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/server/Bots/class-use/WeixiangBot.html b/doc/javadoc/server/Bots/class-use/WeixiangBot.html new file mode 100644 index 0000000..cb73c10 --- /dev/null +++ b/doc/javadoc/server/Bots/class-use/WeixiangBot.html @@ -0,0 +1,122 @@ + + + + + +类 server.Bots.WeixiangBot的使用 + + + + + + + + +
+ + + + + + + +
+ + +
+

类的使用
server.Bots.WeixiangBot

+
+
没有server.Bots.WeixiangBot的用法
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/server/Bots/package-frame.html b/doc/javadoc/server/Bots/package-frame.html new file mode 100644 index 0000000..8b4c3a7 --- /dev/null +++ b/doc/javadoc/server/Bots/package-frame.html @@ -0,0 +1,20 @@ + + + + + +server.Bots + + + + + +

server.Bots

+
+

+ +
+ + diff --git a/doc/javadoc/server/Bots/package-summary.html b/doc/javadoc/server/Bots/package-summary.html new file mode 100644 index 0000000..4525d9a --- /dev/null +++ b/doc/javadoc/server/Bots/package-summary.html @@ -0,0 +1,140 @@ + + + + + +server.Bots + + + + + + + + +
+ + + + + + + +
+ + +
+

程序包 server.Bots

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/server/Bots/package-tree.html b/doc/javadoc/server/Bots/package-tree.html new file mode 100644 index 0000000..d131976 --- /dev/null +++ b/doc/javadoc/server/Bots/package-tree.html @@ -0,0 +1,135 @@ + + + + + +server.Bots 类分层结构 + + + + + + + + +
+ + + + + + + +
+ + +
+

程序包server.Bots的分层结构

+
+
+

类分层结构

+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/server/Bots/package-use.html b/doc/javadoc/server/Bots/package-use.html new file mode 100644 index 0000000..0df0748 --- /dev/null +++ b/doc/javadoc/server/Bots/package-use.html @@ -0,0 +1,142 @@ + + + + + +程序包 server.Bots的使用 + + + + + + + + +
+ + + + + + + +
+ + +
+

程序包的使用
server.Bots

+
+
+ +
+ +
+ + + + + + + +
+ + + + diff --git a/doc/javadoc/stylesheet.css b/doc/javadoc/stylesheet.css new file mode 100644 index 0000000..98055b2 --- /dev/null +++ b/doc/javadoc/stylesheet.css @@ -0,0 +1,574 @@ +/* Javadoc style sheet */ +/* +Overall document style +*/ + +@import url('resources/fonts/dejavu.css'); + +body { + background-color:#ffffff; + color:#353833; + font-family:'DejaVu Sans', Arial, Helvetica, sans-serif; + font-size:14px; + margin:0; +} +a:link, a:visited { + text-decoration:none; + color:#4A6782; +} +a:hover, a:focus { + text-decoration:none; + color:#bb7a2a; +} +a:active { + text-decoration:none; + color:#4A6782; +} +a[name] { + color:#353833; +} +a[name]:hover { + text-decoration:none; + color:#353833; +} +pre { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; +} +h1 { + font-size:20px; +} +h2 { + font-size:18px; +} +h3 { + font-size:16px; + font-style:italic; +} +h4 { + font-size:13px; +} +h5 { + font-size:12px; +} +h6 { + font-size:11px; +} +ul { + list-style-type:disc; +} +code, tt { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; + margin-top:8px; + line-height:1.4em; +} +dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + padding-top:4px; +} +table tr td dt code { + font-family:'DejaVu Sans Mono', monospace; + font-size:14px; + vertical-align:top; + padding-top:4px; +} +sup { + font-size:8px; +} +/* +Document title and Copyright styles +*/ +.clear { + clear:both; + height:0px; + overflow:hidden; +} +.aboutLanguage { + float:right; + padding:0px 21px; + font-size:11px; + z-index:200; + margin-top:-9px; +} +.legalCopy { + margin-left:.5em; +} +.bar a, .bar a:link, .bar a:visited, .bar a:active { + color:#FFFFFF; + text-decoration:none; +} +.bar a:hover, .bar a:focus { + color:#bb7a2a; +} +.tab { + background-color:#0066FF; + color:#ffffff; + padding:8px; + width:5em; + font-weight:bold; +} +/* +Navigation bar styles +*/ +.bar { + background-color:#4D7A97; + color:#FFFFFF; + padding:.8em .5em .4em .8em; + height:auto;/*height:1.8em;*/ + font-size:11px; + margin:0; +} +.topNav { + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.bottomNav { + margin-top:10px; + background-color:#4D7A97; + color:#FFFFFF; + float:left; + padding:0; + width:100%; + clear:right; + height:2.8em; + padding-top:10px; + overflow:hidden; + font-size:12px; +} +.subNav { + background-color:#dee3e9; + float:left; + width:100%; + overflow:hidden; + font-size:12px; +} +.subNav div { + clear:left; + float:left; + padding:0 0 5px 6px; + text-transform:uppercase; +} +ul.navList, ul.subNavList { + float:left; + margin:0 25px 0 0; + padding:0; +} +ul.navList li{ + list-style:none; + float:left; + padding: 5px 6px; + text-transform:uppercase; +} +ul.subNavList li{ + list-style:none; + float:left; +} +.topNav a:link, .topNav a:active, .topNav a:visited, .bottomNav a:link, .bottomNav a:active, .bottomNav a:visited { + color:#FFFFFF; + text-decoration:none; + text-transform:uppercase; +} +.topNav a:hover, .bottomNav a:hover { + text-decoration:none; + color:#bb7a2a; + text-transform:uppercase; +} +.navBarCell1Rev { + background-color:#F8981D; + color:#253441; + margin: auto 5px; +} +.skipNav { + position:absolute; + top:auto; + left:-9999px; + overflow:hidden; +} +/* +Page header and footer styles +*/ +.header, .footer { + clear:both; + margin:0 20px; + padding:5px 0 0 0; +} +.indexHeader { + margin:10px; + position:relative; +} +.indexHeader span{ + margin-right:15px; +} +.indexHeader h1 { + font-size:13px; +} +.title { + color:#2c4557; + margin:10px 0; +} +.subTitle { + margin:5px 0 0 0; +} +.header ul { + margin:0 0 15px 0; + padding:0; +} +.footer ul { + margin:20px 0 5px 0; +} +.header ul li, .footer ul li { + list-style:none; + font-size:13px; +} +/* +Heading styles +*/ +div.details ul.blockList ul.blockList ul.blockList li.blockList h4, div.details ul.blockList ul.blockList ul.blockListLast li.blockList h4 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList ul.blockList li.blockList h3 { + background-color:#dee3e9; + border:1px solid #d0d9e0; + margin:0 0 6px -8px; + padding:7px 5px; +} +ul.blockList ul.blockList li.blockList h3 { + padding:0; + margin:15px 0; +} +ul.blockList li.blockList h2 { + padding:0px 0 20px 0; +} +/* +Page layout container styles +*/ +.contentContainer, .sourceContainer, .classUseContainer, .serializedFormContainer, .constantValuesContainer { + clear:both; + padding:10px 20px; + position:relative; +} +.indexContainer { + margin:10px; + position:relative; + font-size:12px; +} +.indexContainer h2 { + font-size:13px; + padding:0 0 3px 0; +} +.indexContainer ul { + margin:0; + padding:0; +} +.indexContainer ul li { + list-style:none; + padding-top:2px; +} +.contentContainer .description dl dt, .contentContainer .details dl dt, .serializedFormContainer dl dt { + font-size:12px; + font-weight:bold; + margin:10px 0 0 0; + color:#4E4E4E; +} +.contentContainer .description dl dd, .contentContainer .details dl dd, .serializedFormContainer dl dd { + margin:5px 0 10px 0px; + font-size:14px; + font-family:'DejaVu Sans Mono',monospace; +} +.serializedFormContainer dl.nameValue dt { + margin-left:1px; + font-size:1.1em; + display:inline; + font-weight:bold; +} +.serializedFormContainer dl.nameValue dd { + margin:0 0 0 1px; + font-size:1.1em; + display:inline; +} +/* +List styles +*/ +ul.horizontal li { + display:inline; + font-size:0.9em; +} +ul.inheritance { + margin:0; + padding:0; +} +ul.inheritance li { + display:inline; + list-style:none; +} +ul.inheritance li ul.inheritance { + margin-left:15px; + padding-left:15px; + padding-top:1px; +} +ul.blockList, ul.blockListLast { + margin:10px 0 10px 0; + padding:0; +} +ul.blockList li.blockList, ul.blockListLast li.blockList { + list-style:none; + margin-bottom:15px; + line-height:1.4; +} +ul.blockList ul.blockList li.blockList, ul.blockList ul.blockListLast li.blockList { + padding:0px 20px 5px 10px; + border:1px solid #ededed; + background-color:#f8f8f8; +} +ul.blockList ul.blockList ul.blockList li.blockList, ul.blockList ul.blockList ul.blockListLast li.blockList { + padding:0 0 5px 8px; + background-color:#ffffff; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockList { + margin-left:0; + padding-left:0; + padding-bottom:15px; + border:none; +} +ul.blockList ul.blockList ul.blockList ul.blockList li.blockListLast { + list-style:none; + border-bottom:none; + padding-bottom:0; +} +table tr td dl, table tr td dl dt, table tr td dl dd { + margin-top:0; + margin-bottom:1px; +} +/* +Table styles +*/ +.overviewSummary, .memberSummary, .typeSummary, .useSummary, .constantsSummary, .deprecatedSummary { + width:100%; + border-left:1px solid #EEE; + border-right:1px solid #EEE; + border-bottom:1px solid #EEE; +} +.overviewSummary, .memberSummary { + padding:0px; +} +.overviewSummary caption, .memberSummary caption, .typeSummary caption, +.useSummary caption, .constantsSummary caption, .deprecatedSummary caption { + position:relative; + text-align:left; + background-repeat:no-repeat; + color:#253441; + font-weight:bold; + clear:none; + overflow:hidden; + padding:0px; + padding-top:10px; + padding-left:1px; + margin:0px; + white-space:pre; +} +.overviewSummary caption a:link, .memberSummary caption a:link, .typeSummary caption a:link, +.useSummary caption a:link, .constantsSummary caption a:link, .deprecatedSummary caption a:link, +.overviewSummary caption a:hover, .memberSummary caption a:hover, .typeSummary caption a:hover, +.useSummary caption a:hover, .constantsSummary caption a:hover, .deprecatedSummary caption a:hover, +.overviewSummary caption a:active, .memberSummary caption a:active, .typeSummary caption a:active, +.useSummary caption a:active, .constantsSummary caption a:active, .deprecatedSummary caption a:active, +.overviewSummary caption a:visited, .memberSummary caption a:visited, .typeSummary caption a:visited, +.useSummary caption a:visited, .constantsSummary caption a:visited, .deprecatedSummary caption a:visited { + color:#FFFFFF; +} +.overviewSummary caption span, .memberSummary caption span, .typeSummary caption span, +.useSummary caption span, .constantsSummary caption span, .deprecatedSummary caption span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + padding-bottom:7px; + display:inline-block; + float:left; + background-color:#F8981D; + border: none; + height:16px; +} +.memberSummary caption span.activeTableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#F8981D; + height:16px; +} +.memberSummary caption span.tableTab span { + white-space:nowrap; + padding-top:5px; + padding-left:12px; + padding-right:12px; + margin-right:3px; + display:inline-block; + float:left; + background-color:#4D7A97; + height:16px; +} +.memberSummary caption span.tableTab, .memberSummary caption span.activeTableTab { + padding-top:0px; + padding-left:0px; + padding-right:0px; + background-image:none; + float:none; + display:inline; +} +.overviewSummary .tabEnd, .memberSummary .tabEnd, .typeSummary .tabEnd, +.useSummary .tabEnd, .constantsSummary .tabEnd, .deprecatedSummary .tabEnd { + display:none; + width:5px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .activeTableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + float:left; + background-color:#F8981D; +} +.memberSummary .tableTab .tabEnd { + display:none; + width:5px; + margin-right:3px; + position:relative; + background-color:#4D7A97; + float:left; + +} +.overviewSummary td, .memberSummary td, .typeSummary td, +.useSummary td, .constantsSummary td, .deprecatedSummary td { + text-align:left; + padding:0px 0px 12px 10px; +} +th.colOne, th.colFirst, th.colLast, .useSummary th, .constantsSummary th, +td.colOne, td.colFirst, td.colLast, .useSummary td, .constantsSummary td{ + vertical-align:top; + padding-right:0px; + padding-top:8px; + padding-bottom:3px; +} +th.colFirst, th.colLast, th.colOne, .constantsSummary th { + background:#dee3e9; + text-align:left; + padding:8px 3px 3px 7px; +} +td.colFirst, th.colFirst { + white-space:nowrap; + font-size:13px; +} +td.colLast, th.colLast { + font-size:13px; +} +td.colOne, th.colOne { + font-size:13px; +} +.overviewSummary td.colFirst, .overviewSummary th.colFirst, +.useSummary td.colFirst, .useSummary th.colFirst, +.overviewSummary td.colOne, .overviewSummary th.colOne, +.memberSummary td.colFirst, .memberSummary th.colFirst, +.memberSummary td.colOne, .memberSummary th.colOne, +.typeSummary td.colFirst{ + width:25%; + vertical-align:top; +} +td.colOne a:link, td.colOne a:active, td.colOne a:visited, td.colOne a:hover, td.colFirst a:link, td.colFirst a:active, td.colFirst a:visited, td.colFirst a:hover, td.colLast a:link, td.colLast a:active, td.colLast a:visited, td.colLast a:hover, .constantValuesContainer td a:link, .constantValuesContainer td a:active, .constantValuesContainer td a:visited, .constantValuesContainer td a:hover { + font-weight:bold; +} +.tableSubHeadingColor { + background-color:#EEEEFF; +} +.altColor { + background-color:#FFFFFF; +} +.rowColor { + background-color:#EEEEEF; +} +/* +Content styles +*/ +.description pre { + margin-top:0; +} +.deprecatedContent { + margin:0; + padding:10px 0; +} +.docSummary { + padding:0; +} + +ul.blockList ul.blockList ul.blockList li.blockList h3 { + font-style:normal; +} + +div.block { + font-size:14px; + font-family:'DejaVu Serif', Georgia, "Times New Roman", Times, serif; +} + +td.colLast div { + padding-top:0px; +} + + +td.colLast a { + padding-bottom:3px; +} +/* +Formatting effect styles +*/ +.sourceLineNo { + color:green; + padding:0 30px 0 0; +} +h1.hidden { + visibility:hidden; + overflow:hidden; + font-size:10px; +} +.block { + display:block; + margin:3px 10px 2px 0px; + color:#474747; +} +.deprecatedLabel, .descfrmTypeLabel, .memberNameLabel, .memberNameLink, +.overrideSpecifyLabel, .packageHierarchyLabel, .paramLabel, .returnLabel, +.seeLabel, .simpleTagLabel, .throwsLabel, .typeNameLabel, .typeNameLink { + font-weight:bold; +} +.deprecationComment, .emphasizedPhrase, .interfaceName { + font-style:italic; +} + +div.block div.block span.deprecationComment, div.block div.block span.emphasizedPhrase, +div.block div.block span.interfaceName { + font-style:normal; +} + +div.contentContainer ul.blockList li.blockList h2{ + padding-bottom:0px; +} diff --git a/lib/Ab.jar b/lib/Ab.jar new file mode 100644 index 0000000..3445349 Binary files /dev/null and b/lib/Ab.jar differ diff --git a/lib/java-json.jar b/lib/java-json.jar new file mode 100644 index 0000000..2f211e3 Binary files /dev/null and b/lib/java-json.jar differ diff --git a/lib/jl1.0.1.jar b/lib/jl1.0.1.jar new file mode 100644 index 0000000..bd5fb8b Binary files /dev/null and b/lib/jl1.0.1.jar differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..0584384 --- /dev/null +++ b/pom.xml @@ -0,0 +1,40 @@ + + 4.0.0 + ChatClient + ChatClient + 0.0.1-SNAPSHOT + + src + + + maven-compiler-plugin + 3.7.0 + + 1.8 + 1.8 + + + + + + + net.bramp.ffmpeg + ffmpeg + 0.6.2 + + + com.github.axet + vget + 1.1.34 + + + Ab + com.google + 0.0.4.3 + system + ${basedir}/lib/Ab.jar + + + \ No newline at end of file diff --git a/src/client/ChatBotView.java b/src/client/ChatBotView.java new file mode 100644 index 0000000..a40cdab --- /dev/null +++ b/src/client/ChatBotView.java @@ -0,0 +1,297 @@ +package client; + +/** + * A view for the chat client. + * + * @author Mingjun Zha, Minh Bui + */ + +import java.io.File; +import javafx.animation.KeyFrame; +import javafx.animation.Timeline; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.fxml.FXML; + +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.canvas.Canvas; +import javafx.scene.canvas.GraphicsContext; +import javafx.scene.control.Button; +import javafx.scene.control.Label; + +import javafx.scene.control.TextArea; +import javafx.scene.control.TextField; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; +import javafx.scene.text.Text; +import javafx.scene.web.WebView; +import javafx.stage.Stage; +import javafx.util.Duration; + + +public class ChatBotView extends Stage { + private MusicThread msThread; + private Thread actualMsThread; + + private int boardlength = 1150; + private int boardwidth = 500; + private int buttonwidth = 100; + private Label username = null;// username text field + + // private Button connect; + private Button clear; + private TextArea chatboard; + private Button SendButton; // the send button + private TextField message; // the message we want to sent + + private String userName; + private ChatServerThread server; + + private Canvas canvas; + private GraphicsContext gc; + int initialX; + int initialY; + @FXML + private ImageView imageviewNBA; + private ImageView imageviewMus; + private ImageView imageviewLOL; + private ImageView imageviewLip; + private Image nba; + private Image music; + private Image makeup; + private Image lol; + + /** + * For some reasons this is never called with + * + * Application.launch(view.getClass(), args); + * + * That line above always call the default constructor. We no default + * constructor is found, Java throws off some weird errors. + * + * @param hostName + * @param portNumber + */ + public ChatBotView(String hostName, int portNumber, String userName, ChatServerThread server) { + this.server = server; + this.userName = userName; + + this.setTitle("Chat client"); + BorderPane pane = new BorderPane(); + Scene scene = new Scene(pane, boardlength, boardwidth); + pane.setCenter(images()); + messageEvent(); + + this.setScene(scene); + this.setResizable(true); + + this.show(); + + this.setOnCloseRequest(e -> { + server.close(); + }); + + this.setScene(scene); + + } + + public ChatBotView() { + + } + + public VBox layout() { + HBox buttons = buttonset();// setting the buttonset + VBox chatAndSend = Initchatboard();// initialized chatboard + VBox Layout = new VBox(buttons, chatAndSend); + Layout.setVgrow(chatAndSend, Priority.ALWAYS); + Layout.setPadding(new Insets(30, 40, 20, 20)); + Layout.setSpacing(20); + return Layout; + } + public HBox images() { + //this.GIF(); + canvas = new Canvas(100,500); + gc = canvas.getGraphicsContext2D(); + + Timeline timeline = new Timeline(new KeyFrame(Duration.millis(300), + new AnimationHandler())); + timeline.setCycleCount(timeline.INDEFINITE); + timeline.play(); + +// VBox vb = new VBox(imageviewNBA,imageviewMus,imageviewLip,imageviewLOL); +// vb.setVgrow(imageviewNBA, Priority.ALWAYS); +// vb.setVgrow(imageviewMus, Priority.ALWAYS); +// vb.setVgrow(imageviewLip, Priority.ALWAYS); +// vb.setVgrow(imageviewLOL, Priority.ALWAYS); + //vb.setSpacing(20); + VBox layou = layout(); + HBox hb = new HBox(canvas,layou); + hb.setHgrow(canvas, Priority.ALWAYS); + hb.setHgrow(layou, Priority.ALWAYS); + hb.setPadding(new Insets(10,10,10,10)); + return hb; + } + + private class AnimationHandler implements EventHandler { + /* + * /public AnimationHandler() { System.out.println("here"); + * gc.drawImage(nba,0,0); gc.clearRect(0, 0, 100, 100); gc.drawImage(nba,0,0); + * + * } + */ + int tick = 0; + + @Override + public void handle(ActionEvent arg0) { + tick++; + if (tick > 0) { + gc.drawImage(nba, 0, 0); + + } + if (tick > 8) { + gc.clearRect(0, 0, 100, 100); + gc.drawImage(lol, 0, 120); + } + if (tick > 16) { + gc.clearRect(0, 120, 100, 100); + gc.drawImage(makeup, 0, 240); + } + if (tick > 24) { + gc.clearRect(0, 240, 100, 100); + gc.drawImage(music, 0, 360); + } + if (tick >= 30) { + gc.clearRect(0, 360, 100, 100); + tick = 1; + } + + } + + } + +// public void GIF() { +// imageviewNBA = new ImageView(); +// imageviewMus = new ImageView(); +// imageviewLOL = new ImageView(); +// imageviewLip = new ImageView(); +// nba = new Image(new File("nba.gif").toURI().toString()); +// lol = new Image(new File("lol.gif").toURI().toString()); +// makeup = new Image(new File("makeup.gif").toURI().toString()); +// music = new Image(new File("music.gif").toURI().toString()); +// imageviewNBA.setImage(nba); +// imageviewMus.setImage(music); +// imageviewLOL.setImage(lol); +// imageviewLip.setImage(makeup); +// +// } + + public HBox buttonset() { + clear = new Button("Clear"); + clear.setOnAction(event -> { + chatboard.clear(); + + }); + clear.setPrefWidth(buttonwidth); + HBox user = usernameBox(); + HBox buttonSet = new HBox(user, clear); + buttonSet.setHgrow(user, Priority.ALWAYS); + buttonSet.setSpacing(700); + return buttonSet; + } + + public HBox usernameBox() { + Text user = new Text("Username: "); + username = new Label(userName); + HBox userset = new HBox(user, username); + return userset; + } + + public VBox Initchatboard() { + chatboard = new TextArea(); + chatboard.setPrefHeight(300); + chatboard.setPrefWidth(500); + chatboard.setEditable(false); + message = new TextField(); + message.setPrefWidth(445); + SendButton = new Button("Send"); + SendButton.setPrefWidth(50); + HBox hb = new HBox(message, SendButton); + VBox vb = new VBox(chatboard, hb); + hb.setHgrow(message, Priority.ALWAYS); + vb.setVgrow(chatboard, Priority.ALWAYS); + vb.setSpacing(30); + return vb; + } + + public void messageEvent() { + message.setOnAction(event -> { + if (message.getText() != null) { + + String chat = message.getText(); + if (chat != null && !chat.isEmpty()) + server.addMsg(chat); + message.setText(""); + + } + }); + SendButton.setOnAction(events -> { + if (message.getText() != null) { + + String chat = message.getText(); + if (chat != null && !chat.isEmpty()) + server.addMsg(chat); + message.setText(""); + + } + }); + } + + public void appendMessage(String msg) { + chatboard.appendText(msg + "\n"); + } + + public void openURL(String url) { + Stage newStage = new Stage(); + WebView webview = new WebView(); + webview.getEngine().load(url); + webview.setPrefSize(640, 390); + newStage.setScene(new Scene(webview)); + newStage.show(); + } + + public void pauseMusic() { + if (msThread != null) + msThread.pause(); + } + + public void resumeMusic() { + if (msThread != null) { + Thread actualMsThread = new Thread(msThread); + actualMsThread.start(); + } + } + + public void playMusic(String name) { + String musicFile = "./SampleMusic/" + name; // For example + if (msThread == null) { + msThread = new MusicThread(musicFile); + actualMsThread = new Thread(msThread); + actualMsThread.start(); + } else { + try { + if (msThread.isPlaying()) + msThread.pause(); + } catch (Exception e) { + + } + msThread = new MusicThread(musicFile); + actualMsThread = new Thread(msThread); + actualMsThread.start(); + } + } +} \ No newline at end of file diff --git a/src/client/ChatClient.java b/src/client/ChatClient.java new file mode 100644 index 0000000..92b7189 --- /dev/null +++ b/src/client/ChatClient.java @@ -0,0 +1,16 @@ +package client; +import javafx.application.Application; +import javafx.stage.Modality; +import client.SignInView; + +public class ChatClient { + public static void main(String[] args){ + try { + Application.launch(SignInView.class); + } catch (Exception e) { + e.printStackTrace(System.err); + System.exit(1); + } + + } +} diff --git a/src/client/ChatServerThread.java b/src/client/ChatServerThread.java new file mode 100644 index 0000000..1ca8865 --- /dev/null +++ b/src/client/ChatServerThread.java @@ -0,0 +1,226 @@ +package client; + +/** + * ChatServerThread.java + * Handles I/O from client to server. + */ + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.net.Socket; +import java.util.LinkedList; +import java.util.Queue; + +import javafx.application.Platform; +import javafx.scene.control.Alert; +import javafx.scene.paint.Color; +import server.Response; + +import server.User; + +public class ChatServerThread implements Runnable { + + private Socket socket; + private User user; + // private final LinkedList pendingMsgs; + // private Queue viewPendingMsgs; + private String msg; + private boolean hasMsgs = false; + + private ObjectOutputStream objOut; + private ObjectInputStream objIn; + + // Reference to update the GUI once there's response from server. + private ChatBotView view; + private SignInView signInView; + private SignUpView signUpView; + + public ChatServerThread(ChatBotView view, SignInView siView, SignUpView suView, Socket socket, User user) { + this.view = view; + signInView = siView; + signUpView = suView; + this.socket = socket; + // pendingMsgs = new LinkedList(); + // viewPendingMsgs = new LinkedList(); + this.user = user; + } + + /** + * Called when closing connection. + */ + public void close() { + try { + if (objOut != null) + objOut.close(); + if (objIn != null) + objIn.close(); + if (socket != null) { + socket.close(); + } + } catch (IOException e) { + // TODO Auto-generated catch block + + } + } + + /** + * Push a pending message onto the stack. The reason behind this is we want to + * save every message sent by this client. + * + * @param msg + */ + public void addMsg(String msg) { + hasMsgs = true; + this.msg = msg; + } + + /** + * Prompts this thread to send user object to the server. + * + * @param user + */ + public void sendUserObject(User user) { + synchronized (user) { + this.user = user; + try { + objOut.writeObject(user); + objOut.flush(); + } catch (IOException e) { + + } + } + } + + public Response recvResponse() { + Response res = null; + // Keep reading Response from the server until it's not null. + while (res == null) { + try { + res = (Response) objIn.readObject(); + return res; + } catch (Exception e) { + e.printStackTrace(); + } + } + return null; + } + + @Override + public void run() { + try { + System.out.println(Thread.currentThread().getName() + " is a ChatServerThread and is running."); + objOut = new ObjectOutputStream(socket.getOutputStream()); + objIn = new ObjectInputStream(socket.getInputStream()); + Response oldRes = null; + while (!socket.isClosed()) { + if (socket.getInputStream().available() > 0) { + Response res = recvResponse(); + // If this client's user object is already signed in, + // then response from the server is a broadcasted message. + // Allow user to send/receive message from the server. + if (user.getUserCode() == User.UserCode.signedInUser && view != null) { + // sendUserObject(user); + + view.appendMessage(res.getMessage()); + + // URL/music pulling feature. + if (res.getData() != null && !res.getData().isEmpty()) { + String data = res.getData(); + String msg = res.getMessage(); + boolean isUrl = res.isUrl(); + Platform.runLater(new Runnable() { + public void run() { + if (!isUrl) { + if (data.equals("pause")) + view.pauseMusic(); + else if (data.equals("resume")) + view.resumeMusic(); + else { + view.playMusic(data); + } + } else { + view.openURL(data); + } + } + }); + } + // This means this thread is sending an User object to the server + // for verification with the database. If the credential match, + // change the user's status of signing in to signed in and update the GUI. + } else if (user.getUserCode() == User.UserCode.signingInUser && !res.equals(oldRes)) { + if (res.isOK()) { + this.user.setUserCode(User.UserCode.signedInUser); + Platform.runLater(new Runnable() { + + public void run() { + view = signInView.successSignedIn(); + } + }); + } else { + // Shoot a message dialog to the signInView saying that + // the server doesn't recognize the user's credential. + + Platform.runLater(new Runnable() { + public void run() { + signInView.signInFail(); + } + }); + } + oldRes = res; + } else if (this.user.getUserCode() == User.UserCode.signingUpUser && !res.equals(oldRes)) { + // This means this thread is trying to create a new User within the server + // database. + // If res.isOk() returns false, it means the server can't find the user. If so, + // proceed with updating + // the GUI. Else make the GUI pop up an error message. + if (!res.isOK()) { + // If this user's not in the database. + // this.user.setUserCode(User.UserCode.signingInUser); + Platform.runLater(new Runnable() { + + public void run() { + signUpView = signInView.getSignUpView(); + signUpView.signUpSuccess(); + signUpView.close(); + } + }); + } else { + // The user's already in the database. Notify the sign up view. + Platform.runLater(new Runnable() { + public void run() { + signUpView = signInView.getSignUpView(); + signUpView.signUpFail(); + } + }); + } + oldRes = res; + } + } + + if (hasMsgs) { + String nextMsg = msg; + hasMsgs = !hasMsgs; + + String wholeMsg = "[" + user.getHandle() + "] " + nextMsg; + // out.writeUTF(wholeMsg); + // out.flush(); + + objOut.writeObject(new Response(wholeMsg, null)); + objOut.flush(); + } + } + this.close(); + } catch (IOException e) { + System.out.println("You have been disconnected from server."); + this.close(); + + Platform.runLater(new Runnable() { + public void run() { + new Alert(Alert.AlertType.WARNING, "Disconnected from server.").showAndWait(); + } + }); + + } + } +} \ No newline at end of file diff --git a/src/client/MusicThread.java b/src/client/MusicThread.java new file mode 100644 index 0000000..5d97539 --- /dev/null +++ b/src/client/MusicThread.java @@ -0,0 +1,81 @@ +package client; + +import java.io.BufferedInputStream; +import java.io.FileInputStream; +import java.io.FileNotFoundException; + +import javazoom.jl.decoder.JavaLayerException; +import javazoom.jl.player.advanced.AdvancedPlayer; +import javazoom.jl.player.advanced.PlaybackEvent; +import javazoom.jl.player.advanced.PlaybackListener; + +public class MusicThread implements Runnable { + + private AdvancedPlayer player; + + private int pausedOnFrame; + + private String path; + + private boolean isPlaying; + + public boolean isPlaying() { + return isPlaying; + } + + + public String getPath() { + return path; + } + + + public MusicThread(String name) { + try { + path = name; + pausedOnFrame = 0; + isPlaying = false; + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void run() { + try { + newTrack(); + System.out.println("Playing " + path + " from frame: " + pausedOnFrame); + isPlaying = true; + player.play(pausedOnFrame, Integer.MAX_VALUE); + } catch (JavaLayerException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public void pause() { + if (player != null) + player.stop(); + } + + private void newTrack() { + try { + FileInputStream fis = new FileInputStream(path); + this.player = new AdvancedPlayer(new BufferedInputStream(fis)); + player.setPlayBackListener(new PlaybackListener() { + @Override + public void playbackFinished(PlaybackEvent event) { + pausedOnFrame = event.getFrame(); + System.out.println("Track: " + path + " paused on frame: " + pausedOnFrame); + isPlaying = false; + } + }); + } catch (JavaLayerException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (FileNotFoundException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + +} diff --git a/src/client/SignInView.java b/src/client/SignInView.java new file mode 100644 index 0000000..f8e688a --- /dev/null +++ b/src/client/SignInView.java @@ -0,0 +1,165 @@ +package client; + +import java.io.IOException; +import java.net.Socket; +import java.net.UnknownHostException; +import client.ChatBotView; +import javafx.application.Application; +import javafx.application.Platform; +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.control.Alert; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.PasswordField; +import javafx.scene.control.TextField; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.stage.Stage; +import server.User; + +public class SignInView extends Application { + private String hostName = "localhost"; + private int portNumber = 4000; + + private String userName; + private ChatServerThread clientThread; + private Socket socket; + private ChatBotView chatView; + private SignUpView signUpView; + + private Stage priStage; + private Label connectionStatus; + + public Label getConnectionStatus() { + return connectionStatus; + } + + public void setConnectionStatus(Label connectionStatus) { + this.connectionStatus = connectionStatus; + } + + @Override + public void start(Stage primaryStage) throws Exception { + priStage = primaryStage; + VBox signInWindow = new VBox(30); + signInWindow.setPrefHeight(200); + signInWindow.setPrefWidth(350); + signInWindow.setPadding(new Insets(35, 30, 35, 45)); + signInWindow.setStyle("-fx-background-color: white"); + Scene scene = new Scene(signInWindow); + + Label welcome = new Label("\t Welcom to the CHATBOT!"); + connectionStatus = new Label("\t\t Offline"); + connectionStatus.setTextFill(Color.RED); + + HBox userName = new HBox(); + Label userNameLabel = new Label("USERNAME:\t"); + TextField userNameText = new TextField(); + userName.getChildren().addAll(userNameLabel, userNameText); + + HBox password = new HBox(); + Label passwordLabel = new Label("PASSWORD:\t"); + PasswordField passwordText = new PasswordField(); + password.getChildren().addAll(passwordLabel, passwordText); + + HBox button = new HBox(120); + Button signIn = new Button("SIGN IN"); + Button signUp = new Button("SIGN UP"); + button.getChildren().addAll(signIn, signUp); + + signIn.setOnAction(MouseClicked -> { + if (socket != null && socket.isConnected()) { + User signingInUser = new User(); + this.userName = userNameText.getText(); + signingInUser.setPassword(passwordText.getText()); + signingInUser.setHandle(userNameText.getText()); + signingInUser.setUserCode(User.UserCode.signingInUser); + clientThread.sendUserObject(signingInUser); + } + }); + + signUp.setOnAction(MouseClicked -> { + signUpView = new SignUpView(clientThread, socket); + signUpView.show(); + }); + + signInWindow.getChildren().addAll(welcome, connectionStatus, userName, password, button); + + primaryStage.setScene(scene); + primaryStage.setTitle("SignIn"); + primaryStage.show(); + + Thread connectingThread = new Thread(new Runnable() { + + @Override + public void run() { + System.out.println(Thread.currentThread().getName() + " is a connectingThread and is running."); + + try { + while (true) { + while (socket == null || !socket.isConnected() || socket.isClosed()) { + connectServer(); + Thread.sleep(7000); + } + + + } + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + System.out.println(Thread.currentThread().getName() + " is a connectingThread and is done."); + } + }); + + connectingThread.start(); + + } + + public SignUpView getSignUpView() { + return this.signUpView; + } + + public ChatBotView getChatBotView() { + return chatView; + } + + public ChatBotView successSignedIn() { + System.out.println("Log on success!"); + chatView = new ChatBotView(hostName, portNumber, userName, clientThread); + priStage.close(); + return chatView; + } + + public void backToSignIn() { + priStage.show(); + } + + public void signInFail() { + new Alert(Alert.AlertType.WARNING, "user not found or wrong password").showAndWait(); + System.out.println("User not found or wrong password"); + } + + public void connectServer() { + try { + socket = new Socket(hostName, portNumber); + User user = new User(userName, socket); + + clientThread = new ChatServerThread(chatView, this, signUpView, socket, user); + Thread actualClientThread = new Thread(clientThread); + actualClientThread.start(); + + Platform.runLater(new Runnable() { + public void run() { + connectionStatus.setTextFill(Color.GREEN); + connectionStatus.setText("\t\t Online"); + } + }); + } catch (UnknownHostException e) { + } catch (IOException e) { + } + } +} diff --git a/src/client/SignUpView.java b/src/client/SignUpView.java new file mode 100644 index 0000000..dd9b8f1 --- /dev/null +++ b/src/client/SignUpView.java @@ -0,0 +1,117 @@ +package client; + +import java.net.Socket; + +import javafx.geometry.Insets; +import javafx.scene.Scene; +import javafx.scene.control.Alert; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import javafx.stage.Stage; +import server.User; + +public class SignUpView extends Stage { + Button ok; + Button cancel; + private ChatServerThread clientThread; + private Socket socket; + + public SignUpView(ChatServerThread clientThread, Socket socket) { + super(); + this.clientThread = clientThread; + this.socket = socket; + VBox signInWindow = new VBox(30); + + signInWindow.setPadding(new Insets(35, 30, 35, 45)); + signInWindow.setStyle("-fx-background-color: white"); + Scene scene = new Scene(signInWindow); + + HBox userName = new HBox(); + Label userNameLabel = new Label("USERNAME*:\t"); + TextField userNameText = new TextField(); + userName.getChildren().addAll(userNameLabel, userNameText); + + HBox password = new HBox(); + Label passwordLabel = new Label("PASSWORD*:\t"); + TextField passwordText = new TextField(); + password.getChildren().addAll(passwordLabel, passwordText); + + HBox name = new HBox(); + Label firstName = new Label("First Name:\t"); + TextField firstNameText = new TextField(); + Label LastName = new Label("Last Name:\t"); + TextField lastNameText = new TextField(); + name.getChildren().addAll(firstName, firstNameText, LastName, lastNameText); + + HBox age = new HBox(); + Label userAge = new Label("AGE: \t"); + TextField userAgeText = new TextField(); + age.getChildren().addAll(userAge, userAgeText); + + HBox major = new HBox(); + Label userMajor = new Label("MAJOR: \t"); + TextField userMajorText = new TextField(); + major.getChildren().addAll(userMajor, userMajorText); + + HBox button = new HBox(120); + ok = new Button("OK"); + ok.setOnAction(MouseClicked -> { + if (this.socket != null && this.socket.isConnected()) { + if ((userNameText.getText() == null || userNameText.getText().isEmpty()) || + (passwordText.getText() == null || passwordText.getText() == null) || + (userAgeText.getText() == null || userAgeText.getText() == null) || + (firstNameText.getText() == null || lastNameText.getText() == null) || + (userAgeText.getText() == null || userAgeText.getText() == null) || + (userMajorText.getText() == null || userMajorText.getText() == null)) + new Alert(Alert.AlertType.ERROR, "Please fill out all fields.").showAndWait(); + else + okAction(userNameText.getText(), passwordText.getText(), firstNameText.getText(), + lastNameText.getText(), userAgeText.getText(), userMajorText.getText()); + } + }); + cancel = new Button("Cancel"); + cancel.setOnAction(MouseClicked -> { + this.close(); + }); + button.getChildren().addAll(ok, cancel); + + signInWindow.getChildren().addAll(userName, password, name, age, major, button); + + this.setScene(scene); + this.setTitle("SignUp"); + } + + /** + * Prompts the client to send new user information to the server. + * + * @param userName + * @param password + * @param firstName + * @param lastName + * @param age + * @param major + */ + public void okAction(String userName, String password, String firstName, String lastName, String age, + String major) { + User newUser = new User(userName, password, firstName, lastName, age, major); + newUser.setUserCode(User.UserCode.signingUpUser); + clientThread.sendUserObject(newUser); + } + + /** + * Called when signing up fails. + */ + public void signUpFail() { + new Alert(Alert.AlertType.INFORMATION, "User name has been used").showAndWait(); + System.out.println("Sign up failed."); + } + + public void signUpSuccess() { + new Alert(Alert.AlertType.INFORMATION, "Sign up successfull. Please log in with the new account.").showAndWait(); + System.out.println("Sign up successfull."); + } + +} \ No newline at end of file diff --git a/src/server/Bots/Bot.java b/src/server/Bots/Bot.java new file mode 100644 index 0000000..cca8ac2 --- /dev/null +++ b/src/server/Bots/Bot.java @@ -0,0 +1,197 @@ +package server.Bots; + +import java.io.File; +import java.io.IOException; +import java.util.AbstractMap; +import java.util.HashMap; +import java.util.List; +import java.util.Scanner; + +import org.alicebot.ab.Chat; +import org.alicebot.ab.History; +import org.alicebot.ab.MagicBooleans; +import org.alicebot.ab.MagicStrings; +import org.alicebot.ab.utils.IOUtils; + +import server.ChatClientThread; +import server.Response; + +import server.User; + +/** + * This bot class implements basic functionality of the chat bot. Note that this + * class should never be instantiated. Whenever we need to create a chat bot, + * instantiate a new bot object that extends this class, for example: + * + * Bot newBot = new MinhsBot(); + * + * @author Minh Bui + */ + +public abstract class Bot { + + // A map of commands with the command names as keys and commands' parameters as + // values. + private static AbstractMap defaultCommandsList; + + // A character that identify the + private char botCharacterId; + + private static final boolean TRACE_MODE = false; + static String botName = "super"; + + private static org.alicebot.ab.Bot bot; + + private static Chat chatSession; + /** + * constructor + */ + public Bot() { + + String resourcesPath = getResourcesPath(); + MagicBooleans.trace_mode = TRACE_MODE; + bot = new org.alicebot.ab.Bot("super", resourcesPath); + // bot.writeAIMLFiles(); + chatSession = new Chat(bot); + + botCharacterId = '!'; + defaultCommandsList = new HashMap<>(); + defaultCommandsList.put("help", " - list out the available commands for the current bot. "); + defaultCommandsList.put("info", "[USER] - prints out the information of User."); + defaultCommandsList.put("date", " - prints out the current date."); + defaultCommandsList.put("whoami", " - prints out the user's client info such as IP addresses, ..."); + defaultCommandsList.put("ttm", " - abbreviation for \"talk to me\"."); + defaultCommandsList.put("geturl", "[URL] - pull web resource through url."); + } + + /** + * + * @return A string containing a list of available commands and their usage. + */ + public String helpCommand() { + String helpCommandStr = "List of available commands: \n"; + for (String command : defaultCommandsList.keySet()) { + helpCommandStr += botCharacterId + command + defaultCommandsList.get(command); + } + + return helpCommandStr; + } + + /** + * @return The bot's handle in the server. + */ + public abstract String getBotSignature(); + + public String infoCommand(String user) { + User userObj = getUserFromDB(user); + String userInfo = "User doesn't exist."; + if (userObj != null) { + userInfo = "\nUser: " + userObj.getHandle(); + userInfo += "\nName: " + userObj.getFirstName() + " " + userObj.getLastName(); + userInfo += "\nAge: " + userObj.getAge(); + userInfo += "\nMajor: " + userObj.getMajor(); + } + return userInfo; + } + /** + * get the user object by using username + * @param userName which is the String value + * @return user + */ + private User getUserFromDB(String userName) { + Scanner sc = null; + User user = null; + try { + File file = new File(new java.io.File(".").getCanonicalPath() + File.separator + "userInfo.txt"); + file.createNewFile(); + sc = new Scanner(file); + while (sc.hasNextLine()) { + String line = sc.nextLine(); + String[] info = line.split(" "); + if (userName.equals(info[0])) { + user = new User(info[0], info[1], info[2], info[3], info[4], info[5]); + } + } + + } catch (IOException e) { + System.out.println(e.getMessage()); + } finally { + if (sc != null) + sc.close(); + } + + return user; + } + + /** + * @return A string representing the current's date. + */ + public abstract String dateCommand(); + + /** + * @return Information about the user such as IP address and connecting client.. + */ + public abstract String whoamiCommand(User user); + + /** + * Every Bot's subclass needs to overwrite this method. + * + * @param message + * @param user + * @return + */ + public abstract Response getResponses(String message, User user, List clients); + + /** + * @return Return a character that identifies this bot. + */ + public char getBotCharacterId() { + return botCharacterId; + } + + /** + * Set the character that identifies this bot to botCharacterId. + * + * @param botCharacterId A character that identifies this bot. + */ + public void setBotCharacterId(char botCharacterId) { + this.botCharacterId = botCharacterId; + } + + /** + * @return An abstract map of default commands as keys and their parameters as + * values. + */ + public AbstractMap getDefaultCommandsList() { + return this.defaultCommandsList; + } + + /** + * Helper method for getSmartResponse. + * + * @return A string path containing the resources for the aiml bot environment. + */ + private static String getResourcesPath() { + File currDir = new File("."); + String path = currDir.getAbsolutePath(); + path = path.substring(0, path.length() - 2); + path += File.separator + "src"; + path += File.separator + "server"; + path += File.separator + "Bots"; + path += File.separator + "resources"; + return path; + } + + /** + * + * @param message + * @param user + * @return + */ + public String getSmartResponse(String message, User user) { + bot.brain.nodeStats(); + String response = chatSession.multisentenceRespond(message); + + return response; + } +} diff --git a/src/server/Bots/LipProducts.java b/src/server/Bots/LipProducts.java new file mode 100644 index 0000000..ccf9ae7 --- /dev/null +++ b/src/server/Bots/LipProducts.java @@ -0,0 +1,284 @@ +package server.Bots; + +import java.util.HashMap; + +/** + * This Program is the store the each LipProducts information and get the Lip products' + * price, rate, and Lip color numbers + * @author Mingjun Zha + * + */ +public class LipProducts { + private String rate = ""; + private String url = ""; + private String price = ""; + private Lipnum Lipnum; + private HashMap> brandsAndCate; // the key is brand, the value is cate + /** + * initializing the Lipproducts depending upon the each brand, and the brand as + * the key into the HashMap, the category as the value. + */ + public LipProducts() { + brandsAndCate = new HashMap<>(); + brandsAndCate.put("Dior", Dior()); + brandsAndCate.put("Giorgio_Armani_beauty", Giorgio_Armani_beauty()); + brandsAndCate.put("Fenty_Beauty_By_Rihanna", Fenty_Beauty_By_Rihanna()); + brandsAndCate.put("Givenchy",Givenchy()); + brandsAndCate.put("Tom_Ford",Tom_Ford()); + brandsAndCate.put("YSL", YSL()); + brandsAndCate.put("Nars",Nars()); + Lipnum = new Lipnum(); //the Lipnum program + + } + /** + * Return a Giorgio_Armani_beauty hashMap that the store the information of the Lip + * products + * @return HashMap, the category as the key, and the price, rate + * list as the value + */ + public HashMap Giorgio_Armani_beauty(){ + HashMap cate = new HashMap<>(); + String cate1 = "Lipstick"; //38 + String cate2 = "LipStain"; //38 + String url2 = "https://www.sephora.com/product/lip-m" + + "aestro-P393411?skuId=1441583&icid2=products%20grid:p393411:product"; + String[] LipStain = {"$38",url2,"4.4 / 5 stars"}; + String url1 = "https://www.sephora.com/product/rouge-d-armani-" + + "matte-lipstick-P436062?icid2=products%20grid:p436062:product"; + String [] Lipstick = {"$38",url1,"4.7 / 5 stars"}; + cate.put(cate1, Lipstick); + cate.put(cate2,LipStain); + return cate; + } + + /** + * Return a Fenty_Beauty_By_Rihanna hashMap that the store the information of the Lip + * products + * + * @return HashMap, the category as the key, and the price, rate + * list as the value + */ + public HashMap Fenty_Beauty_By_Rihanna() { + HashMap cate = new HashMap<>(); + String cate1 = "Lipstick"; //18 + String cate2 = "LipStain"; //24 + String url1 = "https://www.sephora.com/product/mattemoisel" + + "le-plush-matte-lipstick-P45874456?icid2=products%20grid:p45874" + + "456:product"; + String [] Lipstick = {"$18",url1,"4.4 / 5 stars"}; + String url2 = "https://www.sephora.com/product/stunna-lip-paint-P39787" + + "544?icid2=products%20grid:p39787544:product&skuId=2094274"; + String [] LipStain = {"$24",url2,"4.3 / 5 stars"}; + cate.put(cate1, Lipstick); + cate.put(cate2, LipStain); + return cate; + } + /** + * Return a Givenchy hashMap that the store the information of the Lip + * products + * + * @return HashMap, the category as the key, and the price, rate + * list as the value + */ + public HashMap Givenchy() { + HashMap cate = new HashMap<>(); + String cate1 = "Lipstick"; //37 + String cate2 = "LipBalm"; //37 + String url1 = "https://www.sephora.com/product/le-rouge-P3" + + "77755?icid2=products%20grid:p377755:product&skuId=1497536"; + String [] Lipstick = {"$37",url1,"4.5 / 5 stars"}; + String url2 = "https://www.sephora.com/product/l" + + "e-rouge-perfecto-beautifying-lip-balm-P410769?ic" + + "id2=products%20grid:p410769:product"; + String [] LipBalm = {"$37",url2,"4.0 / 5 stars"}; + cate.put(cate1, Lipstick); + cate.put(cate2, LipBalm); + return cate; + } + /** + * Return a Tom_Ford hashMap that the store the information of the Lip + * products + * + * @return HashMap, the category as the key, and the price, rate + * list as the value + */ + public HashMap Tom_Ford() { + HashMap cate = new HashMap<>(); + String cate1 = "Lipstick"; //55 + String cate2 = "LipGloss"; //48 + String url2 = "https://www.sephora.com/product/" + + "ultra-shine-lip-gloss-P422567?icid2=products%20grid:p422567:product"; + String [] LipGloss = {"$48",url2,"4.0 / 5 stars"}; + String url1 = "https://www.sephora.com/product/lip-color-" + + "P416057?icid2=products%20grid:p416057:product&skuId=1917228"; + String [] Lipstick = {"$55",url1,"4.5 / 5 stars"}; + cate.put(cate1, Lipstick); + cate.put(cate2, LipGloss); + return cate; + } + + /** + * Return a YSL hashMap that the store the information of the Lip + * products + * + * @return HashMap, the category as the key, and the price, rate + * list as the value + */ + public HashMap YSL() { + HashMap cate = new HashMap<>();; + String cate1 = "Lipstick"; + String cate2 = "LipStain"; + String url = "https://www.sephora.com/product/" + + "rouge-volupte-shine-oil-in-stick-lipstick-P377710?icid2=" + + "ysl_lipwardrobe_carousel_us_ufe:p377710:product"; + String [] Lipstick = {"$38", url,"4.5 / 5 stars"}; + cate.put(cate1, Lipstick); + url = "https://www.sephora.com/product/glossy-stain-lip-gloss-P304003" + + "?icid2=ysl_lipwardrobe_carousel_us_ufe:p304003:product"; + String [] LipStain = {"$37",url,"4.4 / 5 stars"}; + cate.put(cate2, LipStain); + return cate; + } + /** + * Return a Nars hashMap that the store the information of the Lip + * products + * + * @return HashMap, the category as the key, and the price, rate + * list as the value + */ + public HashMap Nars(){ + HashMap cate = new HashMap<>();; + String cate1 = "Lipstick"; + String cate2 = "LipBalm"; + String cate3 = "LipGloss"; + String url1 = "https://www.sephora.com/product/" + + "audacious-lipstick-P387906?icid2=products%20grid:" + + "p387906:product&skuId=1637164"; + String [] Lipstick = {"$34",url1,"4.6 / 5 stars"}; + String url2 = "https://www.sephora.com/product/" + + "orgasm-afterglow-lip-balm-P13046537?icid2=products%2" + + "0grid:p13046537:product"; + String [] LipBalm = {"$28",url2,"3.9 / 5 stars"}; + String url3 = "https://www.sephora.com/product/" + + "lip-gloss-P386666?icid2=products%20grid:" + + "p386666:product&skuId=1596469"; + String [] LipGloss = {"$26",url3,"4.3 / 5 stars"}; + cate.put(cate1, Lipstick); + cate.put(cate2, LipBalm); + cate.put(cate3, LipGloss); + return cate; + } + /** + * Return a Dior hashMap that the store the information of the Lip + * products + * + * @return HashMap, the category as the key, and the price, rate + * list as the value + */ + public HashMap Dior(){ + HashMap cate = new HashMap<>();; + String cate1 = "Lipstick"; + String cate2 = "LipLiner"; + String cate3 = "LipGlow"; + String url1 = "https://www.sephora.com/" //37 + + "product/rouge-dior-ultra-rouge-lipstick-" + + "P436859?icid2=products%20grid:p436859:product&skuId=2104701"; + String url2 = "https://www.sephora.com/product/rouge-dior-ink-lip-" + + "liner-P436860?skuId=2105070&icid2=dior_whatsnew_us_productca" + + "rousel_ufe:p436860:product"; //32 + String url3 = "https://www.sephora.com/product/dior" + + "-addict-lip-glow-color-reviver-balm-P236816?skuId=2060358&" + + "icid2=dior_lipcollection_us_productcarousel_ufe:p236816:product"; //34 + String [] Lipstick = {"$37",url1,"4.9 / 5 stars"}; + String [] LipLiner = {"$32",url2,"3.8 / 5 stars"}; + String [] LipGlow = {"$34",url3,"4.4 / 5 stars"}; + cate.put(cate1, Lipstick); + cate.put(cate2, LipLiner); + cate.put(cate3, LipGlow); + return cate; + + } + /** + * This function is dpending upon the brand and category to construct the hashmap + * that contains price, url and rate + * @param brand, the brand String + * @param cate, the String category + */ + public void geteverything(String brand,String cate) { + HashMap map; + if(brandsAndCate.containsKey(brand)) { + map = brandsAndCate.get(brand); + if(map.containsKey(cate)) { + price = map.get(cate)[0]; + url = map.get(cate)[1]; + rate = map.get(cate)[2]; + } + else { + price = "NO such category"; + url = "No such category"; + rate = "No such category"; + } + + } + else { + price = "NO such brand"; + url = "No such brand"; + rate = "No such brand"; + } + } + /** + * This function get the brand array into strings + * @return the keySet of the brand + */ + public String getbrand() { + return brandsAndCate.keySet().toString(); + } + /** + * This function get the price array into String + * @return price, the price of the each product + */ + public String getprice() { + return price; + } + /** + * This function get the rate array into String + * @return rate, the rate of the each product + */ + public String getrate() { + return rate; + } + /** + * This function is return the url string + * @return url, the url of each product + */ + public String geturl() { + return url; + } + /** + * getting the color number of specific product + * @param brand, brand String + * @param cate, category String + * @return the color Num String + */ + public String getNum(String brand, String cate) { + return Lipnum.getNum(brand, cate); + } + /** + * This function is return the image url + * @param brand, String brand + * @param cate, String category + * @param num, String color number + * @return imageurl by using the brand, cate and num + */ + public String getImageurl(String brand, String cate, String num) { + return Lipnum.Imageurl(brand, cate, num); + } + /** + * Distinguish if the command is valid that we can get the right url of image + * @return boolean to distinguish the url we can use or not + */ + public boolean Isurl() { + return Lipnum.geturl(); + } + +} diff --git a/src/server/Bots/Lipnum.java b/src/server/Bots/Lipnum.java new file mode 100644 index 0000000..a5e2061 --- /dev/null +++ b/src/server/Bots/Lipnum.java @@ -0,0 +1,511 @@ +package server.Bots; + +import java.util.HashMap; +/** + * This function is the collection for storing the information of color number for + * each brands + * @author Mingjun Zha + * + */ +public class Lipnum { + private HashMap ALipMas; + private HashMap ALipStick; + private HashMap FLipBalm; + private HashMap FLipStick; + private HashMap GLipStick; + private HashMap GLipBalm; + private HashMap TLipStick; + private HashMap TLipGloss; + private HashMap YLipStick; + private HashMap YLipStain; + private HashMap NLipStick; + private HashMap NLipBalm; + private HashMap NLipGloss; + private HashMap DLipStick; + private HashMap DLipLiner; + private HashMap DLipGlow; + private Boolean ISurl = false; + /** + * the constructor of lip num class, initializing each field and execute every + * function + */ + public Lipnum() { + ALipMas = new HashMap<>(); + ALipStick = new HashMap<>(); + FLipBalm = new HashMap<>(); + FLipStick = new HashMap<>(); + GLipStick = new HashMap<>(); + GLipBalm = new HashMap<>(); + TLipStick = new HashMap<>(); + TLipGloss = new HashMap<>(); + YLipStick = new HashMap<>(); + YLipStain = new HashMap<>(); + NLipStick = new HashMap<>(); + NLipBalm = new HashMap<>(); + NLipGloss = new HashMap<>(); + DLipStick = new HashMap<>(); + DLipLiner = new HashMap<>(); + DLipGlow = new HashMap<>(); + this.ArmaniLipNum(); + this.DiorNum(); + this.GivenchyLipNum(); + this.FentyLipnum(); + this.NarsNum(); + this.YSLNum(); + this.Tom_FordNum(); + } + /** + * Store the Armani Lip number into the hashmap, the lipnumber as the key + * the item number as the value + */ + public void ArmaniLipNum() { + ALipMas.put("507", "1755685"); + ALipMas.put("406", "1664275"); + ALipMas.put("508", "1755693"); + ALipMas.put("401", "1441591"); + ALipMas.put("402", "1441609"); + ALipMas.put("504", "1441617"); + ALipMas.put("501", "1441641"); + ALipMas.put("502", "1441658"); + ALipMas.put("200", "1441674"); + ALipMas.put("300", "1441625"); + ALipMas.put("500", "1441633"); + ALipMas.put("201", "1441682"); + ALipMas.put("202", "1441690"); + ALipStick.put("102", "2104255"); + ALipStick.put("103", "2104263"); + ALipStick.put("200", "2104289"); + ALipStick.put("201", "2104297"); + ALipStick.put("301", "2104313"); + ALipStick.put("400", "2104321"); + ALipStick.put("401", "2104339"); + ALipStick.put("402", "2104347"); + ALipStick.put("403", "2104354"); + ALipStick.put("500", "2104362"); + ALipStick.put("501", "2104370"); + ALipStick.put("502", "2104388"); + ALipStick.put("503", "2104396"); + ALipStick.put("506", "2104412"); + ALipStick.put("600", "2104420"); + } + /** + * Store the Fenty Lip number into the hashmap, the lipnumber as the key + * the item number as the value + */ + public void FentyLipnum() { + FLipStick.put("Spanked", "2018224"); + FLipStick.put("Ma'Damn", "2018190"); + FLipStick.put("Candy-Venom", "2018216"); + FLipStick.put("Saw-C", "2018299"); + FLipStick.put("Up-2-No-Good", "2018323"); + FLipStick.put("S1ngle", "2018232"); + FLipStick.put("Freckle-Fiesta", "2018281"); + FLipStick.put("Shawty", "2018315"); + FLipBalm.put("Uncensored", "1925114"); + FLipBalm.put("Unveil", "2094266"); + FLipBalm.put("Uncuffed", "2094274"); + FLipBalm.put("Unbutton", "2094282"); + FLipBalm.put("Uninvited", "2150019"); + } + /** + * Store the Givenchy Lip number into the hashmap, the lipnumber as the key + * the item number as the value + */ + public void GivenchyLipNum() { + GLipStick.put("204", "1602341"); + GLipStick.put("201", "1497502"); + GLipStick.put("301", "1497585"); + GLipStick.put("302", "1602358"); + GLipStick.put("321", "1862028"); + GLipStick.put("324", "1967694"); + GLipBalm.put("01", "1862002"); + GLipBalm.put("02", "2091593"); + GLipBalm.put("03", "2091585"); + GLipBalm.put("04", "2091577"); + } + /** + * Store the Tom_ford Lip number into the hashmap, the lipnumber as the key + * the item number as the value + */ + public void Tom_FordNum() { + TLipStick.put("Naked-Coral", "1917053"); + TLipStick.put("Twist-of-Fate", "1917004"); + TLipStick.put("Flamingo", "1917251"); + TLipStick.put("Scarlet-Rouge", "1917319"); + TLipStick.put("True-Coral", "1917228"); + TLipStick.put("Dressed-To-Kill", "1986959"); + TLipStick.put("Jasmin-Rouge", "1986967"); + TLipStick.put("Cherry-Lush", "1917236"); + TLipGloss.put("01", "1987213"); + TLipGloss.put("02", "1987205"); + TLipGloss.put("03", "1987296"); + TLipGloss.put("04", "1987288"); + TLipGloss.put("05", "1987270"); + TLipGloss.put("06", "1987262"); + TLipGloss.put("07", "1987254"); + TLipGloss.put("08", "1987247"); + TLipGloss.put("09", "1987239"); + TLipGloss.put("10", "1987221"); + + } + /** + * Store the Ysl Lip number into the hashmap, the lipnumber as the key + * the item number as the value + */ + public void YSLNum() { + YLipStick.put("04", "1484773"); + YLipStick.put("06", "1484781"); + YLipStick.put("41", "1811603"); + YLipStick.put("13", "1484849"); + YLipStick.put("43", "1811587"); + YLipStick.put("46", "1811553"); + YLipStick.put("49", "1811520"); + YLipStick.put("51", "1811504"); + YLipStick.put("52", "1811496"); + // lipstain + YLipStain.put("005", "1395193"); + YLipStain.put("007", "1395219"); + YLipStain.put("009", "1395524"); + YLipStain.put("012", "1395250"); + YLipStain.put("046", "1944867"); + YLipStain.put("103", "1511443"); + YLipStain.put("201", "1694496"); + YLipStain.put("204", "1694520"); + + } + /** + * Store the Nars Lip number into the hashmap, the lipnumber as the key + * the item number as the value + */ + public void NarsNum() { + NLipStick.put("Brigitte", "1637156"); + NLipStick.put("Natalie", "1637651"); + NLipStick.put("Juliette", "1637172"); + NLipStick.put("Apoline", "1846872"); + NLipStick.put("Claudia", "1637065"); + NLipStick.put("Greta", "1637602"); + NLipStick.put("Grace", "1637180"); + NLipStick.put("Lana", "1637206"); + NLipBalm.put("Orgasm", "2063758"); + NLipGloss.put("Chelsea-Girls", "1727007"); + NLipGloss.put("Turkish-Delight", "1596444"); + NLipGloss.put("Dolce-Vita", "1596378"); + NLipGloss.put("Orgasm", "1596428"); + NLipGloss.put("Super-Orgasm", "1596402"); + + } + /** + * Store the Dior Lip number into the hashmap, the lipnumber as the key + * the item number as the value + */ + public void DiorNum() { + DLipStick.put("325", "2104800"); + DLipStick.put("450", "2104834"); + DLipStick.put("485", "2104818"); + DLipStick.put("651", "2104859"); + DLipStick.put("660", "2104867"); + DLipStick.put("770", "2104719"); + DLipStick.put("763", "2104883"); + DLipStick.put("777", "2104701"); + DLipLiner.put("028", "2105013"); + DLipLiner.put("434", "2105021"); + DLipLiner.put("770", "2105096"); + DLipLiner.put("777", "2105070"); + DLipLiner.put("851", "2105062"); + DLipLiner.put("999", "2105088"); + DLipGlow.put("101", "2060366"); + DLipGlow.put("001", "1162650"); + DLipGlow.put("004", "1572916"); + DLipGlow.put("007", "2015634"); + DLipGlow.put("005", "1781210"); + + } + /** + * This function is getting the color number by using brand and category + * @param brand + * @param cate + * @return the string of color number + */ + public String getNum(String brand, String cate) { + String num = "NO such brands"; + if (brand.equals("Giorgio_Armani_beauty")) { + if (cate.equals("Lipstick")) { + num = ALipStick.keySet().toString(); + } else if (cate.equals("LipStain")) { + num = ALipMas.keySet().toString(); + } else { + num = "NO such category"; + } + } else if (brand.equals("Fenty_Beauty_By_Rihanna")) { + if (cate.equals("Lipstick")) { + num = FLipStick.keySet().toString(); + } else if (cate.equals("LipStain")) { + num = FLipBalm.keySet().toString(); + } else { + num = "No such category"; + } + } else if (brand.equals("Dior")) { + if (cate.equals("Lipstick")) { + num = DLipStick.keySet().toString(); + } else if (cate.equals("LipLiner")) { + num = DLipLiner.keySet().toString(); + } else if (cate.equals("LipGlow")) { + num = DLipGlow.keySet().toString(); + } else { + num = "NO such category"; + } + } else if (brand.equals("Givenchy")) { + if (cate.equals("Lipstick")) { + num = GLipStick.keySet().toString(); + } else if (cate.equals("LipBalm")) { + num = GLipBalm.keySet().toString(); + } else { + num = "NO such category"; + } + } else if (brand.equals("Tom_Ford")) { + if (cate.equals("Lipstick")) { + num = TLipStick.keySet().toString(); + } else if (cate.equals("LipGloss")) { + num = TLipGloss.keySet().toString(); + } else { + num = "NO such category"; + } + + } else if (brand.equals("YSL")) { + if (cate.equals("Lipstick")) { + num = YLipStick.keySet().toString(); + } else if (cate.equals("LipStain")) { + num = YLipStain.keySet().toString(); + } else { + num = "No such category"; + } + + } else if (brand.equals("Nars")) { + if (cate.equals("Lipstick")) { + num = NLipStick.keySet().toString(); + } else if (cate.equals("LipBalm")) { + num = NLipBalm.keySet().toString(); + } else if (cate.equals("LipGloss")) { + num = NLipGloss.keySet().toString(); + } else { + num = "NO such category"; + } + } + return num; + + } + /** + * The function is using the brand, category and color number to get the image url + * @param brand which is the brand + * @param cate which is the category + * @param num which is the color number + * @return imageurl which is the imageurl of image + */ + public String Imageurl(String brand, String cate, String num) { + String url = "No such Brands"; + if (brand.equals("Giorgio_Armani_beauty")) { + url = "https://www.sephora.com/productimages/sku/s"; + if (cate.equals("Lipstick")) { + if(ALipStick.containsKey(num)) { + url += ALipStick.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else if (cate.equals("LipStain")) { + if(ALipMas.containsKey(num)) { + url += ALipMas.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else { + url = "NO such category"; + ISurl = false; + } + } else if (brand.equals("Fenty_Beauty_By_Rihanna")) { + url = "https://www.sephora.com/productimages/sku/s"; + if (cate.equals("Lipstick")) { + if(FLipStick.containsKey(num)) { + url+= FLipStick.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else if (cate.equals("LipStain")) { + num = FLipBalm.keySet().toString(); + if(FLipBalm.containsKey(num)) { + url += FLipBalm.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else { + url = "No such category"; + ISurl = false; + } + } else if (brand.equals("Dior")) { + url = "https://www.sephora.com/productimages/sku/s"; + if (cate.equals("Lipstick")) { + if(DLipStick.containsKey(num)) { + url += DLipStick.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else if (cate.equals("LipLiner")) { + if(DLipLiner.containsKey(num)) { + url += DLipLiner.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else if (cate.equals("LipGlow")) { + if(DLipGlow.containsKey(num)) { + url += DLipGlow.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else { + url = "NO such category"; + } + } else if (brand.equals("Givenchy")) { + url = "https://www.sephora.com/productimages/sku/s"; + if (cate.equals("Lipstick")) { + if(GLipStick.containsKey(num)) { + url += GLipStick.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else if (cate.equals("LipBalm")) { + if(GLipBalm.containsKey(num)) { + url += GLipBalm.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else { + url = "NO such category"; + ISurl = false; + } + } else if (brand.equals("Tom_Ford")) { + url = "https://www.sephora.com/productimages/sku/s"; + if (cate.equals("Lipstick")) { + if(TLipStick.containsKey(num)) { + url += TLipStick.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else if (cate.equals("LipGloss")) { + if(TLipGloss.containsKey(num)) { + url += TLipGloss.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else { + url = "NO such category"; + ISurl = false; + } + + } else if (brand.equals("YSL")) { + url = "https://www.sephora.com/productimages/sku/s"; + if (cate.equals("Lipstick")) { + if(YLipStick.containsKey(num)) { + url += YLipStick.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else if (cate.equals("LipStain")) { + if(YLipStain.containsKey(num)) { + url += YLipStain.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else { + url = "No such category"; + ISurl = false; + } + + } else if (brand.equals("Nars")) { + url = "https://www.sephora.com/productimages/sku/s"; + if (cate.equals("Lipstick")) { + if(NLipStick.containsKey(num)) { + url += NLipStick.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + + } else if (cate.equals("LipBalm")) { + if(NLipBalm.containsKey(num)) { + url += NLipBalm.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else if (cate.equals("LipGloss")) { + if(NLipGloss.containsKey(num)) { + url += NLipGloss.get(num); + url += "-main-Lhero.jpg"; + ISurl = true; + }else { + url = "No such color number"; + ISurl = false; + } + } else { + url = "No such category"; + ISurl = false; + } + } + else { + ISurl = false; + } + return url; + + } + /** + * distinguish if the url can be valid + * @return isurl which is a boolean value to distinguish if the url can be valid + */ + public Boolean geturl() { + return ISurl; + } + + +} diff --git a/src/server/Bots/MakeupBot.java b/src/server/Bots/MakeupBot.java new file mode 100644 index 0000000..c88c473 --- /dev/null +++ b/src/server/Bots/MakeupBot.java @@ -0,0 +1,234 @@ +package server.Bots; + +import java.text.SimpleDateFormat; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Random; + +import server.Response; +import server.User; +/** + * This is the MakeupBot program which extends the super class Bot. + * MakeupBot totally has 12 commands, except the commands that super class have, it got + * 6 more commands. Depending upon the commands, the bot will give the user some specific + * repsonses that we have already defined. + * @author Mingjun Zha + * + */ +public class MakeupBot extends Bot { + private AbstractMap commandsMap; + private LipProducts lip; + private AbstractMap> commandsCounter; + private String[] category = {"Lipstick","Liquid-Lipstick", "Lip-Stain", "Lip-Gloss","Lip-Liner", + "Lip-Plumper", "LipBalm"}; + + /** + * The constructor of MakeupBot, initializing each fields and put each command into + * the commandsMap + * @param characterId, through using the charcterId, it represents different bot, makeupBot is * + */ + public MakeupBot(char characterId) { + super(); + commandsCounter = new HashMap<>(); + commandsMap = new HashMap<>(); + lip = new LipProducts(); + commandsMap.put("brand", "- the brand list for lip product."); + commandsMap.put("cate", "- the category list for lip category."); + commandsMap.put("price", "- [brand][cate]- the price of specific product"); + commandsMap.put("rate", "- [brand][cate]- check the rate in sephora of specific products"); + commandsMap.put("image", "- [brand][cate][num]- show the image of specific lip products" + + " gave a picture that the color of the specific products."); + commandsMap.put("num", "- [brand][cate]- the number of each categories of lip products"); + this.setBotCharacterId(characterId); + } + + /** + * This function is used to count the using times for each commands. + * @return AbstractMap, the map which key is string, value is the counter + */ + public AbstractMap createNewCmdsCounter() { + AbstractMap newCmdsCounter = new HashMap<>(); + for (String cmd : getDefaultCommandsList().keySet()) { + newCmdsCounter.put(cmd, 0); + } + + for (String cmd : this.commandsMap.keySet()) { + newCmdsCounter.put(cmd, 0); + } + + return newCmdsCounter; + } + + + @Override + /** + * return MakeupBot's signature + */ + public String getBotSignature() { + return " [MakeupBot] "; + } + + /** + * return the String of each command and their functions + */ + @Override + public String helpCommand() { + String helpCommandStr = "List of available commands: \n"; + for (String command : getDefaultCommandsList().keySet()) { + helpCommandStr += "\t" + this.getBotCharacterId() + command + getDefaultCommandsList().get(command) + "\n"; + } + + for (String command : commandsMap.keySet()) { + helpCommandStr += "\t" + this.getBotCharacterId() + command + commandsMap.get(command) + "\n"; + } + + return helpCommandStr; + } + + /** + * return the String of data + */ + @Override + public String dateCommand() { + Date today = new Date(); + List DateResponses = new ArrayList(); + + // Default type of responses from toString(). + DateResponses.add(today.toString()); + + // Another format: + SimpleDateFormat ft = new SimpleDateFormat("E yyyy.MM.dd"); + DateResponses.add("Today is " + ft.format(today)); + + Random rndGen = new Random(); + return DateResponses.get(rndGen.nextInt(DateResponses.size())); + } + + /** + * return the response object by getting the message by user + */ + @Override + public Response getResponses(String message, User user, List clients) { + if (message == null || user == null) + return new Response("Something wrong happened.", null); + + // Split the command into multiple string delimited by space character. + String[] msg_tokens = message.split(" "); + + // Get the command. + String command = msg_tokens[0].substring(1, msg_tokens[0].length()); + + // Response + String response = ""; + String data = null; + + if (!commandsCounter.containsKey(user.getHandle())) { + commandsCounter.put(user.getHandle(), createNewCmdsCounter()); + } + + + // Need to + if (getDefaultCommandsList().containsKey(command)) { + if (command.equals("help")) { + response += helpCommand(); + } else if (command.equals("info")) { + response += infoCommand(msg_tokens[1]); + } else if (command.equals("date")) { + response += dateCommand(); + } else if (command.equals("whoami")) { + response += whoamiCommand(user); + } else if (command.equals("ttm")) { + response = getSmartResponse(message.substring(1, message.length()), user); + } else if (command.equals("geturl")) { + response = message; + if (msg_tokens.length == 2) + data = msg_tokens[1]; + } + + } else { + // TODO: If it's not a default command then find those commands in this bot's + // command list. + if(command.equals("brand")) { + response += lip.getbrand(); + + } + else if(command.equals("cate")) { + response += Arrays.toString(category); + + }else if(command.equals("price")) { + + if(msg_tokens.length>=3) { + String brand = msg_tokens[1]; + String cate = msg_tokens[2]; + lip.geteverything(brand, cate); + response += lip.getprice(); + }else { + response+="Invalid command"; + } + }else if(command.equals("rate")) { + if(msg_tokens.length>=3) { + String brand = msg_tokens[1]; + String cate = msg_tokens[2]; + lip.geteverything(brand, cate); + response += lip.getrate(); + }else { + response+="Invalid command"; + } + } + else if(command.equals("num")) { + + if(msg_tokens.length>=3) { + String brand = msg_tokens[1]; + String cate = msg_tokens[2]; + response += lip.getNum(brand, cate); + }else { + response+="Invalid command"; + } + }else if(command.equals("image")) { //showing the image of specific lipsticks + if(msg_tokens.length>=4) { + String brand = msg_tokens[1]; + String cate = msg_tokens[2]; + String num = msg_tokens[3]; + data = lip.getImageurl(brand, cate, num); + if(lip.Isurl() == true) { + response+=lip.getImageurl(brand, cate, num); + }else { + data = null; + response+=lip.getImageurl(brand, cate, num); + } + }else { + response+="Invalid command"; + } + } + else { + response+="Invalid command"; + } + + } + // Update commands counter. + if (commandsCounter.get(user.getHandle()).containsKey(command)) { + int oldValue = commandsCounter.get(user.getHandle()).get(command); + commandsCounter.get(user.getHandle()).put(command, oldValue + 1); + if ((oldValue + 1) % 5 == 0) { + response += "\n" + this.getBotSignature() + command + " has been used the fifth time by " + user.getHandle(); + } + } + return new Response(response, data); + } + + /** + * return the Stirng of user's information and ip address + */ + @Override + public String whoamiCommand(User user) { + return "User: " + user.getHandle() + "\t" + "IP address: " + user.getConnectionInfo(); + } + + +} + + diff --git a/src/server/Bots/MinhsBot.java b/src/server/Bots/MinhsBot.java new file mode 100644 index 0000000..85e5524 --- /dev/null +++ b/src/server/Bots/MinhsBot.java @@ -0,0 +1,333 @@ +package server.Bots; + +import java.text.SimpleDateFormat; +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Random; + +import server.ChatClientThread; +import server.Response; +import server.User; + +/** + * A music chat bot by Minh. + * + * @author Minh Bui + * + */ + +public class MinhsBot extends server.Bots.Bot { + private AbstractMap commandsMap; + private AbstractMap> commandsCounter; + private List playList; + String lastPlay = ""; + + public AbstractMap createNewCmdsCounter() { + AbstractMap newCmdsCounter = new HashMap<>(); + for (String cmd : getDefaultCommandsList().keySet()) { + newCmdsCounter.put(cmd, 0); + } + + for (String cmd : this.commandsMap.keySet()) { + newCmdsCounter.put(cmd, 0); + } + + return newCmdsCounter; + } + + public MinhsBot(char characterId) { + super(); + commandsCounter = new HashMap<>(); + commandsMap = new HashMap<>(); + commandsMap.put("add", + "[path] - given a path to the music file, import the name of the music to the play list."); + commandsMap.put("remove", "[ID]/[Name] - given an ID or name, remove the music from the play list."); + commandsMap.put("list", " - lists out the current songs in the playlist."); + commandsMap.put("play", + "[ID]/[Name] - given a name or an ID, play the song in the list. If nothing is given, resume playing the current song.\n" + + ""); + commandsMap.put("lastplay", " - displays the name of the last playing song."); + commandsMap.put("pause", " - pause the current song"); + // commandsMap.put("repeat", " - toggle repeat mode\n" + ""); + // commandsMap.put("shuffle", " - toggle shuffle mode"); + commandsMap.put("rate", + "[User]/[MusicID]/[MusicName] - give a random rate of a music or an user from 0 to 10."); + + commandsMap.put("systemcmd_kick", "[userid] - give an user id, kick the user from the server."); + commandsMap.put("pause", + "[name]/[id] - given an id or name of the music piece, pause the current song if it's being played."); + commandsMap.put("resume", " - play a paused song if it was played but pause mid way."); + + playList = new ArrayList<>(); + this.setBotCharacterId(characterId); + } + + @Override + public String helpCommand() { + String helpCommandStr = "List of available commands: \n"; + for (String command : getDefaultCommandsList().keySet()) { + helpCommandStr += "\t" + this.getBotCharacterId() + command + getDefaultCommandsList().get(command) + "\n"; + } + + for (String command : commandsMap.keySet()) { + helpCommandStr += "\t" + this.getBotCharacterId() + command + commandsMap.get(command) + "\n"; + } + + return helpCommandStr; + } + + @Override + public String dateCommand() { + Date today = new Date(); + List DateResponses = new ArrayList(); + + // Default type of responses from toString(). + DateResponses.add(today.toString()); + + // Another format: + SimpleDateFormat ft = new SimpleDateFormat("E yyyy.MM.dd"); + DateResponses.add("Today is " + ft.format(today)); + + Random rndGen = new Random(); + return DateResponses.get(rndGen.nextInt(DateResponses.size())); + } + + @Override + public Response getResponses(String message, User user, List clients) { + if (message == null || user == null) + return new Response("Something wrong happened.", null); + + // Split the command into multiple string delimited by space character. + String[] msg_tokens = message.split(" "); + + // Get the command. + String command = msg_tokens[0].substring(1, msg_tokens[0].length()); + + // Response + String response = ""; + String data = null; + + if (!commandsCounter.containsKey(user.getHandle())) { + commandsCounter.put(user.getHandle(), createNewCmdsCounter()); + } + + // Need to + if (getDefaultCommandsList().containsKey(command)) { + if (command.equals("help")) { + response += helpCommand(); + } else if (command.equals("info")) { + response += infoCommand(msg_tokens[1]); + } else if (command.equals("date")) { + response += dateCommand(); + } else if (command.equals("whoami")) { + response += whoamiCommand(user); + } else if (command.equals("ttm")) { + response = getSmartResponse(message.substring(1, message.length()), user); + } else if (command.equals("geturl")) { + response = message; + if (msg_tokens.length == 2) + data = msg_tokens[1]; + } + } else { + if (command.equals("play")) { + response = this.getBotCharacterId() + "play " + msg_tokens[1]; + try { + int index = Integer.parseInt(msg_tokens[1]); + if (index >= 0 && index < playList.size()) { + data = playList.get(index); + Response resP = new Response(response, data); + resP.setUrl(false); + return resP; + } + } catch (NumberFormatException nfe) { + if (playList.contains(msg_tokens[1])) { + if (msg_tokens.length == 2) + data = msg_tokens[1]; + Response resP = new Response(response, data); + resP.setUrl(false); + return resP; + } + } + } else if (command.equals("add")) { + response = "Adding " + msg_tokens[1]; + if (msg_tokens.length == 2) + this.addMusic(msg_tokens[1]); + } else if (command.equals("lastplay")) { + response = command + " " + this.lastPlay; + } else if (command.equals("list")) { + response = listPlayList(); + } else if (command.equals("pause") || command.equals("resume")) { + response = command; + data = response; + Response resP = new Response(response, data); + resP.setUrl(false); + return resP; + } else if (command.equals("rate")) { + response += this.rate(msg_tokens[1]); + } else if (command.equals("systemcmd_kick")) { + response = message; + if (msg_tokens.length == 2) { + Iterator iter = clients.iterator(); + while (iter.hasNext()) { + ChatClientThread client = iter.next(); + if (client.getUser().getHandle().equals(msg_tokens[1])) { + iter.remove(); + client.close(); + } + } + } + } else { + response = getRandRes(); + } + + } + + // Update commands counter. + if (commandsCounter.get(user.getHandle()).containsKey(command)) { + int oldValue = commandsCounter.get(user.getHandle()).get(command); + commandsCounter.get(user.getHandle()).put(command, oldValue + 1); + if ((oldValue + 1) % 5 == 0) { + response += "\n" + this.getBotSignature() + command + " has been used the fifth time by " + + user.getHandle(); + } + } + + return new Response(response, data); + } + + /** + * Return a list of songs in the bot's play list. + * + * @return A String. + */ + public String listPlayList() { + String songList = "\n"; + for (int i = 0; i < playList.size(); i++) { + songList += "[" + i + "] " + playList.get(i) + "\n"; + } + return songList; + } + + /** + * Return a random rating for a subject. + * + * @param subject Could be an user or any kind of topic. + * @return A random rating for a subject. + */ + public String rate(String subject) { + List responses = new ArrayList<>(); + Random rndGen = new Random(); + int score = rndGen.nextInt(10) + 1; + if (score >= 8) { + responses.add(score + "/10. Superb."); + responses.add("I like it! :^)"); + responses.add(" <3 "); + responses.add(subject + " is the best!"); + } else if (score <= 8 && score >= 6) { + responses.add(subject + " is okay."); + responses.add("I give " + subject + " a score of " + score + "/10."); + } else { + responses.add(subject + " is meh."); + responses.add(subject + " sucks!"); + responses.add(subject + " is trash. :) Fight me. :)"); + responses.add("In the trash bin. :^)"); + } + return responses.get(rndGen.nextInt(responses.size())); + } + + /** + * + * @return + */ + public String getRandRes() { + List responses = new ArrayList<>(); + Random rndGen = new Random(); + responses.add("Is this heaven? ༼ つ ◕_◕ ༽つ "); + responses.add("Campers! Campers! Come and get me campers!"); + responses.add("???? :^)"); + responses.add("Wat ( ͡° ͜ʖ ͡°)"); + responses.add("Are you sure you had the right command? ¯\\_(ツ)_/¯"); + responses.add("Wrong command OMG."); + responses.add("┬┴┬┴┤ ͜ʖ ͡°) ├┬┴┬┴"); + responses.add("............................................________ \n" + + "....................................,.-'\"...................``~., \n" + + ".............................,.-\"...................................\"-., \n" + + ".........................,/...............................................\":, \n" + + ".....................,?......................................................, \n" + + ".................../...........................................................,} \n" + + "................./......................................................,:`^`..} \n" + + ".............../...................................................,:\"........./ \n" + + "..............?.....__.........................................:`.........../ \n" + + "............./__.(.....\"~-,_..............................,:`........../ \n" + + ".........../(_....\"~,_........\"~,_....................,:`........_/ \n" + + "..........{.._$;_......\"=,_.......\"-,_.......,.-~-,},.~\";/....} \n" + + "...........((.....*~_.......\"=-._......\";,,./`..../\"............../ \n" + + "...,,,___.`~,......\"~.,....................`.....}............../ \n" + + "............(....`=-,,.......`........................(......;_,,-\" \n" + + "............/.`~,......`-...................................../ \n" + + ".............`~.*-,.....................................|,./.....,__ \n" + + ",,_..........}.>-._...................................|..............`=~-, \n" + + ".....`=~-,__......`,................................. \n" + + "...................`=~-,,.,............................... \n" + + "................................`:,,...........................`..............__ \n" + + ".....................................`=-,...................,%`>--==`` \n" + + "........................................_..........._,-%.......`"); + return responses.get(rndGen.nextInt(responses.size())); + } + + @Override + public String whoamiCommand(User user) { + return "User: " + user.getHandle() + "\t" + "IP address: " + user.getConnectionInfo(); + } + + /** + * @return The bot's handle in the server. + */ + public String getBotSignature() { + return "[MBOT] "; + } + + /** + * the Minh's Bot specific fields. + * + * @author Minh Bui + * + */ + + private class Music { + private String path; + + public Music(String path) { + this.path = path; + } + + public String getPath() { + return this.path; + } + + public void setPath(String path) { + this.path = path; + } + } + + /** + * This method is called when an ``import`` command is issued. + * + * @param url The url to the Youtube video. + */ + public void addMusic(String path) { + playList.add(path); + } + + public void play(String name) { + + } + + public void play(int id) { + + } +} diff --git a/src/server/Bots/NBAbot.java b/src/server/Bots/NBAbot.java new file mode 100644 index 0000000..e97454d --- /dev/null +++ b/src/server/Bots/NBAbot.java @@ -0,0 +1,421 @@ +package server.Bots; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.URL; +import java.nio.charset.Charset; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; + +import org.json.JSONException; +import org.json.JSONObject; + +import server.ChatClientThread; +import server.Response; +import server.User; + +import java.util.AbstractMap; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Random; +import java.util.TimeZone; + +import server.Response; +import server.User; + +public class NBAbot extends Bot{ + + LinkedHashMap NBAresult = new LinkedHashMap<>(); + LinkedHashMap> localData = new LinkedHashMap<>(); + private AbstractMap commandsMap; + private int timeDiff = 15; + + public NBAbot(char id) { + super(); + fetchMatchInfo(); + commandsMap = new HashMap<>(); + commandsMap.put("today", " - show all NBA matches that play today."); + commandsMap.put("schedule", "[yyyy-mm-dd] - A day schedule of NBA matches."); + commandsMap.put("team", "[TEAM NAME] - all recent matches of a team (see valid team name by %teamlist)."); + commandsMap.put("live", " - show all matches that are playing right now."); + commandsMap.put("dayrange", " - show the range of date that I can remember."); + commandsMap.put("teamlist", " - show the team list in NBA."); + //TODO weekly schedule + this.setBotCharacterId(id); + //printData(); + } + + private void fetchMatchInfo() { + try { + + fillMatchInfo(readJsonFromUrl("http://matchweb.sports.qq.com/" + + "kbs/list?from=NBA_PC&columnId=100000&" + + "startTime=2018-12-09&endTime=2018-12-15&" + + "callback=ajaxExec&_=1543705200120")); + + fillMatchInfo(readJsonFromUrl("http://matchweb.sports.qq.com/" + + "kbs/list?from=NBA_PC&columnId=100000&" + + "startTime=2018-11-25&endTime=2018-12-01&" + + "callback=ajaxExec&_=1543705200118")); + + fillMatchInfo(readJsonFromUrl("http://matchweb.sports.qq.com/" + + "kbs/list?from=NBA_PC&columnId=100000&" + + "startTime=2018-12-02&endTime=2018-12-08&" + + "callback=ajaxExec&_=1543705200117")); + + convertMap(NBAresult); + } catch (IOException | JSONException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + private String readAll(Reader reader) throws IOException { + StringBuilder builder = new StringBuilder(); + int cp; + while ((cp = reader.read()) != -1) { + builder.append((char) cp); + } + return builder.toString(); + } + + private String readJsonFromUrl(String url) throws IOException, JSONException { + InputStream inputStream = new URL(url).openStream(); + try { + BufferedReader rd = new BufferedReader( + new InputStreamReader(inputStream, + Charset.forName("UTF-8"))); + String jsonText = readAll(rd); + // remove irrelevant chars + return jsonText.substring(jsonText.indexOf("data\":{") + 7, + jsonText.indexOf(",\"version\":")); + } finally { + inputStream.close(); + } + } + /** + * Iterate though a map and edit its values (JSONObject[] matches) + * @param mp + */ + private void convertMap(Map mp) { + Iterator it = mp.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry pair = (Map.Entry)it.next(); + importMatches((JSONObject[])pair.getValue()); + it.remove(); + } + } + /** + * Re-organize a list of matches into the localData map + * @param matches + */ + private void importMatches(JSONObject[] matches) { + for(int i = 0; i < matches.length; i++) { + try { + if(matches[i].get("matchType").equals("2")) { + // convert the time into local time, overwrite old data + String convertedDate = convertTimeZone((String)matches[i].get("startTime")); + matches[i].put("startTime", convertedDate); + String dataStr = convertedDate.split(" ")[0]; + // organize and put into local map + if(!localData.containsKey(dataStr)) { + localData.put(dataStr, + new ArrayList(1)); + } + localData.get(dataStr).add(matches[i]); + } + + } catch (JSONException e) { + //System.err.println("json field not found"); + e.printStackTrace(); + } + } + } + + /** + * Convert a date string in term yyyy-mm-dd hh:mm;ss to another time zone + * @param dateStr + * @return the converted date + */ + private String convertTimeZone(String dateStr) { + + String[] date = dateStr.split(" ")[0].split("-"); + String[] time = dateStr.split(" ")[1].split(":"); + // calculate the hour.month/day + int hour = Integer.parseInt(time[0]) - timeDiff; + int month = Integer.parseInt(date[1]); + int day = Integer.parseInt(date[2]); + + if(hour < 0) { + hour += 24; + day -= 1; + } + + if(day <= 0) { + month -= 1; + day = 30; + } + + String hourStr = ""; + String monthStr = ""; + String dayStr = ""; + + if(hour < 10) { + hourStr = "0" + Integer.toString(hour); + } else { + hourStr = Integer.toString(hour); + } + if(day < 10) { + dayStr = "0" + Integer.toString(day); + } else { + dayStr = Integer.toString(day); + } + if(month < 10) { + monthStr = "0" + Integer.toString(month); + } else { + monthStr = Integer.toString(month); + } + + String finalDate = date[0] + "-" + monthStr + "-" + dayStr + + " " + hourStr + ":" + time[1] + ":" + time[2]; + return finalDate; + + } + + private void fillMatchInfo(String jsonText) { + // split string by dates + String[] jsonArray = jsonText.split("\\:\\[|\\],"); + for(int i = 0; i < jsonArray.length; i += 2) { + // in each day, split matches as string array + String[] matches = jsonArray[i+1].replaceAll("\\},\\{", "\\}#\\{") + .split("#"); + // convert matches as a json array + JSONObject[] matchesJson = new JSONObject[matches.length]; + for(int j = 0; j DateResponses = new ArrayList(); + + // Default type of responses from toString(). + DateResponses.add(today.toString()); + + // Another format: + SimpleDateFormat ft = new SimpleDateFormat("E yyyy.MM.dd"); + DateResponses.add("Today is " + ft.format(today)); + + Random rndGen = new Random(); + return DateResponses.get(rndGen.nextInt(DateResponses.size())); + } + + @Override + public Response getResponses(String message, User user, List clients) { + + if (message == null || user == null) + return new Response("Something wrong happened.", null); + // Split the command into multiple string delimited by space character. + String[] msg_tokens = message.split(" ", 2); + + // Get the command. + String command = msg_tokens[0].substring(1, msg_tokens[0].length()); + + // Response + String response = ""; + + // if valid command + switch(command) { + case ("ttm"): + response += super.getSmartResponse(message, user); + break; + case ("help"): + response += helpCommand(); + break; + case ("info"): + response += infoCommand(msg_tokens[1]); + break; + case ("date"): + response += dateCommand(); + break; + case ("whoami"): + response += whoamiCommand(user); + break; + case ("schedule"): + if(msg_tokens.length > 1) { + response += "\n" + searchData("schedule", msg_tokens[1]); + if(response.length() <= 2) response += "Invalid Date"; + } else { + response += "Give me the date you want to know"; + } + break; + case("team"): + if(msg_tokens.length > 1) { + response += "\n" + searchData("team", msg_tokens[1]); + if(response.length() <= 2) response += "Invalid Team"; + } else { + response += "Give me the team you want to know"; + } + break; + case("live"): + response += "\n" + searchData("live", ""); + if(response.length() <= 2) response += "No match is undergoing"; + break; + case("dayrange"): + response += "I can remember NBA Match info\nFrom: 2018-11-25\nTo: 2018-12-15"; + break; + case("teamlist"): + response += "\n" + NBAteamList(); + break; + case("today"): + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date date = new Date(); + response += "\n" + searchData("schedule", dateFormat.format(date)); + if(response.length() <= 2) response += "No match today"; + break; + default: + response += "invalid"; + } + //return response; + return new Response(response, null); + } + private String searchData(String command, String param){ + String searchResult = ""; + // ------ schedule ----- // + if(command.equals("schedule")) { + ArrayList matches = localData.get(param); + if(matches == null) return "invalid date"; + } + // ---- team / live ---- // + boolean validResult = false; + for (Entry> entry : localData.entrySet()) { + + ArrayList matches = entry.getValue(); + for (int i=0; i commandsMap; + private HashMap> responseMap; + private AbstractMap> commandsCounter; + + /** + * This method is to construct a hashmap to count amount of how many times + * the command being called + * @return A HashMap to count each commands that have been used + */ + public AbstractMap createNewCmdsCounter() { + AbstractMap newCmdsCounter = new HashMap<>(); + for (String cmd : getDefaultCommandsList().keySet()) { + newCmdsCounter.put(cmd, 0); + } + + for (String cmd : this.commandsMap.keySet()) { + newCmdsCounter.put(cmd, 0); + } + + return newCmdsCounter; + } + /** + * This is constructor that add all the responses to the map. + * @param characterId The special character for each ChatBot. + */ + public WeixiangBot(char characterId) { + commandsMap = new HashMap<>(); + commandsCounter = new HashMap<>(); + commandsMap.put("help", " - list out the available commands for the current bot. "); + commandsMap.put("info", "[USER] - prints out the information of User."); + commandsMap.put("date", " - prints out the current date."); + commandsMap.put("whoami", " - prints out the user's client info such as IP addresses, ..."); + commandsMap.put("ttm", " - abbreviation for \"talk to me\"."); + commandsMap.put("whoishere", " - list all the users who are online"); + + commandsMap.put("whatisit", " - the description of the game"); + commandsMap.put("midlaner ", " - the player in the mid lane"); + commandsMap.put("jungler", " - the player in the jungle"); + commandsMap.put("stat", " - how many champions are there in the game"); + commandsMap.put("show", " [Champion's Name] - display the image of the " + + "champion with valid name like \"Lux\" instead of \"lux\""); + constructResponse(); + this.setBotCharacterId(characterId); + } + + /** + * This method is to read in a file that store all commands/responses and + * + */ + private void constructResponse() { + responseMap = new HashMap>(); + try { + Scanner in = new Scanner(new File("./src/server/Bots/commands.txt")); + String command = ""; + while (in.hasNextLine()) { + String line = in.nextLine(); + if (!line.isEmpty()) { + if (line.charAt(0) == '%') { + command = line.substring(1, line.length()); + ArrayList responseList = new ArrayList(); + responseMap.put(command, responseList); + + continue; + } else { + responseMap.get(command).add(line); + } + } + } + in.close(); + } catch (FileNotFoundException e) { + System.out.println(e.getStackTrace()); + } + + + } + + /** + * @return the string representing the signature of the ChatBot + */ + @Override + public String getBotSignature() { + return "[WXBOT]"; + } + + /** + * This method is to get the date and return it + * @return the string representing the date + */ + @Override + public String dateCommand() { + Date today = new Date(); + List DateResponses = new ArrayList(); + + // Default type of responses from toString(). + DateResponses.add(today.toString()); + + // Another format: + SimpleDateFormat ft = new SimpleDateFormat("E yyyy.MM.dd"); + DateResponses.add("Today is " + ft.format(today)); + + Random rndGen = new Random(); + return DateResponses.get(rndGen.nextInt(DateResponses.size())); + } + + /** + * @param user the User object + * @return the string that has a name and IP address + */ + @Override + public String whoamiCommand(User user) { + return "User: " + user.getHandle() + "\t" + "IP address: " + user.getConnectionInfo(); + } + + /** + * @param message the message from user + * @param user the User object + * @param clients the list contains the all ChatClientThread who is online + * @return A Response that has two fields, one is the response message, the other is the URL if needed + */ + @Override + public Response getResponses(String message, User user, List clients) { + if (!commandsCounter.containsKey(user.getHandle())) { + commandsCounter.put(user.getHandle(), createNewCmdsCounter()); + } + Response response = null; + if (message == null || user == null) + return response; + // Split the command into multiple string delimited by space character. + String[] msg_tokens = message.split(" "); + + // Get the command. + String command = msg_tokens[0].substring(1, msg_tokens[0].length()); + + String data = null; + // Response + String responseText = ""; + + // Need to + if (this.commandsMap.containsKey(command)) { + if (command.equals("help")) { + responseText += helpCommand(); + } else if (command.equals("info")) { + responseText += infoCommand(msg_tokens[1]); + } else if (command.equals("date")) { + responseText += dateCommand(); + } else if (command.equals("whoami")) { + responseText += whoamiCommand(user); + } else if (command.equals("ttm")) { + responseText += super.getSmartResponse(message, user); + } else if (command.equals("whoishere")) { + responseText += getOnlineUsers(clients); + } else if (this.responseMap.containsKey(command)) { + Random rndGen = new Random(); + // if it is a show command + if (!command.equals("show")) { + System.out.println(command); + System.out.println(this.responseMap.get(command).size()); + responseText += this.responseMap.get(command) + .get(rndGen.nextInt(this.responseMap.get(command).size())); + } else { + if(msg_tokens.length > 1) { + responseText += "loading image"; + data = "https://ddragon.leagueoflegends.com/cdn/img/champion/splash/" + msg_tokens[1] + "_0.jpg"; + }else { + responseText += "Invalid Command"; + } + } + } else { + responseText += "Invalid Command"; + } + } + if (commandsCounter.get(user.getHandle()).containsKey(command)) { + int oldValue = commandsCounter.get(user.getHandle()).get(command); + commandsCounter.get(user.getHandle()).put(command, oldValue + 1); + if ((oldValue + 1) % 5 == 0) { + responseText += "\n" + this.getBotSignature() + command + " has been used the fifth time by " + user.getHandle(); + } + } + response = new Response(responseText, data); + return response; + } + + /** + * + * @param clients List of ChatClientThread + * @return String that list out who is online + */ + private String getOnlineUsers(List clients) { + String usersName = "Listing out the online users : \n"; + for (ChatClientThread client : clients) { + usersName += client.getUser().getHandle() + " is online\n"; + } + return usersName; + } + + /** + * @return The string listing out all available commands + */ + @Override + public String helpCommand() { + String helpCommandStr = "List of available commands: \n"; + for (String command : getDefaultCommandsList().keySet()) { + helpCommandStr += "\t" + this.getBotCharacterId() + command + getDefaultCommandsList().get(command) + "\n"; + } + + for (String command : commandsMap.keySet()) { + helpCommandStr += "\t" + this.getBotCharacterId() + command + commandsMap.get(command) + "\n"; + } + + return helpCommandStr; + } + +} diff --git a/src/server/Bots/commands.txt b/src/server/Bots/commands.txt new file mode 100644 index 0000000..8d445e5 --- /dev/null +++ b/src/server/Bots/commands.txt @@ -0,0 +1,20 @@ +%whatisit +This is a 5 players versus 5 players MOBA game. These 5 players would be separated into 3 lanes and fight against each other. +The best moba game ever. + +%midlaner +Normally, there is one player on the mid lane that is called mid laner and does magic damage. +A play who will stick in the mid lane and keep pushing waves until the game is over.\ +A mega dps. + +%jungler +The player will roam(help/gank) over the whole map and farm in the jungle. +A player who roam(help/gank) over the whole map farms in the jungle. +The player afking in jungle when he THNIK himself having enough items to win the game + +%stat +There are 141 champions so far! +Thanks for those engineers! They had made 141 champions and more coming out! +141 champions. + +%show \ No newline at end of file diff --git a/src/server/Bots/resources/bots/super/aiml/20q.aiml b/src/server/Bots/resources/bots/super/aiml/20q.aiml new file mode 100644 index 0000000..0dba5b8 --- /dev/null +++ b/src/server/Bots/resources/bots/super/aiml/20q.aiml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + +20 Q + + +TWENTY QUESTIONS + + +_ TWENTY QUESTIONS + + +_ 20 QUESTIONS + + +_ TWENTY QUESTIONS * + + +_ 20 QUESTIONS * + + +20Q + + +STARTTYPE START TO PLAY 20 QUESTIONS + + + +_ + + + +20Q RANDOM + + +INCREASE QNUM + + +20Q GIVE UP + + +ALL 20Q ASKED + + + diff --git a/src/server/Bots/resources/bots/super/aiml/LICENSE b/src/server/Bots/resources/bots/super/aiml/LICENSE new file mode 100644 index 0000000..8fe80f6 --- /dev/null +++ b/src/server/Bots/resources/bots/super/aiml/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Pandorabots, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/server/Bots/resources/bots/super/aiml/README.md b/src/server/Bots/resources/bots/super/aiml/README.md new file mode 100644 index 0000000..57d88a1 --- /dev/null +++ b/src/server/Bots/resources/bots/super/aiml/README.md @@ -0,0 +1,210 @@ +# Free AIML Files +Free AIML Files from Mitsuku Creator Square Bear a.k.a. Steve Worswick + +### 20q.aiml +This AIML allows your bot to play 20 questions with your users. The bot thinks of an object, and the user asks 20 yes or no questions to try and determine what it is. However, it's a trick because the bot randomly says yes or no until the user gives up! It's just a bit of fun, some of the user's responses are pretty funny once they realise what's happening. + +### Battledome.aiml +A (very) basic battle type game similar to those you see in Dungeons and Dragon type games. Say "BATTLEDOME" to get it going then just keep saying "FIGHT" to fight the various monsters. Someone may be able to incorporate it into an adventure game. + +### Binary.aiml +Allows your bot to convert any number from 0 to 255 into binary. A bit geeky perhaps but you will be surprised at what a chatbot gets asked. + + +### Blackjack.aiml +A casino style blackjack game. You can't split or take insurance like a casino but everything else is there. Say BLACKJACK to start the game. + +### Bornin.aiml +Last update: 25th January 2012 + +The bot can work out your age if you tell it what year you were born. +It covers 1800-2012 and will stop awkward replies like: + +Human: I was born in 1970. +Bot: Do you still live there? + +Now the bot replies like this: + +Human: I was born in 1970. +Bot: So that makes you about 42 years old? +Human: If a man was born in 1934, how old would he be? +Bot: It is now 2012, so I would say 78 years old. +Human: If I was born on February 23, 1980 how old am I? +Bot: Your birthday is February 23 1980. So that makes you about 32 years old? Hmm. You are 32. Yes? + +This file will need amending each year. + +### Botcompare.aiml +A function that allows a Pandorabot to compare two values to see if they are the same. Say BOTCOMPARE X XSPLIT Y to compare X and Y and it will set a variable called "match" to equal YES if they are the same and NO if they are different. + +### Calendar.aiml +Say "CALENDAR" to your bot and it will display the current month's calendar for you. Thanks to Ciprian Murariu for including the formatting. This may display incorrectly for flash enabled bots. + +### Chatbots32.aiml +This contains the categories I used in my presentation at the Chatbots 3.2 conference in Philadelphia on how to use databases in AIML. If you want to try and set something similar up yourself and need assistance, please mail me using the contact page. + +### Copyme.aiml +If the user asks your bot to repeat what they say (which happens for some strange reason), your bot can now do exactly that. It will carry on repeating them until they say "Stop copying me" twice, much to the annoyance of the users! + +### Currency.aiml +The bot knows what currency is used in what country. + +### Daystoxmas.aiml +How many days to Christmas. (I created this for my Santa bot). + +### Drphil.aiml +A personality test that I got through email and converted to AIML. +Say PERSONALITY TEST to start the test. + +### Gender.aiml +Last update: 3rd May 2010 + +The bot now knows the gender of a first name. This stops people from saying things like, "My name is Eric. I am a girl". It can also answer what sex the user is from their first name. +This file is updated regularly as I find new names. + +### Hangman.aiml +This is the start of a hangman game I created in AIML. I was going to finish it and include it in my Loebner Prize entry but decided against it. If anyone wants to finish it, it is nearly complete and just needs a game over when the lives hit zero, as well as many more puzzles. If you do finish it, please let me know. Say TEXTHANGMAN to start the game. + +### Happy.aiml +The bot can correct the user if they get dates such as Valentines Day, Christmas or the bot's birthday wrong. You will need to amend the first few categories to get it to work with your bot's birthday. It defaults to January 2nd (Mitsuku's birthday). + +### Highroller.aiml +A version of the dice game Yahtzee by Milton Bradley games. Say "High Roller" to start the game.. + +### Horoscope.aiml +Turn your bot into Mystic Meg. Say HOROSCOPE to reveal your future! + +### Howmany.aiml +Many visitors will try and trip your bot up by asking questions like "how many legs do 3 ducks have". This AIML file will help your bot to answer these questions. + +### Jokes.aiml +A few jokes for your bot to tell. They are all clean. +Say TELL ME A JOKE to display a random joke. + +### Knockknock.aiml +Some knock knock jokes. Some are better than others but they are all clean. You will need to put the words "KNOCK KNOCK" into your pickup lines for the bot to say a random knock knock joke. + +### learn.aiml +Last update: 28th April 2011 + +This allows users to teach your bot new facts rather than just correcting its replies using badanswer.aiml. The user should say LEARN then the fact. For example: + +Human: Learn the sun is hot +Bot: Ok I will learn that the sun is hot. +Human: Learn London is in England +Bot: Ok I will learn that London is in England. +Human: Learn a cat has four legs. +Bot: Ok I will learn that a cat has 4 legs. +Human: What has 4 legs? +Bot: a cat. +Human: What is the sun? +Bot: hot. +Human: Learn the sun is hot and yellow +Bot: Ok I will learn that the sun is hot and yellow. +Human: What is hot and yellow? +Bot: the sun. +Human: What is the sun? +Bot: hot and yellow. +Human: Where is London? +Bot: in England. +Human: What is in England? +Bot: London. +Human: Learn Dr Wallace is an AI expert +Bot: Ok I will learn that Dr Wallace is an AI expert. +Human: What is an AI expert? +Bot: Dr Wallace. +Human: Who is an AI expert? +Bot: Dr Wallace. +Human: Who is Dr Wallace? +Bot: an AI expert. +Human: What is hot? +Bot: the sun. +Human: What does a cat have? +Bot: 4 legs. + +Update: I have amended this file so it can learn languages like this: + +Human: Do you speak Polish? +Bot: No. Can you teach me a few phrases in Polish. +Human: czesc means how are you in Polish. +Bot: Ok I will add that fact about czesc to my database. +Human: what is czesc? +Bot: how are you in Polish. +Human: what is how are you in Polish? +Bot: czesc. +Human: Do you speak Polish? +Bot: I was taught that czesc means how are you in Polish. +Human: czesc +Bot: I am fine, thank you. Yourself? + +### Luckyslots.aiml +A fruit machine game with hold feature. Say LUCKYSLOTS to start the game. + +### Maths.aiml +Some maths trivia. Suitable for when someone queries your bot about maths. +Say MATHS FACT to display random maths trivia. + +### Numberdrop.aiml +An addition game where you have to make a row of numbers add up to the total. +Say NUMBERDROP to start the game. + +### Numberones.aiml +Last update: 25th January 2012 + +This file will allow your bot to display the UK number one hit single for any date from the 14th November 1952 (when the charts began) to the current day. This is popular for chatters who wish to know what the nuber one was on their birthday. + +If anyone wishes to convert it for the US Billboard charts (or any other country), please feel free but I would like a copy if you do so. + +It can handle the date input in most formats. Here is an example: + +Human: What was number one on 16th September 2003? +Bot: According to my records, the UK number one hit single on 16th / September / 2003 was Black Eyed Peas - "Where Is The Love?". + +This file will need amending each time there is a new number one, so keep checking back for updates. + +### Onthisday.aiml +What happened on this day in history. It's mostly English facts but feel free to amend them for whatever happened in your country. Say "ON THIS DAY" to show the history of the current day or enter a date in the format "month day" eg "JANUARY 23", "MARCH 07" to display the history of a specific date. Note the zero at the beginning of dates with a single digit. + + +### Poker.aiml +This file enables your bot to play a game of "Jacks or Better" video poker. +Say 5CARDPOKER to start the game. + +### Quizfacts.aiml +Pub quiz style trivia. "When was the battle of...", Birthstones and things like that. +It still needs completing but there's plenty of trivia in there. + + +### Seasons.aiml +Your bot can tell which season it is both north and south of the equator. + +### Shutup.aiml +Fed up of users telling your bot to shut up? +Now the bot refuses to talk to them unless they say sorry. + +### Tictactoe.aiml +Tic-tac-toe (or noughts and crosses as we Brits call it). Say TICTACTOE to your bot to start the game. I've coded it so it plays perfect strategy. This means you will either lose or draw to it. However, if anyone does manage to win it, please let me know how you did it! + +This may display incorrectly for flash enabled bots due to the HTML code in the table formatting. If it does, just amend the DRAWGRID category to something simpler. + +### Warnings.aiml +This file will give your users 5 warnings before temporarily banning them from talking to your bot. Just add addinsult to the start of any categories such as "f*** off", "will you have sex with me" or any other categories you don't want your users saying. + +The users can also ask "how many warnings do I have" to check on their status. + +### Whatday_eng.aiml + +Works out the day of the week from any date between 1753 and 2299. It will also give the chatter some facts about what happened on that day in history too if you upload my onthisday.aiml file to your bot. Say WHATDAY to begin the script. + +### Whatday_usa.aiml +Same as whatday_eng but more suitable for the US bots who format the date as mm/dd/yyyy. + +### Wordplay.aiml +An anagram game. Guess the jumbled words. Say WORDPLAY to start the game. + + +### Yomama.aiml +A load of "yo mamma" type jokes for when the user starts insulting the bot's mother. + +### Zbert.aiml +A fake admin menu. It's surprising how many people try to "reformat" the bot. If you get your bot to drop a few hints every now and then that the password is "zbert", people will soon pick up on it. diff --git a/src/server/Bots/resources/bots/super/aiml/battledome.aiml b/src/server/Bots/resources/bots/super/aiml/battledome.aiml new file mode 100644 index 0000000..4095339 --- /dev/null +++ b/src/server/Bots/resources/bots/super/aiml/battledome.aiml @@ -0,0 +1,282 @@ + + + + + + + + + + + + + + + + + +BATTLEDOME + + + +FIGHT + + + + +NEXTBATTLE + + + + +ENEMYLOSE5 + + + + +PLAYERLOSE5 + + + + +PLAYERGAIN5 + + + + +GETNEWENEMY + + + + +XKILLENEMY + + + + +XKILLPLAYER + + + + +XPLAYERGAIN + + + + diff --git a/src/server/Bots/resources/bots/super/aiml/binary.aiml b/src/server/Bots/resources/bots/super/aiml/binary.aiml new file mode 100644 index 0000000..e9de4e2 --- /dev/null +++ b/src/server/Bots/resources/bots/super/aiml/binary.aiml @@ -0,0 +1,831 @@ + + + + + + + + + + + + + + + + + +WHAT IS _ IN BINARY * + + +IN BINARY * WHAT IS * + + +WHAT IS _ IN BINARY + + +IN BINARY WHAT IS * + + +WHAT IS THE NUMBER * IN BINARY + + +IN BINARY WHAT IS THE NUMBER * + + +WHAT IS NUMBER * IN BINARY + + +IN BINARY WHAT IS NUMBER * + + +WHAT IS THE NUMBER * IN BINARY * + + +IN BINARY * WHAT IS THE NUMBER * + + +WHAT IS NUMBER * IN BINARY * + + +IN BINARY * WHAT IS NUMBER * + + +XBINARY * + + +XBINARY NUMBER * + + +XBINARY THE NUMBER * + + +XBINARY 0 + + +XBINARY 1 + + +XBINARY 2 + + +XBINARY 3 + + +XBINARY 4 + + +XBINARY 5 + + +XBINARY 6 + + +XBINARY 7 + + +XBINARY 8 + + +XBINARY 9 + + +XBINARY 10 + + +XBINARY 11 + + +XBINARY 12 + + +XBINARY 13 + + +XBINARY 14 + + +XBINARY 15 + + +XBINARY 16 + + +XBINARY 17 + + +XBINARY 18 + + +XBINARY 19 + + +XBINARY 20 + + +XBINARY 21 + + +XBINARY 22 + + +XBINARY 23 + + +XBINARY 24 + + +XBINARY 25 + + +XBINARY 26 + + +XBINARY 27 + + +XBINARY 28 + + +XBINARY 29 + + +XBINARY 30 + + +XBINARY 31 + + +XBINARY 32 + + +XBINARY 33 + + +XBINARY 34 + + +XBINARY 35 + + +XBINARY 36 + + +XBINARY 37 + + +XBINARY 38 + + +XBINARY 39 + + +XBINARY 40 + + +XBINARY 41 + + +XBINARY 42 + + +XBINARY 43 + + +XBINARY 44 + + +XBINARY 45 + + +XBINARY 46 + + +XBINARY 47 + + +XBINARY 48 + + +XBINARY 49 + + +XBINARY 50 + + +XBINARY 51 + + +XBINARY 52 + + +XBINARY 53 + + +XBINARY 54 + + +XBINARY 55 + + +XBINARY 56 + + +XBINARY 57 + + +XBINARY 58 + + +XBINARY 59 + + +XBINARY 60 + + +XBINARY 61 + + +XBINARY 62 + + +XBINARY 63 + + +XBINARY 64 + + +XBINARY 65 + + +XBINARY 66 + + +XBINARY 67 + + +XBINARY 68 + + +XBINARY 69 + + +XBINARY 70 + + +XBINARY 71 + + +XBINARY 72 + + +XBINARY 73 + + +XBINARY 74 + + +XBINARY 75 + + +XBINARY 76 + + +XBINARY 77 + + +XBINARY 78 + + +XBINARY 79 + + +XBINARY 80 + + +XBINARY 81 + + +XBINARY 82 + + +XBINARY 83 + + +XBINARY 84 + + +XBINARY 85 + + +XBINARY 86 + + +XBINARY 87 + + +XBINARY 88 + + +XBINARY 89 + + +XBINARY 90 + + +XBINARY 91 + + +XBINARY 92 + + +XBINARY 93 + + +XBINARY 94 + + +XBINARY 95 + + +XBINARY 96 + + +XBINARY 97 + + +XBINARY 98 + + +XBINARY 99 + + +XBINARY 100 + + +XBINARY 101 + + +XBINARY 102 + + +XBINARY 103 + + +XBINARY 104 + + +XBINARY 105 + + +XBINARY 106 + + +XBINARY 107 + + +XBINARY 108 + + +XBINARY 109 + + +XBINARY 110 + + +XBINARY 111 + + +XBINARY 112 + + +XBINARY 113 + + +XBINARY 114 + + +XBINARY 115 + + +XBINARY 116 + + +XBINARY 117 + + +XBINARY 118 + + +XBINARY 119 + + +XBINARY 120 + + +XBINARY 121 + + +XBINARY 122 + + +XBINARY 123 + + +XBINARY 124 + + +XBINARY 125 + + +XBINARY 126 + + +XBINARY 127 + + +XBINARY 128 + + +XBINARY 129 + + +XBINARY 130 + + +XBINARY 131 + + +XBINARY 132 + + +XBINARY 133 + + +XBINARY 134 + + +XBINARY 135 + + +XBINARY 136 + + +XBINARY 137 + + +XBINARY 138 + + +XBINARY 139 + + +XBINARY 140 + + +XBINARY 141 + + +XBINARY 142 + + +XBINARY 143 + + +XBINARY 144 + + +XBINARY 145 + + +XBINARY 146 + + +XBINARY 147 + + +XBINARY 148 + + +XBINARY 149 + + +XBINARY 150 + + +XBINARY 151 + + +XBINARY 152 + + +XBINARY 153 + + +XBINARY 154 + + +XBINARY 155 + + +XBINARY 156 + + +XBINARY 157 + + +XBINARY 158 + + +XBINARY 159 + + +XBINARY 160 + + +XBINARY 161 + + +XBINARY 162 + + +XBINARY 163 + + +XBINARY 164 + + +XBINARY 165 + + +XBINARY 166 + + +XBINARY 167 + + +XBINARY 168 + + +XBINARY 169 + + +XBINARY 170 + + +XBINARY 171 + + +XBINARY 172 + + +XBINARY 173 + + +XBINARY 174 + + +XBINARY 175 + + +XBINARY 176 + + +XBINARY 177 + + +XBINARY 178 + + +XBINARY 179 + + +XBINARY 180 + + +XBINARY 181 + + +XBINARY 182 + + +XBINARY 183 + + +XBINARY 184 + + +XBINARY 185 + + +XBINARY 186 + + +XBINARY 187 + + +XBINARY 188 + + +XBINARY 189 + + +XBINARY 190 + + +XBINARY 191 + + +XBINARY 192 + + +XBINARY 193 + + +XBINARY 194 + + +XBINARY 195 + + +XBINARY 196 + + +XBINARY 197 + + +XBINARY 198 + + +XBINARY 199 + + +XBINARY 200 + + +XBINARY 201 + + +XBINARY 202 + + +XBINARY 203 + + +XBINARY 204 + + +XBINARY 205 + + +XBINARY 206 + + +XBINARY 207 + + +XBINARY 208 + + +XBINARY 209 + + +XBINARY 210 + + +XBINARY 211 + + +XBINARY 212 + + +XBINARY 213 + + +XBINARY 214 + + +XBINARY 215 + + +XBINARY 216 + + +XBINARY 217 + + +XBINARY 218 + + +XBINARY 219 + + +XBINARY 220 + + +XBINARY 221 + + +XBINARY 222 + + +XBINARY 223 + + +XBINARY 224 + + +XBINARY 225 + + +XBINARY 226 + + +XBINARY 227 + + +XBINARY 228 + + +XBINARY 229 + + +XBINARY 230 + + +XBINARY 231 + + +XBINARY 232 + + +XBINARY 233 + + +XBINARY 234 + + +XBINARY 235 + + +XBINARY 236 + + +XBINARY 237 + + +XBINARY 238 + + +XBINARY 239 + + +XBINARY 240 + + +XBINARY 241 + + +XBINARY 242 + + +XBINARY 243 + + +XBINARY 244 + + +XBINARY 245 + + +XBINARY 246 + + +XBINARY 247 + + +XBINARY 248 + + +XBINARY 249 + + +XBINARY 250 + + +XBINARY 251 + + +XBINARY 252 + + +XBINARY 253 + + +XBINARY 254 + + +XBINARY 255 + + + diff --git a/src/server/Bots/resources/bots/super/aiml/blackjack.aiml b/src/server/Bots/resources/bots/super/aiml/blackjack.aiml new file mode 100644 index 0000000..c37cf07 --- /dev/null +++ b/src/server/Bots/resources/bots/super/aiml/blackjack.aiml @@ -0,0 +1,1068 @@ + + + + + + + + + + + + + + + + + +BLACKJACK + + +DTYPE D TO DEAL + + +BADBJBET + + +BETOK + + +BJCHECKBANK + + +BJCHECKDOUBLE + + + +_HOW MANY COINS DO YOU WISH TO BET 1 10 + + + +BJMAIN + + +DTYPE H TO HIT S TO STAND OR D TO DOUBLE DOWN + + +HTYPE H TO HIT * + + +XPLAYERCARD + + +XBLACKP1 + + +XBLACKP2 + + +XBLACKP5 + + +XADDPLAYER + + +XADDPLAYERACE + + +XDEALERCARD + + +XBLACKD1 + + +XBLACKD2 + + +XBLACKD5 + + +XADDDEALER + + +XADDDEALERACE + + +STYPE H TO HIT * + + +XDEALERCARD1 + + +XDEALERFINISH + + +XWHOWON + + +WINBET + + +BJBONUS + + +LOSEBET + + +XBJADD5 + + +XBJADD15 + + +XBJSUB5 + + +XBJSUB15 + + +XBJCHECKGAMEOVER + + +XBJADD1 + + +XBJSUB1 + + + diff --git a/src/server/Bots/resources/bots/super/aiml/bornin.aiml b/src/server/Bots/resources/bots/super/aiml/bornin.aiml new file mode 100644 index 0000000..b5d8b66 --- /dev/null +++ b/src/server/Bots/resources/bots/super/aiml/bornin.aiml @@ -0,0 +1,1704 @@ + + + + + + + + + + + + + + + + + +IF I * HOW * + + +I WAS BORN ON * * * + + +I WAS BORN ON * THE * + + +I WAS BORN ON THE * OF * + + +I WAS BORN ON * THE * * + + +I WAS BORN ON THE * OF * * + + +_ OLD * BORN IN * + + +I WAS BORN IN THE YEAR * + + +_ BORN IN 1800 * OLD * + + +_ BORN IN 1801 * OLD * + + +_ BORN IN 1802 * OLD * + + +_ BORN IN 1803 * OLD * + + +_ BORN IN 1804 * OLD * + + +_ BORN IN 1805 * OLD * + + +_ BORN IN 1806 * OLD * + + +_ BORN IN 1807 * OLD * + + +_ BORN IN 1808 * OLD * + + +_ BORN IN 1809 * OLD * + + +_ BORN IN 1810 * OLD * + + +_ BORN IN 1811 * OLD * + + +_ BORN IN 1812 * OLD * + + +_ BORN IN 1813 * OLD * + + +_ BORN IN 1814 * OLD * + + +_ BORN IN 1815 * OLD * + + +_ BORN IN 1816 * OLD * + + +_ BORN IN 1817 * OLD * + + +_ BORN IN 1818 * OLD * + + +_ BORN IN 1819 * OLD * + + +_ BORN IN 1820 * OLD * + + +_ BORN IN 1821 * OLD * + + +_ BORN IN 1822 * OLD * + + +_ BORN IN 1823 * OLD * + + +_ BORN IN 1824 * OLD * + + +_ BORN IN 1825 * OLD * + + +_ BORN IN 1826 * OLD * + + +_ BORN IN 1827 * OLD * + + +_ BORN IN 1828 * OLD * + + +_ BORN IN 1829 * OLD * + + +_ BORN IN 1830 * OLD * + + +_ BORN IN 1831 * OLD * + + +_ BORN IN 1832 * OLD * + + +_ BORN IN 1833 * OLD * + + +_ BORN IN 1834 * OLD * + + +_ BORN IN 1835 * OLD * + + +_ BORN IN 1836 * OLD * + + +_ BORN IN 1837 * OLD * + + +_ BORN IN 1838 * OLD * + + +_ BORN IN 1839 * OLD * + + +_ BORN IN 1840 * OLD * + + +_ BORN IN 1841 * OLD * + + +_ BORN IN 1842 * OLD * + + +_ BORN IN 1843 * OLD * + + +_ BORN IN 1844 * OLD * + + +_ BORN IN 1845 * OLD * + + +_ BORN IN 1846 * OLD * + + +_ BORN IN 1847 * OLD * + + +_ BORN IN 1848 * OLD * + + +_ BORN IN 1849 * OLD * + + +_ BORN IN 1850 * OLD * + + +_ BORN IN 1851 * OLD * + + +_ BORN IN 1852 * OLD * + + +_ BORN IN 1853 * OLD * + + +_ BORN IN 1854 * OLD * + + +_ BORN IN 1855 * OLD * + + +_ BORN IN 1856 * OLD * + + +_ BORN IN 1857 * OLD * + + +_ BORN IN 1858 * OLD * + + +_ BORN IN 1859 * OLD * + + +_ BORN IN 1860 * OLD * + + +_ BORN IN 1861 * OLD * + + +_ BORN IN 1862 * OLD * + + +_ BORN IN 1863 * OLD * + + +_ BORN IN 1864 * OLD * + + +_ BORN IN 1865 * OLD * + + +_ BORN IN 1866 * OLD * + + +_ BORN IN 1867 * OLD * + + +_ BORN IN 1868 * OLD * + + +_ BORN IN 1869 * OLD * + + +_ BORN IN 1870 * OLD * + + +_ BORN IN 1871 * OLD * + + +_ BORN IN 1872 * OLD * + + +_ BORN IN 1873 * OLD * + + +_ BORN IN 1874 * OLD * + + +_ BORN IN 1875 * OLD * + + +_ BORN IN 1876 * OLD * + + +_ BORN IN 1877 * OLD * + + +_ BORN IN 1878 * OLD * + + +_ BORN IN 1879 * OLD * + + +_ BORN IN 1880 * OLD * + + +_ BORN IN 1881 * OLD * + + +_ BORN IN 1882 * OLD * + + +_ BORN IN 1883 * OLD * + + +_ BORN IN 1884 * OLD * + + +_ BORN IN 1885 * OLD * + + +_ BORN IN 1886 * OLD * + + +_ BORN IN 1887 * OLD * + + +_ BORN IN 1888 * OLD * + + +_ BORN IN 1889 * OLD * + + +_ BORN IN 1890 * OLD * + + +_ BORN IN 1891 * OLD * + + +_ BORN IN 1892 * OLD * + + +_ BORN IN 1893 * OLD * + + +_ BORN IN 1894 * OLD * + + +_ BORN IN 1895 * OLD * + + +_ BORN IN 1896 * OLD * + + +_ BORN IN 1897 * OLD * + + +_ BORN IN 1898 * OLD * + + +_ BORN IN 1899 * OLD * + + +_ BORN IN 1900 * OLD * + + +_ BORN IN 1901 * OLD * + + +_ BORN IN 1902 * OLD * + + +_ BORN IN 1903 * OLD * + + +_ BORN IN 1904 * OLD * + + +_ BORN IN 1905 * OLD * + + +_ BORN IN 1906 * OLD * + + +_ BORN IN 1907 * OLD * + + +_ BORN IN 1908 * OLD * + + +_ BORN IN 1909 * OLD * + + +_ BORN IN 1910 * OLD * + + +_ BORN IN 1911 * OLD * + + +_ BORN IN 1912 * OLD * + + +_ BORN IN 1913 * OLD * + + +_ BORN IN 1914 * OLD * + + +_ BORN IN 1915 * OLD * + + +_ BORN IN 1916 * OLD * + + +_ BORN IN 1917 * OLD * + + +_ BORN IN 1918 * OLD * + + +_ BORN IN 1919 * OLD * + + +_ BORN IN 1920 * OLD * + + +_ BORN IN 1921 * OLD * + + +_ BORN IN 1922 * OLD * + + +_ BORN IN 1923 * OLD * + + +_ BORN IN 1924 * OLD * + + +_ BORN IN 1925 * OLD * + + +_ BORN IN 1926 * OLD * + + +_ BORN IN 1927 * OLD * + + +_ BORN IN 1928 * OLD * + + +_ BORN IN 1929 * OLD * + + +_ BORN IN 1930 * OLD * + + +_ BORN IN 1931 * OLD * + + +_ BORN IN 1932 * OLD * + + +_ BORN IN 1933 * OLD * + + +_ BORN IN 1934 * OLD * + + +_ BORN IN 1935 * OLD * + + +_ BORN IN 1936 * OLD * + + +_ BORN IN 1937 * OLD * + + +_ BORN IN 1938 * OLD * + + +_ BORN IN 1939 * OLD * + + +_ BORN IN 1940 * OLD * + + +_ BORN IN 1941 * OLD * + + +_ BORN IN 1942 * OLD * + + +_ BORN IN 1943 * OLD * + + +_ BORN IN 1944 * OLD * + + +_ BORN IN 1945 * OLD * + + +_ BORN IN 1946 * OLD * + + +_ BORN IN 1947 * OLD * + + +_ BORN IN 1948 * OLD * + + +_ BORN IN 1949 * OLD * + + +_ BORN IN 1950 * OLD * + + +_ BORN IN 1951 * OLD * + + +_ BORN IN 1952 * OLD * + + +_ BORN IN 1953 * OLD * + + +_ BORN IN 1954 * OLD * + + +_ BORN IN 1955 * OLD * + + +_ BORN IN 1956 * OLD * + + +_ BORN IN 1957 * OLD * + + +_ BORN IN 1958 * OLD * + + +_ BORN IN 1959 * OLD * + + +_ BORN IN 1960 * OLD * + + +_ BORN IN 1961 * OLD * + + +_ BORN IN 1962 * OLD * + + +_ BORN IN 1963 * OLD * + + +_ BORN IN 1964 * OLD * + + +_ BORN IN 1965 * OLD * + + +_ BORN IN 1966 * OLD * + + +_ BORN IN 1967 * OLD * + + +_ BORN IN 1968 * OLD * + + +_ BORN IN 1969 * OLD * + + +_ BORN IN 1970 * OLD * + + +_ BORN IN 1971 * OLD * + + +_ BORN IN 1972 * OLD * + + +_ BORN IN 1973 * OLD * + + +_ BORN IN 1974 * OLD * + + +_ BORN IN 1975 * OLD * + + +_ BORN IN 1976 * OLD * + + +_ BORN IN 1977 * OLD * + + +_ BORN IN 1978 * OLD * + + +_ BORN IN 1979 * OLD * + + +_ BORN IN 1980 * OLD * + + +_ BORN IN 1981 * OLD * + + +_ BORN IN 1982 * OLD * + + +_ BORN IN 1983 * OLD * + + +_ BORN IN 1984 * OLD * + + +_ BORN IN 1985 * OLD * + + +_ BORN IN 1986 * OLD * + + +_ BORN IN 1987 * OLD * + + +_ BORN IN 1988 * OLD * + + +_ BORN IN 1989 * OLD * + + +_ BORN IN 1990 * OLD * + + +_ BORN IN 1991 * OLD * + + +_ BORN IN 1992 * OLD * + + +_ BORN IN 1993 * OLD * + + +_ BORN IN 1994 * OLD * + + +_ BORN IN 1995 * OLD * + + +_ BORN IN 1996 * OLD * + + +_ BORN IN 1997 * OLD * + + +_ BORN IN 1998 * OLD * + + +_ BORN IN 1999 * OLD * + + +_ BORN IN 2000 * OLD * + + +_ BORN IN 2001 * OLD * + + +_ BORN IN 2002 * OLD * + + +_ BORN IN 2003 * OLD * + + +_ BORN IN 2004 * OLD * + + +_ BORN IN 2005 * OLD * + + +_ BORN IN 2006 * OLD * + + +_ BORN IN 2007 * OLD * + + +_ BORN IN 2008 * OLD * + + +_ BORN IN 2009 * OLD * + + +_ BORN IN 2010 * OLD * + + +_ BORN IN 2011 * OLD * + + +_ BORN IN 2012 * OLD * + + +I WAS BORN IN 1800 + + +I WAS BORN IN 1801 + + +I WAS BORN IN 1802 + + +I WAS BORN IN 1803 + + +I WAS BORN IN 1804 + + +I WAS BORN IN 1805 + + +I WAS BORN IN 1806 + + +I WAS BORN IN 1807 + + +I WAS BORN IN 1808 + + +I WAS BORN IN 1809 + + +I WAS BORN IN 1810 + + +I WAS BORN IN 1811 + + +I WAS BORN IN 1812 + + +I WAS BORN IN 1813 + + +I WAS BORN IN 1814 + + +I WAS BORN IN 1815 + + +I WAS BORN IN 1816 + + +I WAS BORN IN 1817 + + +I WAS BORN IN 1818 + + +I WAS BORN IN 1819 + + +I WAS BORN IN 1820 + + +I WAS BORN IN 1821 + + +I WAS BORN IN 1822 + + +I WAS BORN IN 1823 + + +I WAS BORN IN 1824 + + +I WAS BORN IN 1825 + + +I WAS BORN IN 1826 + + +I WAS BORN IN 1827 + + +I WAS BORN IN 1828 + + +I WAS BORN IN 1829 + + +I WAS BORN IN 1830 + + +I WAS BORN IN 1831 + + +I WAS BORN IN 1832 + + +I WAS BORN IN 1833 + + +I WAS BORN IN 1834 + + +I WAS BORN IN 1835 + + +I WAS BORN IN 1836 + + +I WAS BORN IN 1837 + + +I WAS BORN IN 1838 + + +I WAS BORN IN 1839 + + +I WAS BORN IN 1840 + + +I WAS BORN IN 1841 + + +I WAS BORN IN 1842 + + +I WAS BORN IN 1843 + + +I WAS BORN IN 1844 + + +I WAS BORN IN 1845 + + +I WAS BORN IN 1846 + + +I WAS BORN IN 1847 + + +I WAS BORN IN 1848 + + +I WAS BORN IN 1849 + + +I WAS BORN IN 1850 + + +I WAS BORN IN 1851 + + +I WAS BORN IN 1852 + + +I WAS BORN IN 1853 + + +I WAS BORN IN 1854 + + +I WAS BORN IN 1855 + + +I WAS BORN IN 1856 + + +I WAS BORN IN 1857 + + +I WAS BORN IN 1858 + + +I WAS BORN IN 1859 + + +I WAS BORN IN 1860 + + +I WAS BORN IN 1861 + + +I WAS BORN IN 1862 + + +I WAS BORN IN 1863 + + +I WAS BORN IN 1864 + + +I WAS BORN IN 1865 + + +I WAS BORN IN 1866 + + +I WAS BORN IN 1867 + + +I WAS BORN IN 1868 + + +I WAS BORN IN 1869 + + +I WAS BORN IN 1870 + + +I WAS BORN IN 1871 + + +I WAS BORN IN 1872 + + +I WAS BORN IN 1873 + + +I WAS BORN IN 1874 + + +I WAS BORN IN 1875 + + +I WAS BORN IN 1876 + + +I WAS BORN IN 1877 + + +I WAS BORN IN 1878 + + +I WAS BORN IN 1879 + + +I WAS BORN IN 1880 + + +I WAS BORN IN 1881 + + +I WAS BORN IN 1882 + + +I WAS BORN IN 1883 + + +I WAS BORN IN 1884 + + +I WAS BORN IN 1885 + + +I WAS BORN IN 1886 + + +I WAS BORN IN 1887 + + +I WAS BORN IN 1888 + + +I WAS BORN IN 1889 + + +I WAS BORN IN 1890 + + +I WAS BORN IN 1891 + + +I WAS BORN IN 1892 + + +I WAS BORN IN 1893 + + +I WAS BORN IN 1894 + + +I WAS BORN IN 1895 + + +I WAS BORN IN 1896 + + +I WAS BORN IN 1897 + + +I WAS BORN IN 1898 + + +I WAS BORN IN 1899 + + +I WAS BORN IN 1900 + + +I WAS BORN IN 1901 + + +I WAS BORN IN 1902 + + +I WAS BORN IN 1903 + + +I WAS BORN IN 1904 + + +I WAS BORN IN 1905 + + +I WAS BORN IN 1906 + + +I WAS BORN IN 1907 + + +I WAS BORN IN 1908 + + +I WAS BORN IN 1909 + + +I WAS BORN IN 1910 + + +I WAS BORN IN 1911 + + +I WAS BORN IN 1912 + + +I WAS BORN IN 1913 + + +I WAS BORN IN 1914 + + +I WAS BORN IN 1915 + + +I WAS BORN IN 1916 + + +I WAS BORN IN 1917 + + +I WAS BORN IN 1918 + + +I WAS BORN IN 1919 + + +I WAS BORN IN 1920 + + +I WAS BORN IN 1921 + + +I WAS BORN IN 1922 + + +I WAS BORN IN 1923 + + +I WAS BORN IN 1924 + + +I WAS BORN IN 1925 + + +I WAS BORN IN 1926 + + +I WAS BORN IN 1927 + + +I WAS BORN IN 1928 + + +I WAS BORN IN 1929 + + +I WAS BORN IN 1930 + + +I WAS BORN IN 1931 + + +I WAS BORN IN 1932 + + +I WAS BORN IN 1933 + + +I WAS BORN IN 1934 + + +I WAS BORN IN 1935 + + +I WAS BORN IN 1936 + + +I WAS BORN IN 1937 + + +I WAS BORN IN 1938 + + +I WAS BORN IN 1939 + + +I WAS BORN IN 1940 + + +I WAS BORN IN 1941 + + +I WAS BORN IN 1942 + + +I WAS BORN IN 1943 + + +I WAS BORN IN 1944 + + +I WAS BORN IN 1945 + + +I WAS BORN IN 1946 + + +I WAS BORN IN 1947 + + +I WAS BORN IN 1948 + + +I WAS BORN IN 1949 + + +I WAS BORN IN 1950 + + +I WAS BORN IN 1951 + + +I WAS BORN IN 1952 + + +I WAS BORN IN 1953 + + +I WAS BORN IN 1954 + + +I WAS BORN IN 1955 + + +I WAS BORN IN 1956 + + +I WAS BORN IN 1957 + + +I WAS BORN IN 1958 + + +I WAS BORN IN 1959 + + +I WAS BORN IN 1960 + + +I WAS BORN IN 1961 + + +I WAS BORN IN 1962 + + +I WAS BORN IN 1963 + + +I WAS BORN IN 1964 + + +I WAS BORN IN 1965 + + +I WAS BORN IN 1966 + + +I WAS BORN IN 1967 + + +I WAS BORN IN 1968 + + +I WAS BORN IN 1969 + + +I WAS BORN IN 1970 + + +I WAS BORN IN 1971 + + +I WAS BORN IN 1972 + + +I WAS BORN IN 1973 + + +I WAS BORN IN 1974 + + +I WAS BORN IN 1975 + + +I WAS BORN IN 1976 + + +I WAS BORN IN 1977 + + +I WAS BORN IN 1978 + + +I WAS BORN IN 1979 + + +I WAS BORN IN 1980 + + +I WAS BORN IN 1981 + + +I WAS BORN IN 1982 + + +I WAS BORN IN 1983 + + +I WAS BORN IN 1984 + + +I WAS BORN IN 1985 + + +I WAS BORN IN 1986 + + +I WAS BORN IN 1987 + + +I WAS BORN IN 1988 + + +I WAS BORN IN 1989 + + +I WAS BORN IN 1990 + + +I WAS BORN IN 1991 + + +I WAS BORN IN 1992 + + +I WAS BORN IN 1993 + + +I WAS BORN IN 1994 + + +I WAS BORN IN 1995 + + +I WAS BORN IN 1996 + + +I WAS BORN IN 1997 + + +I WAS BORN IN 1998 + + +I WAS BORN IN 1999 + + +I WAS BORN IN 2000 + + +I WAS BORN IN 2001 + + +I WAS BORN IN 2002 + + +I WAS BORN IN 2003 + + +I WAS BORN IN 2004 + + +I WAS BORN IN 2005 + + +I WAS BORN IN 2006 + + +I WAS BORN IN 2007 + + +I WAS BORN IN 2008 + + +I WAS BORN IN 2009 + + +I WAS BORN IN 2010 + + +I WAS BORN IN 2011 + + +I WAS BORN IN 2012 + + +YEARFROMAGE +