Example #1
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <object> result)
        {
            string reponseBot = GetKaamelott("http://kaamelott.underfloor.io/quote/rand");

            var    activity = await result as Activity;
            string userName = "******";

            // activity = context.Activity;
            if (activity.From.Name != null)
            {
                userName = activity.From.Name;
            }
            var dateTimeStamp = activity.Timestamp;

            string chanel = activity.ChannelId;
            // calcule le nombre de caractère dans le msg
            int length = (activity.Text ?? string.Empty).Length;

            //string reponseBot = $"Tu m'as écrit {activity.Text}, cela contient {length} caractères, ton nom est {userName} ! Tu m'écris de {chanel} le {dateTimeStamp}, ton id est {activity.From.Id}";
            await context.PostAsync(reponseBot);

            BotDBModel db = new BotDBModel();

            db.enregistrementUtilisateur(activity);
            bool messageEnregistre = db.enregistrementMessage(activity);

            db.enregistrementBot(activity, reponseBot);
            context.Wait(MessageReceivedAsync);
        }
Example #2
0
        public void TestMethod1()
        {
            Activity act = new Activity();

            act.Text    = "test";
            act.From.Id = "IdTest";
            BotDBModel botDb    = new BotDBModel();
            bool       resultat = botDb.enregistrementMessage(act);

            Assert.AreEqual(resultat, true);
        }