forked from adam/discord-bot-shtik
less nonsense initialization
This commit is contained in:
parent
818cb22c21
commit
fa674398ce
41
Program.cs
41
Program.cs
@ -13,14 +13,13 @@ namespace silverworker_discord
|
|||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
private DiscordSocketClient _client;
|
private DiscordSocketClient _client;
|
||||||
private Random r = new Random();
|
|
||||||
|
|
||||||
IConfigurationRoot config = new ConfigurationBuilder()
|
IConfigurationRoot config = new ConfigurationBuilder()
|
||||||
.AddJsonFile("appsettings.json", true, true)
|
.AddJsonFile("appsettings.json", true, true)
|
||||||
.Build();
|
.Build();
|
||||||
|
|
||||||
int initNonce;
|
private ISocketMessageChannel botChatterChannel = null;
|
||||||
private ISocketMessageChannel targetChannel = null;
|
private ISocketMessageChannel announcementChannel = null;
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
=> new Program().MainAsync().GetAwaiter().GetResult();
|
=> new Program().MainAsync().GetAwaiter().GetResult();
|
||||||
@ -31,7 +30,6 @@ namespace silverworker_discord
|
|||||||
}
|
}
|
||||||
public async Task MainAsync()
|
public async Task MainAsync()
|
||||||
{
|
{
|
||||||
initNonce = r.Next();
|
|
||||||
_client = new DiscordSocketClient();
|
_client = new DiscordSocketClient();
|
||||||
|
|
||||||
_client.Log += Log;
|
_client.Log += Log;
|
||||||
@ -42,12 +40,11 @@ namespace silverworker_discord
|
|||||||
_client.MessageReceived += MessageReceived;
|
_client.MessageReceived += MessageReceived;
|
||||||
_client.UserJoined += UserJoined;
|
_client.UserJoined += UserJoined;
|
||||||
|
|
||||||
_client.Ready += () =>
|
_client.Ready += () => Task.Run(() =>{
|
||||||
{
|
Console.WriteLine("Bot is connected!");
|
||||||
Console.WriteLine("Bot is connected! this is the dumbest.");
|
botChatterChannel = _client.GetChannel(ulong.Parse(config["botChatterChannel"])) as ISocketMessageChannel;
|
||||||
var wh = new Discord.Webhook.DiscordWebhookClient(config["initWebhook"]);
|
announcementChannel = _client.GetChannel(ulong.Parse(config["announcementChannel"])) as ISocketMessageChannel;
|
||||||
return wh.SendMessageAsync(initNonce.ToString(), username: "silver loop");
|
});
|
||||||
};
|
|
||||||
// Block this task until the program is closed.
|
// Block this task until the program is closed.
|
||||||
await Task.Delay(-1);
|
await Task.Delay(-1);
|
||||||
}
|
}
|
||||||
@ -59,24 +56,16 @@ namespace silverworker_discord
|
|||||||
if (message.Author.Id == _client.CurrentUser.Id) return;
|
if (message.Author.Id == _client.CurrentUser.Id) return;
|
||||||
|
|
||||||
Console.WriteLine($"{message.Channel}, {message.Content}, {message.Id}");
|
Console.WriteLine($"{message.Channel}, {message.Content}, {message.Id}");
|
||||||
if(targetChannel == null &&
|
if (message.Channel.Id == botChatterChannel.Id)
|
||||||
message.Author.Username == "silver loop" && message.Content == initNonce.ToString())
|
|
||||||
{
|
{
|
||||||
targetChannel = message.Channel;
|
if(message.Attachments?.Count > 0)
|
||||||
Task.WaitAll(message.DeleteAsync(), targetChannel.SendMessageAsync("this initialization is nonsense lol"));
|
|
||||||
}
|
|
||||||
else if (message.Channel.Id != targetChannel.Id)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(message.Attachments?.Count > 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine(message.Attachments.Count);
|
|
||||||
foreach (var att in message.Attachments)
|
|
||||||
{
|
{
|
||||||
Console.WriteLine(att.Url);
|
Console.WriteLine(message.Attachments.Count);
|
||||||
await WebRequest.Create("http://192.168.1.151:3001/shortcuts?display_url=" + att.Url).GetResponseAsync();
|
foreach (var att in message.Attachments)
|
||||||
|
{
|
||||||
|
Console.WriteLine(att.Url);
|
||||||
|
await WebRequest.Create("http://192.168.1.151:3001/shortcuts?display_url=" + att.Url).GetResponseAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
{
|
{
|
||||||
"token": "59 chars",
|
"token": "59 chars",
|
||||||
"initWebhook": "https://discord.com/api/webhooks/ and then a bunch of other stuff, just make one and coyp it"
|
"initWebhook": "https://discord.com/api/webhooks/ and then a bunch of other stuff, just make one and coyp it",
|
||||||
|
"botChatterChannel": 0,
|
||||||
|
"announcementChannel": 0
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user