示例#1
0
文件: ChatLog.cs 项目: bremnes/IrcBot
        public void Get_LotOfEntries_OnlyForLast24Hours()
        {
            var entries = new List<ChatEntry> {
                new ChatEntry {
                    NickName = "johndoe", Text = "Hey, how does it look in print?", Time = DateTime.Now
                },
                new ChatEntry
                {
                    NickName = "janedoe", Text = "howdy", Time = DateTime.Now.AddHours(-5)
                },
                new ChatEntry
                {
                    NickName = "johndoe", Text = "nothing", Time = DateTime.Now.AddHours(-6)
                },
                new ChatEntry
                {
                    NickName = "janedoe", Text = "what's up?", Time = DateTime.Now.AddHours(-7)
                },
                new ChatEntry
                {
                    NickName = "janedoe", Text = "this should go between the delete limit (48) and the get hour (24)", Time = DateTime.Now.AddHours(-28)
                },
            };
            _chatLog = new Bot.Services.ChatLog(new Dictionary<string, IList<ChatEntry>> { { "Channel", entries } });

            var comments = _chatLog.Get("Channel");
            Assert.AreEqual(entries.Count-1, comments.Count);
        }
示例#2
0
        /// <summary>
        /// initialize events and component
        /// </summary>
        public ClientForm(IChatLog chatLog)
        {
            this.chatLog = chatLog;

            Executor.ProgressCustom += new ChatLibrary.ProgressCustomEventHandler(Executor_ServerText);
            Executor.ClientText     += new ChatLibrary.ClientChatEventHandler(Executor_ClientText);
            InitializeComponent();
        }
示例#3
0
        public static Response PersistChatLog(QueryResult response, Sesion sesion, string text, string source, string type)
        {
            Response output = new Response();

            try
            {
                var container = new Container();
                UnityConfig.RegisterTypes(container);
                IChatLog chatlog = container.GetInstance <IChatLog>();

                decimal confidence;
                decimal.TryParse(response?.IntentDetectionConfidence.ToString(), out confidence);

                ChatLog input = new ChatLog
                {
                    IdSesion = (int)sesion.IdSesion,
                    IdAlumno = (int)sesion.IdAlumno,
                    Fecha    = DateTime.Now,
                    //Texto = response?.QueryText,
                    Texto     = text,
                    Intencion = response?.Intent?.DisplayName,
                    //Fuente = "Usuario",
                    Fuente     = source, //Usuario, Bot
                    Tipo       = type,   //DialogFlow, BotFramework
                    Contexto   = response?.OutputContexts?.ToString(),
                    Parametros = response?.Parameters?.ToString(),
                    Confianza  = confidence
                };

                ChatLog chatLogInputData = chatlog.CrearChatLog(input);

                output.Status = true;
                output.Type   = Enums.ResponseType.success;
                output.Data   = chatLogInputData;

                //ChatLog output = new ChatLog
                //{
                //    IdSesion = (int)sesion.IdSesion,
                //    IdAlumno = (int)sesion.IdAlumno,
                //    Fecha = DateTime.Now,
                //    Texto = response.FulfillmentText,
                //    Intencion = response.Intent.DisplayName,
                //    Fuente = "Bot",
                //    Contexto = response.OutputContexts.ToString(),
                //    Parametros = response.Parameters.ToString(),
                //    Confianza = (decimal)response.IntentDetectionConfidence

                //};

                //ChatLog chatLogOutputData = chatlog.CrearChatLog(output);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            return(output);
        }
示例#4
0
文件: ChatLog.cs 项目: bremnes/IrcBot
        public void Get_OldEntries_OldDeleted()
        {
            var entries = new List<ChatEntry> {
                new ChatEntry {
                    NickName = "johndoe", Text = "Hey, how does it look in print?", Time = DateTime.Now
                },
                new ChatEntry
                    {
                        NickName = "janedoe", Text = "this should be deleted", Time = DateTime.Now.AddHours(-49)
                    }
            };
            _chatLog = new Bot.Services.ChatLog(new Dictionary<string, IList<ChatEntry>> { { "Channel", entries } });

            var comments = _chatLog.Get("Channel", 100);
            Assert.AreEqual(1, comments.Count);
            Assert.AreEqual("johndoe", comments.First().NickName);
        }
示例#5
0
 public Server(IChatLog chatlog)
 {
     this.chatlog = chatlog;
 }
示例#6
0
文件: ChatLog.cs 项目: bremnes/IrcBot
        public void ToString_CommentLooksGood()
        {
            var time = DateTime.Now;
            var entries = new List<ChatEntry> { new ChatEntry{ NickName = "johndoe", Text = "Hey, how does it look in print?", Time = time } };
            _chatLog = new Bot.Services.ChatLog(new Dictionary<string, IList<ChatEntry>> {{"Channel", entries}});

            var comments = _chatLog.Get("Channel");
            Assert.AreEqual(1, comments.Count);
            Console.WriteLine(comments.First().ToString());
        }
示例#7
0
文件: ChatLog.cs 项目: bremnes/IrcBot
 public void Initialize()
 {
     _chatLog = new Bot.Services.ChatLog();
 }