mirror of
https://github.com/liyunze-coding/rython-task-bot-v2.git
synced 2026-09-22 07:24:27 +00:00
0.2.3 Break long messages into multiple chunks
This commit is contained in:
parent
b2d7c74cf9
commit
b8aef79f4b
2 changed files with 31 additions and 2 deletions
31
Code.cs
31
Code.cs
|
|
@ -463,7 +463,6 @@ public class TaskOperations
|
||||||
{
|
{
|
||||||
for (int i = 0; i < tasks.Count; i++)
|
for (int i = 0; i < tasks.Count; i++)
|
||||||
tasks[i].Focused = false;
|
tasks[i].Focused = false;
|
||||||
|
|
||||||
return tasks;
|
return tasks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -610,7 +609,37 @@ public class CPHInline
|
||||||
|
|
||||||
private void Respond(string message)
|
private void Respond(string message)
|
||||||
{
|
{
|
||||||
|
int maxChars = 500;
|
||||||
|
|
||||||
CPH.TryGetArg("userType", out string platform);
|
CPH.TryGetArg("userType", out string platform);
|
||||||
|
if (platform == "youtube") {
|
||||||
|
maxChars = 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
string[] words = message.Split(' ');
|
||||||
|
string output = "";
|
||||||
|
foreach (string word in words)
|
||||||
|
{
|
||||||
|
if ((output + " " + word).Length > maxChars)
|
||||||
|
{
|
||||||
|
SendMessage(output.Trim(), platform);
|
||||||
|
output = word;
|
||||||
|
CPH.Wait(100);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
output += (string.IsNullOrEmpty(output) ? "" : " ") + word;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(output))
|
||||||
|
{
|
||||||
|
SendMessage(output.Trim(), platform);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SendMessage(string message, string platform = "twitch")
|
||||||
|
{
|
||||||
switch (platform)
|
switch (platform)
|
||||||
{
|
{
|
||||||
case "twitch":
|
case "twitch":
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue