internal static Task Status(ICoreHandler handler, Message Message) { CoreHandler core = handler as CoreHandler; core.Respond(Message.ChannelId, core.ToString()); return(Task.CompletedTask); }
public SignatureController(ISigningEngine signingEngine, ISvgRenderer svgRenderer, ICoreHandler coreHandler) { _signingEngine = (SigningEngine)signingEngine; _coreHandler = coreHandler; }
public GroupdocsViewerApiController() { _rootPathFinder = new RootPathFinder(); _applicationPathFinder = new ApplicationPathFinder(); _printableHtmlCreator = new PrintableHtmlCreator(); _helper = new Helper(); _coreHandler = new CoreHandler(); }
public GroupdocsViewerController(IRootPathFinder rootPathFinder, IApplicationPathFinder applicationPathFinder, IPrintableHtmlCreator printableHtmlCreator, IHelper helper, ICoreHandler coreHandler) { _rootPathFinder = rootPathFinder; _applicationPathFinder = applicationPathFinder; _printableHtmlCreator = printableHtmlCreator; _helper = helper; _coreHandler = coreHandler; }
public GroupdocsViewerApiController(IRootPathFinder rootPathFinder, IApplicationPathFinder applicationPathFinder, IPrintableHtmlCreator printableHtmlCreator, IHelper helper, ICoreHandler coreHandler) { _rootPathFinder = rootPathFinder; _applicationPathFinder = applicationPathFinder; _printableHtmlCreator = printableHtmlCreator; _helper = helper; _coreHandler = coreHandler; }
private Task UnLoadModules(ICoreHandler handler, Message message) { Stopwatch sw = new Stopwatch(); sw.Start(); foreach (var c in Commands) { Commands.Remove(c.Key); } loader.Unload(); sw.Stop(); if (handler != null && message != null) { handler.Respond(message.ChannelId, string.Format(Resources.Culture, Resources.ResourceManager.GetString("UnLoadedModules", Resources.Culture), sw.Elapsed.ToString("s\\.f", Resources.Culture))); } return(Task.CompletedTask); }
public static async Task Search(ICoreHandler handler, Message Message, string @params) { int number = 5; Stopwatch sw = new Stopwatch(); sw.Start(); string data = (await client.GetStringAsync("https://www.anime-planet.com/anime/all?name=" + WebUtility.HtmlEncode(@params))); HtmlDocument html = new HtmlDocument(); html.LoadHtml(data); HtmlNode document = html.DocumentNode; for (int i = 0; i < number; i++) { HtmlNode info = document.QuerySelectorAll("h2.cardName").ToArray()[i]; handler.Respond(Message.ChannelId, info.InnerText); } }
internal Task Broadcast(ICoreHandler handler, string broadcast) { try { CoreHandler core = handler as CoreHandler; foreach (DiscordGuild guild in core.Guilds) { if (guild.SystemChannelId.HasValue) { core.Respond(guild.SystemChannelId.Value, broadcast); } else { core.Respond(guild.Id, broadcast); } } } catch (Exception ex) { log.Error(ex.ToString()); throw; } return(Task.CompletedTask); }
private Task LoadModules(ICoreHandler handler, Message message) { try { loader = new AssemblyLoadContext("AzukiModules", true); Stopwatch sw = new Stopwatch(); sw.Start(); log.Info(Resources.ResourceManager.GetString("LoadingModules", Resources.Culture)); List <Type> expectedparams = new List <Type> { typeof(ICoreHandler), typeof(ulong), typeof(ulong), typeof(string) }; foreach (string assembly in Directory.GetFiles("Dependencies", "*.dll")) { loader.LoadFromAssemblyPath(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + Path.DirectorySeparatorChar + assembly); } foreach (string assembly in Directory.GetFiles("Modules", "*Module.dll")) { log.Info(string.Format(Resources.Culture, Resources.ResourceManager.GetString("FoundModuleContainer", Resources.Culture), Path.GetFileName(assembly))); List <Type> types = loader.LoadFromAssemblyPath(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName) + Path.DirectorySeparatorChar + assembly).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(BaseModule))).ToList(); int count = 0; foreach (Type t in types) { count += LoadCommands(t); } log.Info(string.Format(Resources.Culture, Resources.ResourceManager.GetString("LoadedModuleContainer", Resources.Culture), Path.GetFileName(assembly), types.Count, count)); } sw.Stop(); if (handler != null && message != null) { handler.Respond(message.ChannelId, string.Format(Resources.Culture, Resources.ResourceManager.GetString("LoadedModules", Resources.Culture), sw.Elapsed.ToString("s\\.f", Resources.Culture))); } log.Info(string.Format(Resources.Culture, Resources.ResourceManager.GetString("LoadedModules", Resources.Culture), sw.Elapsed.ToString("s\\.f", Resources.Culture))); } catch (Exception ex) { log.Error(ex.ToString()); throw; } return(Task.CompletedTask); }
public async Task Play(ICoreHandler handler, Message message, string param) { Video vid = (await client.Search.GetVideosAsync(param)).FirstOrDefault(); if (vid != null) { if (vid.Duration <= TimeSpan.FromMinutes(10)) { StreamManifest streamManifest = await client.Videos.Streams.GetManifestAsync(vid.Id); AudioOnlyStreamInfo audio = streamManifest.GetAudioOnly().FirstOrDefault(); if (audio != null) { MemoryStream stream = new MemoryStream(); await client.Videos.Streams.CopyToAsync(audio, stream); Debug(audio.AudioCodec); unsafe { AVPacket *pkt = ffmpeg.av_packet_alloc(); AVCodec * codec = ffmpeg.avcodec_find_decoder_by_name(audio.AudioCodec); if (codec == null) { Error($"Codec {audio.AudioCodec} not found."); return; } AVCodecParserContext *parser = ffmpeg.av_parser_init((int)codec->id); if (parser == null) { Error("Could not allocate audio codec context."); return; } AVCodecContext *context = ffmpeg.avcodec_alloc_context3(codec); if (context == null) { Error("Could not allocate audio codec context."); return; } if (ffmpeg.avcodec_open2(context, codec, null) < 0) { Error("Could not open audio codec context."); return; } AVFrame *decoded_frame = null; while (stream.Length - stream.Position > 0) { if (decoded_frame == null) { decoded_frame = ffmpeg.av_frame_alloc(); } byte[] buffer = new byte[pkt->size]; stream.Read(buffer, 0, buffer.Length); IntPtr unmanagedPointer = Marshal.AllocHGlobal(buffer.Length); Marshal.Copy(buffer, 0, unmanagedPointer, buffer.Length); ffmpeg.av_parser_parse2(parser, context, &pkt->data, &pkt->size, (byte *)unmanagedPointer, buffer.Length, ffmpeg.AV_NOPTS_VALUE, ffmpeg.AV_NOPTS_VALUE, 0); int ret = ffmpeg.avcodec_send_packet(context, pkt); while (ret > 0) { ret = ffmpeg.avcodec_receive_frame(context, decoded_frame); int data_size = ffmpeg.av_get_bytes_per_sample(context->sample_fmt); int current = 0; for (int i = 0; i < decoded_frame->nb_samples; i++) { for (uint ch = 0; ch < context->channels; ch++) { Marshal.Copy((IntPtr)decoded_frame->data[ch] + (data_size * i), buffer, current, data_size); current += data_size; } } message.TransferSound(buffer); } Marshal.FreeHGlobal(unmanagedPointer); } } } } else { Warn("Video too long."); } } else { Warn("No video by that term."); } /*DiscordGuildTextChannel Channel = client.GetChannel(e.Message.ChannelId).Result as DiscordGuildTextChannel; * Snowflake GuildId = Channel.GuildId; * DiscordGuild Guild = await client.GetGuild(GuildId); * Snowflake ChannelId = e.Message.ChannelId; * DiscordVoiceState voiceState = e.Shard.Cache.GetVoiceState(GuildId, e.Message.Author.Id); * if (voiceState == null) { * return; * } else { * if (!SharedObjectStorage.VoiceModuleObjects.Keys.Contains(voiceState.ChannelId.Value)) { * VoiceModule music = new VoiceModule(e.Shard, voiceState.ChannelId.Value); * SharedObjectStorage.VoiceModuleObjects.Add(voiceState.ChannelId.Value, music); * if (Tempnamelist.Count <= 2) { * Tempnamelist.Add($"Temp{i++}"); * } * string filename = Tempnamelist[0]; * Tempnamelist.RemoveAt(0); * voice = new YoutubeVoiceProvider(); * voice.DoQuery(query); * client.CreateMessage(e.Message.ChannelId, "" + String.Join("\n", voice.Result)); * this.GuildId = ((await client.GetChannel(e.Message.ChannelId)) as DiscordGuildTextChannel).GuildId; * UserId = e.Message.Author.Id; * e.Shard.Gateway.OnMessageCreated += Gateway_OnMessageCreated1; * stopsignal.WaitOne(); * e.Shard.Gateway.OnMessageCreated -= Gateway_OnMessageCreated1; * voice.DownloadToFileByQuery($"Temp/{filename}").Wait(); * if (new FileInfo($"Temp/{filename}").Length <= 100) { return; } * client.CreateMessage(e.Message.ChannelId, "Playing: " + voice.CurrentSelection); * Converter c = new FFmpegConverter(); * c.TempfileClosed += TempfileClosed; * music.Transfer(new FileInfo($"Temp/{filename}"), c, playCancellationTokenSource); * } * }*/ }