Exemplo n.º 1
0
            /// <summary>
            /// The bot's primary loop. It takes a room name, and will attempt to join it.
            /// </summary>
            /// <param name="aRoomName">The name of the room you want to join</param>
            /// <returns>True if the bot started successfully, false otherwise.</returns>
            public async Task <bool> Connect(string aRoomName)
            {
                List <DrrrRoom> Rooms = await GetLounge();

                DrrrRoom Room      = Rooms.Find(lRoom => lRoom.Name == aRoomName);
                bool     Connected = false;

                if (Room == null)
                {
                    Logger.Error("Failed to connect, room not found.");
                }
                else if (Room.Full)
                {
                    Logger.Error("Failed to connect, room is full.");
                }
                else
                {
                    Connected = true;
                }

                if (!Connected)
                {
                    return(false);
                }
                Console.WriteLine("Connecting...");

                return(await Connect(Room));
            }
Exemplo n.º 2
0
 public Context(DrrrClient aClient, DrrrMessage aMessage, DrrrUser aAuthor, DrrrRoom aRoom)
 {
     Client  = aClient;
     Message = aMessage;
     Author  = aAuthor;
     Room    = aRoom;
 }
Exemplo n.º 3
0
            private async Task BotMain()
            {
                Console.WriteLine("Starting loop...");

                while (Running)
                {
                    if (Room != null)
                    {
                        DrrrRoom Data = await GetRoom();

                        await Task.Delay(500);
                    }
                }
            }
Exemplo n.º 4
0
            public async Task <bool> Connect(DrrrRoom aRoom)
            {
                //If the need arises, processing can be done on the resulting DrrrRoom object.
                await JoinRoom(aRoom.RoomId);

                Console.WriteLine("Done...");

                if (!Running)
                {
                    Running = true;
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                    Task.Run(() => BotMain());
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
                }

                return(true);
            }