Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Discord;
- using Discord.API;
- using Discord.WebSocket;
- using HtmlAgilityPack;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Net;
- using System.Net.Http;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading;
- using System.Threading.Tasks;
- using System.Reflection;
- using System.Diagnostics;
- using Discord.Audio;
- namespace MathProof
- {
- class Program
- {
- static void Main(string[] args)
- {
- MainAsync().GetAwaiter().GetResult();
- Task.Delay(-1).GetAwaiter().GetResult();
- }
- public static DiscordSocketClient API;
- static async Task MainAsync()
- {
- var handle = GetConsoleWindow();
- // Hide
- //ShowWindow(handle, SW_HIDE);
- // Show
- //ShowWindow(handle, SW_SHOW);
- API = new DiscordSocketClient();
- await API.LoginAsync(TokenType.Bot, "redacted lol");
- await API.StartAsync();
- API.MessageReceived += API_MessageReceived;
- }
- public static string[] CursedTimes = new string[]
- {
- "national-kill-all-anime-pfps-day",
- DateTime.UtcNow.DayOfWeek.ToString(),
- "acab day! :revolving_hearts:"
- };
- private static bool StopAll = false;
- [DllImport("kernel32.dll")]
- static extern IntPtr GetConsoleWindow();
- [DllImport("user32.dll")]
- static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
- const int SW_HIDE = 0;
- const int SW_SHOW = 5;
- private static async Task API_MessageReceived(SocketMessage arg)
- {
- try
- {
- if (arg.Content.ToLower().StartsWith("alexa, order "))
- {
- string WhatToOrder = arg.Content.ToLower().Split(new[] { "alexa, order " }, StringSplitOptions.None)[1];
- var Dict = new Dictionary<string, string>()
- {
- {"q", WhatToOrder},
- {"tbm", "isch"}
- };
- string Q = $"https://www.google.com/search?{ await new FormUrlEncodedContent(Dict).ReadAsStringAsync() }";
- using (HttpClient Cl = new HttpClient())
- {
- var Resp = await Cl.GetAsync(Q);
- var Data = await Resp.Content.ReadAsStringAsync();
- HtmlDocument Doc = new HtmlDocument();
- Doc.LoadHtml(Data);
- await orderpls(WhatToOrder, arg, Doc, new Random().Next(29, 45));
- }
- }
- else if (arg.Content.ToLower().StartsWith("alexa,") && arg.Content.ToLower().Contains("play"))
- {
- bool VCFound = false;
- foreach(var Vc in ((SocketGuildChannel)arg.Channel).Guild.VoiceChannels)
- {
- if(Vc.Users.Contains((SocketGuildUser)arg.Author))
- {
- VCFound = true;
- var client = await Vc.ConnectAsync();
- string path = @"\ffmpeg.exe";
- using (var ffmpeg = CreateStream(path))
- using (var output = ffmpeg.StandardOutput.BaseStream)
- using (var discord = client.CreatePCMStream(AudioApplication.Mixed))
- {
- try { await output.CopyToAsync(discord); }
- finally { await discord.FlushAsync(); }
- }
- break;
- }
- }
- if (!VCFound)
- await arg.Channel.SendMessageAsync("ure not in a vc wtf");
- }
- else if (arg.Content.ToLower().StartsWith("alexa,") && (arg.Content.ToLower().Contains("time") || arg.Content.ToLower().Contains("date") || arg.Content.ToLower().Contains("day")))
- {
- await arg.Channel.SendMessageAsync($"today is {CursedTimes[new Random().Next(0, CursedTimes.Length - 1)]}");
- }
- else if (arg.Content.ToLower().StartsWith("alexa,") && arg.Content.ToLower().Contains("kill me"))
- {
- await arg.Channel.SendMessageAsync($"here u go loser; https://en.wikipedia.org/wiki/Suicide_methods");
- }
- else if(arg.Content.ToLower().StartsWith("alexa,") && (arg.Content.ToLower().Contains("live") && arg.Content.ToLower().Contains("why")))
- {
- await arg.Channel.SendMessageAsync("bc dying is illegal");
- }
- else if (arg.Content.ToLower().StartsWith("alexa,") && arg.Content.ToLower().Contains("kpid"))
- {
- await arg.Channel.SendMessageAsync($"process of arch {Assembly.GetExecutingAssembly().GetName().ProcessorArchitecture} // {Assembly.GetExecutingAssembly().GetName().Name} killed");
- Environment.Exit(-1);
- }
- else if (arg.Content.ToLower().StartsWith("alexa,") && arg.Content.ToLower().Contains("stop"))
- {
- if (arg.Author.Id != 528750326107602965)
- {
- await arg.Channel.SendMessageAsync("no u");
- }
- else
- {
- StopAll = true;
- new Thread(x =>
- {
- Thread.Sleep(10000);
- StopAll = false;
- }).Start();
- await arg.Channel.SendMessageAsync($"ugh fine ill stop, gimme 10 seconds before starting another counting session yeah?\n\n```\nsent message to stop all thread pumps, 10000ms to thread lock release.\n```");
- }
- }
- else if (arg.Content.ToLower().StartsWith("alexa,") && (arg.Content.ToLower().Contains("count") || (arg.Content.ToLower().Contains("go") && arg.Content.ToLower().Contains("to"))))
- {
- int Res = 0;
- for(int i = 0; i < arg.Content.Split(' ').Length; i++)
- {
- if(int.TryParse(arg.Content.Split(' ')[i], out Res))
- break;
- }
- if (Res < 0)
- return;
- new Thread(async x =>
- {
- int i = 0;
- while (!StopAll && i < Res)
- {
- try
- {
- i++;
- await arg.Channel.SendMessageAsync(i.ToString());
- }
- catch
- {
- Thread.Sleep(15000);
- }
- Thread.Sleep(2000);
- }
- }).Start();
- }
- }
- catch(Exception e)
- {
- await arg.Channel.SendMessageAsync($"i couldnt do that for some reason, sorry :pensive:\n\n```\n{e}\n```");
- }
- }
- public static int Exhaust = 10;
- private static async Task orderpls(string WhatToOrder, SocketMessage arg, HtmlDocument Doc, int StartInd)
- {
- var __Img = (from S in Doc.DocumentNode.SelectNodes(".//a/@href | .//img/@src") where S.InnerLength > 1 select S);
- var _Img = __Img.ElementAt(StartInd);
- try
- {
- string Img = _Img.InnerHtml.Split(new[] { "src" }, StringSplitOptions.None)[1].Split(new[] { @"""" }, StringSplitOptions.None)[1].Split(new[] { @"""" }, StringSplitOptions.None)[0];
- await arg.Channel.SendMessageAsync($"ordered {WhatToOrder}.. will be here around {(DateTime.Now + TimeSpan.FromDays(new Random().Next(2, 7))).ToShortDateString()}");
- using (WebClient WCl = new WebClient())
- {
- WCl.DownloadFile(Img, @".\uwu.png");
- await arg.Channel.SendFileAsync(@".\uwu.png", "ur product:");
- }
- File.Delete(@".\uwu.png");
- Exhaust = 10;
- }
- catch
- {
- if (Exhaust > 0)
- {
- Exhaust -= 1;
- await orderpls(WhatToOrder, arg, Doc, StartInd + 1);
- }
- else
- {
- Exhaust = 10;
- await arg.Channel.SendMessageAsync("couldnt order that sorry, must be out of stock - u can always retry tho");
- }
- }
- }
- public static Process CreateStream(string path)
- {
- return Process.Start(new ProcessStartInfo
- {
- FileName = "ffmpeg",
- Arguments = $"-hide_banner -loglevel panic -i \"{path}\" -ac 2 -f s16le -ar 48000 pipe:1",
- UseShellExecute = false,
- RedirectStandardOutput = true,
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement