コード例 #1
0
        public async Task GameStatus(CommandContext ctx, int gameID)
        {
            await ctx.TriggerTypingAsync();

            String result = BotLibrary.returnCurrentGameStatus(gameID);

            if (result != null)
            {
                await ctx.RespondAsync($"Hi, {ctx.User.Mention}! " + result);
            }
            else
            {
                await ctx.RespondAsync($"Hi, {ctx.User.Mention}! Game Status is currently: " + "Unavailable");
            }
        }
コード例 #2
0
        public async Task CurrentGame(CommandContext ctx)
        {
            await ctx.TriggerTypingAsync();

            String result = BotLibrary.returnCurrentGameStatus();

            if (result != null)
            {
                await ctx.RespondAsync($"Hi, {ctx.User.Mention}! " + result);
            }
            else
            {
                await ctx.RespondAsync($"Hi, {ctx.User.Mention}! Game Status is currently: " + "Unavailable");
            }

            /*var interactivity = ctx.Client.GetInteractivityModule();
             * var msg = await interactivity.WaitForMessageAsync(xm => xm.Author.Id == ctx.User.Id && xm.Content.ToLower() == "how are you?", TimeSpan.FromMinutes(1));
             * if (msg != null)
             *  await ctx.RespondAsync($"I'm fine, thank you!");*/
        }
コード例 #3
0
        public async Task addgamechat(CommandContext ctx, int gameID)
        {
            HashSet <String> chatLog = new HashSet <String>();
            Random           rand    = new Random();
            Boolean          boo     = false;
            int ID = 0; //ID of thread

            while (!boo)
            {
                ID = rand.Next(99999);
                try
                {
                    await readlock.WaitAsync();

                    boo = chatlogging.Add(ID);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    readlock.Release();
                }
            }//will continue only if true(unused ID)
            await ctx.RespondAsync($"Logging Game:" + gameID + ", Handle is " + ID + " ; Use this handle with command *.exitchat handle* to end logging");


            while (boo)
            {
                HashSet <String> temp = BotLibrary.returnGameChat(gameID);
                foreach (String x in temp)
                {
                    //await ctx.TriggerTypingAsync();
                    if (chatLog.Add(x))
                    {
                        await ctx.RespondAsync(x);
                    }
                }
                //await ctx.RespondAsync($"Looping beboop!");
                await Task.Delay(10000);

                try
                {
                    await readlock.WaitAsync();

                    if (chatlogging.Overlaps(new int[1] {
                        ID
                    }))
                    {
                        //exists
                    }
                    else
                    {
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    readlock.Release();
                }
            }
        }