示例#1
0
 public static void PrintMessages(SocketMessage socketMessage, string message, string response)
 {
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.WriteLine("");
     Console.WriteLine($"From: {Userhelper.GetFullUsername(socketMessage)}");
     Console.WriteLine(message);
     Console.WriteLine();
     Console.WriteLine($"To: {Userhelper.GetFullUsername(socketMessage)}");
     Console.WriteLine(response);
     Console.WriteLine("================");
     Console.ForegroundColor = ConsoleColor.Gray;
 }
示例#2
0
        public async Task CreateNewSession(SocketMessage socketMessage)
        {
            var learnFaster = socketMessage.Content.Contains(" -learn faster");

            var settings   = new SessionSettings($"{Userhelper.GetFullUsername(socketMessage)}--{socketMessage.Channel.Name}", learnFaster);
            var newSession = new ChatSession(Userhelper.GetFullUsername(socketMessage), socketMessage.Channel.Name, settings);

            chatSessions.Add(newSession);

            await SessionMessages.CreatedSession(socketMessage, newSession);

            if (learnFaster)
            {
                await SessionMessages.LearnFasterModeActivated(socketMessage);
            }
        }
示例#3
0
        public async Task ReadyToMerge(SocketMessage socketMessage, IMessageChannel messageChannel)
        {
            var session = await GetThisRoomChatSession(socketMessage);

            if (session == null)
            {
                return;
            }

            if (session.SessionOwner != Userhelper.GetFullUsername(socketMessage) && !Userhelper.IsAdmin(socketMessage))
            {
                await SessionMessages.CannotSetAsReadyToMerge(socketMessage, session);

                return;
            }

            await SessionMessages.ReadyToMergeSession(socketMessage, session, messageChannel);
        }
示例#4
0
        public async Task DeleteSession(SocketMessage socketMessage)
        {
            var session = await GetThisRoomChatSession(socketMessage);

            if (session == null)
            {
                return;
            }
            if (session.SessionOwner != Userhelper.GetFullUsername(socketMessage) && !Userhelper.IsAdmin(socketMessage))
            {
                await SessionMessages.CannotDeleteSessionBcsPermission(socketMessage, session);

                return;
            }
            session.RoboChat.DeleteSession();
            chatSessions.Remove(session);
            await SessionMessages.DeletedSession(socketMessage, session);
        }
示例#5
0
        public async Task SendResponseToUser(SocketMessage socketMessage, string message)
        {
            var currentSession = chatSessions.Where(x => x.RoomName == socketMessage.Channel.Name)
                                 .FirstOrDefault(x => x.SessionOwner == Userhelper.GetFullUsername(socketMessage));

            if (currentSession == null)
            {
                await SessionMessages.NotFoundSession(socketMessage);

                return;
            }

            var response = currentSession.RoboChat.SendMessage(socketMessage.Author.Username, message);

            if (response.StartsWith("/"))
            {
                response = response.TrimStart("/".ToCharArray());
            }
            await socketMessage.Channel.SendMessageAsync(response);

            PrintToConsole.PrintMessages(socketMessage, message, response);
        }
示例#6
0
 public static async Task MergedSession(SocketMessage socketMessage, ChatSession session)
 {
     await socketMessage.Channel.SendMessageAsync($"```Merged session for user: {session.SessionOwner} in room: {session.RoomName} by user: {Userhelper.GetFullUsername(socketMessage)}```");
 }