funny react
This commit is contained in:
31
Program.cs
31
Program.cs
@@ -2,13 +2,14 @@ using Valour.Sdk.Client;
|
||||
using Valour.Sdk.Models;
|
||||
using DotNetEnv;
|
||||
using SkyBot;
|
||||
using System.Text;
|
||||
|
||||
Env.Load();
|
||||
|
||||
var token = Environment.GetEnvironmentVariable("TOKEN");
|
||||
var allowedUserIds = new List<long> { 15652354820931584 };
|
||||
var ownerId = 15652354820931584;
|
||||
var prefix = "s/";
|
||||
var prefix = "sd/";
|
||||
|
||||
var client = new ValourClient("https://api.valour.gg/");
|
||||
client.SetupHttpClient();
|
||||
@@ -66,6 +67,32 @@ client.MessageService.MessageReceived += async (message) =>
|
||||
}
|
||||
};
|
||||
|
||||
if (Utils.ContainsAny(content, $"{prefix}react"))
|
||||
{
|
||||
if (message.AuthorUserId != ownerId) return;
|
||||
|
||||
string[] args = content.Split(' ', StringSplitOptions.RemoveEmptyEntries);
|
||||
if (args.Length < 2) return;
|
||||
string emoji = args[1];
|
||||
|
||||
var interceptor = new Utils.ReactionInterceptor(Console.Out);
|
||||
Console.SetOut(interceptor);
|
||||
|
||||
while (true)
|
||||
{
|
||||
interceptor.Reset();
|
||||
await message.AddReactionAsync(emoji);
|
||||
if (interceptor.DetectedAlreadyExists)
|
||||
{
|
||||
Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true });
|
||||
Console.WriteLine("Reaction already exists, stopping.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = true });
|
||||
}
|
||||
|
||||
var echoprefixes = new[] { $"{prefix}echo"};
|
||||
if (Utils.ContainsAny(content, echoprefixes))
|
||||
{
|
||||
@@ -219,4 +246,4 @@ client.MessageService.MessageReceived += async (message) =>
|
||||
};
|
||||
|
||||
Console.WriteLine("Listening for messages...");
|
||||
await Task.Delay(Timeout.Infinite);
|
||||
await Task.Delay(Timeout.Infinite);
|
||||
|
||||
Reference in New Issue
Block a user