Skip to content

Commit 1c1c083

Browse files
committed
Add usage for commands
1 parent eb2e830 commit 1c1c083

15 files changed

Lines changed: 127 additions & 48 deletions

SteamChatBot/MainWindow.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ private void plusTriggerButton_Click(object sender, RoutedEventArgs e)
312312
ccaw.apiBlock.PreviewMouseDown += (sender1, e1) => Ccaw_PreviewMouseDown_Wunderground(sender1, e1, ccaw);
313313
break;
314314
case "youtubeTrigger":
315+
MessageBox.Show("You MUST name your project \"Steam Chat Bot\" or else this trigger will not work!", "Information", MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
315316
ccaw.apiBlock.PreviewMouseDown += (sender1, e1) => Ccaw_PreviewMouseDown1_Google(sender1, e1, ccaw);
316317
break;
317318
}

SteamChatBot/Triggers/BanCheckTrigger.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ private bool Respond(SteamID toID, SteamID userID, string message, bool room)
3737
SendMessageAfterDelay(toID, "You must declare a Steam API key to use this trigger.", room);
3838
return false;
3939
}
40-
if(query != null && query[1] != null)
40+
41+
if(query != null && query.Length == 1)
42+
{
43+
SendMessageAfterDelay(toID, "Usage: " + Options.ChatCommandApi.ChatCommand.Command + " <steamid64>", room);
44+
return true;
45+
}
46+
else if(query != null && query[1] != null)
4147
{
4248
if (query[1] != null)
4349
{

SteamChatBot/Triggers/ChangeNameTrigger.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ public override bool respondToFriendMessage(SteamID userID, string message)
2626
private bool Respond(SteamID toID, SteamID userID, string message, bool room)
2727
{
2828
string[] query = StripCommand(message, Options.ChatCommand.Command);
29-
if(query != null && query.Length >= 2)
29+
if (query != null && query.Length == 1)
30+
{
31+
SendMessageAfterDelay(toID, "Usage: " + Options.ChatCommand.Command + " <new name>", room);
32+
return true;
33+
}
34+
else if (query != null && query.Length >= 2)
3035
{
3136
string name = "";
3237
for (int i = 1; i < query.Length; i++)

SteamChatBot/Triggers/ChooseTrigger.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ public override bool respondToFriendMessage(SteamID userID, string message)
2626
private bool Respond(SteamID toID, SteamID userID, string message, bool room)
2727
{
2828
string[] query = StripCommand(message, Options.ChatCommand.Command);
29-
if(query != null && query.Length > 2)
29+
if(query != null && query.Length == 1)
30+
{
31+
SendMessageAfterDelay(toID, "Usage: " + Options.ChatCommand.Command + " <item1> <item2> ...", room);
32+
return true;
33+
}
34+
else if(query != null && query.Length > 2)
3035
{
3136
List<string> removed = new List<string>();
3237
for (int i = 1; i < query.Length; i++)

SteamChatBot/Triggers/GoogleTrigger.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ public override bool respondToFriendMessage(SteamID userID, string message)
2929
private bool Respond(SteamID toID, SteamID userID, string message, bool room)
3030
{
3131
string[] query = StripCommand(message, Options.ChatCommand.Command);
32-
if(query != null && query.Length >= 2)
32+
if (query != null && query.Length == 1)
33+
{
34+
SendMessageAfterDelay(toID, "Usage: " + Options.ChatCommand.Command + " <query>", room);
35+
return true;
36+
}
37+
else if (query != null && query.Length >= 2)
3338
{
3439
string q = "";
3540
for (int i = 1; i < query.Length; i++)

SteamChatBot/Triggers/IsUpTrigger.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ public override bool respondToChatMessage(SteamID roomID, SteamID chatterID, str
2929
private bool Respond(SteamID toID, SteamID userID, string message, bool room)
3030
{
3131
string[] query = StripCommand(message, Options.ChatCommand.Command);
32-
if (query != null)
32+
if (query != null && query.Length == 1)
33+
{
34+
SendMessageAfterDelay(toID, "Usage: " + Options.ChatCommand.Command + " <url>", room);
35+
return true;
36+
}
37+
else if (query != null && query.Length == 2)
3338
{
3439
HttpWebResponse response;
3540
try

SteamChatBot/Triggers/KickTrigger.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ public override bool respondToChatMessage(SteamID roomID, SteamID chatterId, str
2323
private bool Respond(SteamID toID, SteamID userID, string message)
2424
{
2525
string[] query = StripCommand(message, Options.ChatCommand.Command);
26-
if(query != null && query[1] != null)
26+
if (query != null && query.Length == 1)
27+
{
28+
SendMessageAfterDelay(toID, "Usage: " + Options.ChatCommand.Command + " <steamid64>", true);
29+
return true;
30+
}
31+
else if (query != null && query[1] != null)
2732
{
2833
Bot.steamFriends.KickChatMember(toID, new SteamID(Convert.ToUInt64(query[1])));
2934
return true;

SteamChatBot/Triggers/LockChatTrigger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public override bool respondToChatMessage(SteamID roomID, SteamID chatterId, str
2424
private bool Respond(SteamID roomID, string message)
2525
{
2626
string[] query = StripCommand(message, Options.ChatCommand.Command);
27-
if(query != null)
27+
if (query != null)
2828
{
2929
var msg = new ClientMsg<MsgClientChatAction>();
3030
msg.Body.SteamIdChat = SteamHelper.ToChatID(roomID);

SteamChatBot/Triggers/NoteTrigger.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,12 @@ private bool Respond(SteamID roomID, SteamID userID, string message)
9393
}
9494

9595
query = StripCommand(message, Options.NoteTriggerOptions.DeleteCommand);
96-
if (query != null && query.Length == 2)
96+
if(query != null && query.Length == 1)
97+
{
98+
SendMessageAfterDelay(roomID, "Usage: " + Options.NoteTriggerOptions.DeleteCommand + " <note name>", true);
99+
return true;
100+
}
101+
else if (query != null && query.Length == 2)
97102
{
98103
string name = query[1];
99104
if (!db.ContainsKey(name))
@@ -110,7 +115,12 @@ private bool Respond(SteamID roomID, SteamID userID, string message)
110115
}
111116

112117
query = StripCommand(message, Options.NoteTriggerOptions.InfoCommand);
113-
if(query != null && query.Length == 2)
118+
if (query != null && query.Length == 1)
119+
{
120+
SendMessageAfterDelay(roomID, "Usage: " + Options.NoteTriggerOptions.InfoCommand + " <note name>", true);
121+
return true;
122+
}
123+
else if (query != null && query.Length == 2)
114124
{
115125
string name = query[1];
116126
if (!db.ContainsKey(name))
@@ -127,7 +137,12 @@ private bool Respond(SteamID roomID, SteamID userID, string message)
127137
}
128138

129139
query = StripCommand(message, Options.NoteTriggerOptions.NoteCommand);
130-
if (query != null && query.Length == 2)
140+
if (query != null && query.Length == 1)
141+
{
142+
SendMessageAfterDelay(roomID, "Usage: " + Options.NoteTriggerOptions.NoteCommand + " <note name> [note content]", true);
143+
return true;
144+
}
145+
else if (query != null && query.Length == 2)
131146
{
132147
string name = query[1];
133148
if (!db.ContainsKey(name))

SteamChatBot/Triggers/NotificationTrigger.cs

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,17 @@ public override bool onLoggedOn()
4343
Options.NotificationOptions.DB = JsonConvert.DeserializeObject<Dictionary<ulong, DB>>(File.ReadAllText(Options.NotificationOptions.DBFile));
4444
Log.Instance.Silly("{0}/{1}: Read db from {2}", Bot.username, Name, Options.NotificationOptions.DBFile);
4545
}
46-
catch(FileNotFoundException fnfe)
46+
catch (FileNotFoundException fnfe)
4747
{
4848
File.Create(Options.NotificationOptions.DBFile);
4949
}
50-
catch(Exception e)
50+
catch (Exception e)
5151
{
5252
Log.Instance.Error(e.StackTrace);
5353
return false;
5454
}
5555

56-
if(Options.NotificationOptions.DB == null)
56+
if (Options.NotificationOptions.DB == null)
5757
{
5858
Options.NotificationOptions.DB = new Dictionary<ulong, DB>();
5959
}
@@ -74,7 +74,6 @@ public override bool respondToChatMessage(SteamID roomID, SteamID chatterId, str
7474

7575
private bool Respond(SteamID toID, SteamID userID, string message, bool room)
7676
{
77-
bool messageSent = false;
7877
CheckIfDBExists(userID);
7978
Dictionary<ulong, DB> db = Options.NotificationOptions.DB;
8079

@@ -83,27 +82,37 @@ private bool Respond(SteamID toID, SteamID userID, string message, bool room)
8382
db[userID].name = Bot.steamFriends.GetFriendPersonaName(userID);
8483

8584
string[] query = StripCommand(message, Options.NotificationOptions.SeenCommand);
85+
if (query != null && query.Length == 1)
86+
{
87+
SendMessageAfterDelay(toID, "Usage: " + Options.NotificationOptions.SeenCommand + " <steamid64>", room);
88+
return true;
89+
}
8690
if (query != null && query.Length == 2)
8791
{
8892
if (!db.ContainsKey(Convert.ToUInt64(query[1])) || db[Convert.ToUInt64(query[1])] == null)
8993
{
9094
SendMessageAfterDelay(toID, "The user " + query[1] + " was not found.", room);
91-
messageSent = true;
95+
return true;
9296
}
9397
else
9498
{
9599
SendMessageAfterDelay(toID, string.Format("I last saw {0} on {1} at {2}", db[Convert.ToUInt64(query[1])].name, db[Convert.ToUInt64(query[1])].seen.ToShortDateString(), db[Convert.ToUInt64(query[1])].seen.ToShortTimeString()), room);
96-
messageSent = true;
100+
return true;
97101
}
98102
}
99103

100104
query = StripCommand(message, Options.NotificationOptions.APICommand);
101-
if(query != null && userID != toID)
105+
if (query != null && userID != toID)
102106
{
103107
SendMessageAfterDelay(toID, "This command will only work in private to protect privacy.", room);
104-
messageSent = true;
108+
return true;
105109
}
106-
else if(query != null && query.Length == 2 && userID == toID)
110+
else if (query != null && userID == toID && query.Length == 1)
111+
{
112+
SendMessageAfterDelay(toID, "Usage: " + Options.NotificationOptions.APICommand + " <apikey>", room);
113+
return true;
114+
}
115+
else if (query != null && query.Length == 2 && userID == toID)
107116
{
108117
CheckIfDBExists(userID);
109118
string api = query[1];
@@ -116,27 +125,27 @@ private bool Respond(SteamID toID, SteamID userID, string message, bool room)
116125
};
117126

118127
PushResponse response = client.PushNote(note);
119-
if(response == null)
128+
if (response == null)
120129
{
121130
SendMessageAfterDelay(toID, "Your push failed. Most likely your API key is incorrect.", room);
122-
messageSent = true;
131+
return true;
123132
}
124133
else
125134
{
126135
SendMessageAfterDelay(toID, "Your push was a success.", room);
127-
messageSent = true;
136+
return true;
128137
}
129138
}
130139

131140
query = StripCommand(message, Options.NotificationOptions.FilterCommand);
132-
if(query != null && query.Length == 1)
141+
if (query != null && query.Length == 1)
133142
{
134-
SendMessageAfterDelay(toID, "Available sub commands: add, list, clear, delete", room);
135-
messageSent = true;
143+
SendMessageAfterDelay(toID, "Usage: " + Options.NotificationOptions.FilterCommand + "<subcommand> [query]\nAvailable sub commands: add, list, clear, delete", room);
144+
return true;
136145
}
137-
else if(query != null && query.Length >= 2)
146+
else if (query != null && query.Length >= 2)
138147
{
139-
if(query[1] == "add" && query.Length >= 3)
148+
if (query[1] == "add" && query.Length >= 3)
140149
{
141150

142151
List<string> words = new List<string>();
@@ -149,42 +158,42 @@ private bool Respond(SteamID toID, SteamID userID, string message, bool room)
149158

150159
db[userID].pb.filter = words;
151160
SendMessageAfterDelay(toID, "Your filter has been successfully modified.", room);
152-
messageSent = true;
161+
return true;
153162
}
154-
else if(query[1] == "list" && query.Length == 2)
163+
else if (query[1] == "list" && query.Length == 2)
155164
{
156165
if (db[userID].pb.filter.Count > 0)
157166
{
158167
string words = string.Join(", ", db[userID].pb.filter);
159168
SendMessageAfterDelay(userID, "Your filter: " + words, false);
160-
messageSent = true;
169+
return true;
161170
}
162171
else
163172
{
164173
SendMessageAfterDelay(userID, "Your filter is empty. Use \"!filter add <words>\" to add to your filter", false);
165-
messageSent = true;
174+
return true;
166175
}
167176
}
168-
else if(query[1] == "clear" && query.Length == 2)
177+
else if (query[1] == "clear" && query.Length == 2)
169178
{
170179
db[userID].pb.filter.Clear();
171180
SendMessageAfterDelay(toID, "Your filter has been cleared", room);
172-
messageSent = true;
181+
return true;
173182
}
174-
else if(query[1] == "delete" && query.Length == 3)
183+
else if (query[1] == "delete" && query.Length == 3)
175184
{
176185
db[userID].pb.filter.Remove(query[2]);
177186
SendMessageAfterDelay(toID, "The filter \"" + query[2] + "\" has been removed", room);
178-
messageSent = true;
187+
return true;
179188
}
180189
}
181190

182191
query = StripCommand(message, Options.NotificationOptions.ClearCommand);
183-
if(query != null)
192+
if (query != null)
184193
{
185194
db[userID] = null;
186195
SendMessageAfterDelay(toID, "Your database file has been cleared.", room);
187-
messageSent = true;
196+
return true;
188197
}
189198

190199

@@ -211,8 +220,7 @@ private bool Respond(SteamID toID, SteamID userID, string message, bool room)
211220
}
212221
}
213222
}
214-
215-
return messageSent;
223+
return false;
216224
}
217225

218226
private void CheckIfDBExists(SteamID userID)

0 commit comments

Comments
 (0)