|
@@ -77,11 +77,12 @@ public class SimpleShell {
|
77
|
77
|
}
|
78
|
78
|
|
79
|
79
|
// messages
|
80
|
|
- if (list.contains("messages")) {
|
|
80
|
+ if (list.contains("messages") && list.size() == 1) {
|
81
|
81
|
System.out.println(webber.get_messages());
|
82
|
82
|
continue;
|
83
|
83
|
}
|
84
|
84
|
|
|
85
|
+ //Post new user
|
85
|
86
|
if (list.contains("ids") && list.size() > 1 && !webber.githubIdExists(list.get(2))) {
|
86
|
87
|
Id id = new Id(list.get(1), list.get(2));
|
87
|
88
|
webber.postNewUser(id);
|
|
@@ -93,6 +94,7 @@ public class SimpleShell {
|
93
|
94
|
continue;
|
94
|
95
|
}
|
95
|
96
|
|
|
97
|
+ //Update user name
|
96
|
98
|
if (list.contains("ids") && list.size() > 1 && webber.githubIdExists(list.get(2))) {
|
97
|
99
|
Id id = new Id(list.get(1), list.get(2));
|
98
|
100
|
webber.putNewName(id);
|
|
@@ -103,7 +105,44 @@ public class SimpleShell {
|
103
|
105
|
}
|
104
|
106
|
continue;
|
105
|
107
|
}
|
106
|
|
- // you need to add a bunch more.
|
|
108
|
+
|
|
109
|
+ //get my messages
|
|
110
|
+ if (list.contains("messages") && list.size() == 2) {
|
|
111
|
+ System.out.println(webber.getMyMessages(list.get(1)));
|
|
112
|
+ continue;
|
|
113
|
+ }
|
|
114
|
+
|
|
115
|
+ //send a message to timeline
|
|
116
|
+ if (list.contains("send") && !list.contains("to")) {
|
|
117
|
+ String phrase = "";
|
|
118
|
+ for (int i = 2; i < list.size(); i++) {
|
|
119
|
+ phrase += list.get(i);
|
|
120
|
+ }
|
|
121
|
+ Message message = new Message(list.get(1), "", phrase);
|
|
122
|
+ webber.sendMessage(message);
|
|
123
|
+ if(webber.messageExists(phrase)) {
|
|
124
|
+ System.out.println("Message posted to timeline.");
|
|
125
|
+ } else {
|
|
126
|
+ System.out.println("Error posting message.");
|
|
127
|
+ }
|
|
128
|
+ continue;
|
|
129
|
+ }
|
|
130
|
+
|
|
131
|
+ //send a message to someone
|
|
132
|
+ if (list.contains("send") && list.contains("to")) {
|
|
133
|
+ String phrase = "";
|
|
134
|
+ for (int i = 2; i < list.size() - 2; i++) {
|
|
135
|
+ phrase += list.get(i);
|
|
136
|
+ }
|
|
137
|
+ Message message = new Message(list.get(1), list.get(list.size() - 1), phrase);
|
|
138
|
+ webber.sendMessage(message);
|
|
139
|
+ if(webber.messageExists(phrase)) {
|
|
140
|
+ System.out.println("Message posted to: " + list.get(list.size() - 1));
|
|
141
|
+ } else {
|
|
142
|
+ System.out.println("Error posting message to: " + list.get(list.size() - 1));
|
|
143
|
+ }
|
|
144
|
+ continue;
|
|
145
|
+ }
|
107
|
146
|
|
108
|
147
|
//!! command returns the last command in history
|
109
|
148
|
if (list.get(list.size() - 1).equals("!!")) {
|