mirror of
https://github.com/liyunze-coding/rython-task-bot-v2.git
synced 2026-09-22 07:24:27 +00:00
added Count command
This commit is contained in:
parent
58de6ea012
commit
b065cd2138
2 changed files with 50 additions and 7 deletions
47
Code.cs
47
Code.cs
|
|
@ -236,8 +236,8 @@ public static class MessageBuilder
|
||||||
{
|
{
|
||||||
if (logged.Count > 0 && failed.Count == 0)
|
if (logged.Count > 0 && failed.Count == 0)
|
||||||
{
|
{
|
||||||
string response = $"Task List Update ♡ → The task(s) {String.Join(", ", logged)} have been logged! Good luck! 🍀";
|
string response = $"Task List Update ♡ → The task(s) {String.Join(", ", logged)} have been logged! Good job! 🍀";
|
||||||
return response.Length > TaskHelpers.CharacterLimit ? "Task List Update ♡ → Your task(s) have been logged! Good luck! 🍀" : response;
|
return response.Length > TaskHelpers.CharacterLimit ? "Task List Update ♡ → Your task(s) have been logged! Good job! 🍀" : response;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (logged.Count == 0 && failed.Count == 1)
|
if (logged.Count == 0 && failed.Count == 1)
|
||||||
|
|
@ -463,6 +463,8 @@ public class TaskOperations
|
||||||
tasks[i].Focused = false;
|
tasks[i].Focused = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void SaveIntoTasks(List<Task> tasks)
|
public void SaveIntoTasks(List<Task> tasks)
|
||||||
{
|
{
|
||||||
string key = getKey();
|
string key = getKey();
|
||||||
|
|
@ -594,6 +596,16 @@ public class CPHInline
|
||||||
CPH.SetGlobalVar("rython-task-bot", taskDataString, true);
|
CPH.SetGlobalVar("rython-task-bot", taskDataString, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int GetCount(string? key = null)
|
||||||
|
{
|
||||||
|
if (String.IsNullOrEmpty(key))
|
||||||
|
{
|
||||||
|
key = GetKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
return taskData[key].TotalCompletedCount;
|
||||||
|
}
|
||||||
|
|
||||||
private void Respond(string message)
|
private void Respond(string message)
|
||||||
{
|
{
|
||||||
CPH.TryGetArg("userType", out string platform);
|
CPH.TryGetArg("userType", out string platform);
|
||||||
|
|
@ -1073,6 +1085,37 @@ public class CPHInline
|
||||||
Respond("📝 All tasks (excluding the streamer's) have been cleared!");
|
Respond("📝 All tasks (excluding the streamer's) have been cleared!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CountCommand()
|
||||||
|
{
|
||||||
|
CPH.TryGetArg("rawInput", out string rawInput);
|
||||||
|
rawInput = rawInput.Trim();
|
||||||
|
string key = null;
|
||||||
|
bool someoneElse = false;
|
||||||
|
if (!String.IsNullOrWhiteSpace(rawInput))
|
||||||
|
{
|
||||||
|
key = GetKey(rawInput);
|
||||||
|
if (key == "")
|
||||||
|
{
|
||||||
|
Respond("❌ User not found");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
someoneElse = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int completedCount = GetCount(key);
|
||||||
|
if (someoneElse)
|
||||||
|
{
|
||||||
|
string username = GetUsername(key);
|
||||||
|
Respond($"{username} has completed {completedCount} task(s) so far!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Respond($"You have completed {completedCount} task(s) so far!");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue