Exemple #1
0
        private void onMessageSent(object sender, MessageSentEventArgs e)
        {
            //SmtpClient outbound = (SmtpClient)sender;

            string result = e.Response.Split(']')[1];

            WriteLog(string.Format("Message Result {0} {1}", e.Message.To.First(), result), LogLevel.Informational);

            try
            {
                Queue q = queue.Where(queue => queue.MessageID == e.Message.MessageId).First();
                if (result.Contains("Queued mail for delivery"))
                {
                    q.Status = Status.Complete;
                }
                else
                {
                    q.Status = Status.Failed;
                }
            }
            catch { }
            //Error uoloading to CSSOK : 5.3.4 Message size exceeds fixed maximum message size

            //TODO: Update message relay log.
        }
        /// <summary>
        /// Callback is invoked when IM Modality state changes upon receipt of message
        /// </summary>
        /// <param name="source">InstantMessageModality Modality </param>
        /// <param name="data">SendMessageEventArgs The new message.</param>
        public void ReceiveMessage(Object sender, MessageSentEventArgs e)
        {
            IDictionary <InstantMessageContentType, string> messageFormatProperty = e.Contents;
            var key = messageFormatProperty.Keys;

            string content = string.Empty;

            if (messageFormatProperty.ContainsKey(InstantMessageContentType.PlainText))
            {
                messageFormatProperty.TryGetValue(InstantMessageContentType.PlainText, out content);
            }

            else if (messageFormatProperty.ContainsKey(InstantMessageContentType.RichText))
            {
                if (messageFormatProperty.TryGetValue(InstantMessageContentType.RichText, out content))
                {
                    //RTFDomDocument doc = new RTFDomDocument();
                    //doc.LoadRTFText(content);
                    //content = doc.InnerText;
                    System.Windows.Forms.RichTextBox rtb = new System.Windows.Forms.RichTextBox();
                    rtb.Rtf = content;
                    content = rtb.Text;
                }
            }

            var replymessage = this.commandManager.ExecuteCommand(content);

            SendMessage(replymessage);

            Debug.WriteLine(content);
            Debug.WriteLine(replymessage);
        }
        private void MessageSent(object sender, MessageSentEventArgs e)
        {
            //var sendArg = e.UserState as SendArg;
            //if (sendArg == null)
            //    return;

            //if (e.Error != null)
            //{
            //    _logger.Warn($"Error when send file {sendArg.File} ,the {sendArg.RetryTime + 1} times.");
            //    _logger.Warn(e.Error.ToString());
            //    //if (sendArg.RetryTime < 3)
            //    sendArg.Client.SendAsync(sendArg.Message, sendArg.Retry());
            //}
            //else
            //{
            //    _logger.Info($"Sucess when send file {sendArg.File} ,the {sendArg.RetryTime + 1} times.");

            //    File.AppendAllText(_taskFile, sendArg.File + System.Environment.NewLine);

            //    string fileName;
            //    while (!sendArg.QueuedFiles.TryDequeue(out fileName))
            //    {
            //    }
            //}
        }
Exemple #4
0
        private static void ChatRecibido(object sender, MessageSentEventArgs e)
        {
            InstantMessageModality elChat = (InstantMessageModality)sender;
            // el user es elPibe
            string elPibe = elChat.Endpoint.DisplayName.Substring(0, elChat.Endpoint.DisplayName.LastIndexOf("@"));
            string elComando = e.Text;
            //loguear
            Console.WriteLine(DateTime.Now + ". " + elPibe + " dice: " + elComando);

            //Check permisos y pregunta parametros
            Dictionary<string, string> elCheck = GetScripInfo(elPibe, elComando);

            //...
            if (elCheck["elCom"] != "No encuentro el comando")
            {
                Console.WriteLine(elPibe + " ejecutando comando... \r\n" + elCheck["elCom"]);

                //Executar comando y contar como va yendo y esa onda
                var elResul = Ejecuta(elCheck);
                //Loguear?
                //Aca desarmar el jotason?
                Console.WriteLine(elResul);

                elChat.BeginSendMessage(elResul, (ar) => { elChat.EndSendMessage(ar); }, null);
            }
            else
            {
                elChat.BeginSendMessage("Lo siento " +elPibe + ", " + elCheck["elCom"], (ar) => { elChat.EndSendMessage(ar); }, null);
            }
        }
Exemple #5
0
        private async void InstantMessageReceived(object sender, MessageSentEventArgs e)
        {
            var    text = e.Text.Replace(Environment.NewLine, string.Empty);
            string myRemoteParticipantUri = (sender as InstantMessageModality).Endpoint.Uri.Replace("sip:", string.Empty);
            var    username_string        = (sender as InstantMessageModality).Participant.Contact.GetContactInformation(ContactInformationType.DisplayName);;

            try
            {
                //LogMessage(myRemoteParticipantUri, text);
                string strResult = "";
                apiAi = Get_apiai_object_from_username(myRemoteParticipantUri);

                List <AIContext> aicontext = new List <AIContext>();
                AIContext        user_info = new AIContext();
                user_info.Name = "skype_username="******"speech"].ToString();
                strResult = ret_text;

                (sender as InstantMessageModality).BeginSendMessage(strResult, null, null);
            }
            catch (Exception ex)
            {
                //LogMessage(myRemoteParticipantUri, ex.Message);
            }
        }
Exemple #6
0
        public static void Send(MessageSentEventArgs args)
        {
            Program.Log.WriteLine("Replying: " + args.Response.Text, overrideColor: ConsoleColor.Yellow);
            var text = args.Response.Text;

            try
            {
                if (text.StartsWith("/me"))
                {
                    text = text.Replace("/me", "*") + "*";
                }
                if (text.StartsWith("/"))
                {
                    text = text.Substring(1);
                }
                long targetId = 0;
                if (long.TryParse(args.Target, out targetId))
                {
                    Bot.SendTextMessageAsync(targetId, text, replyMarkup: CreateMarkupFromMenu(args.Response.Menu), parseMode: args.Response.ParseMode);
                }
                //Bot.SendTextMessage(update.Message.Chat.Id, text);
                return;
            }
            catch (Exception e)
            {
                //Logging.Write("Server error! restarting..");
                //Process.Start("csircbot.exe");
                //Environment.Exit(7);
            }
        }
Exemple #7
0
 /// <summary>
 /// Handles the InstantMessageReceived event of the remoteModality control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="Microsoft.Lync.Model.Conversation.MessageSentEventArgs"/> instance containing the event data.</param>
 private void RemoteModality_InstantMessageReceived(object sender, MessageSentEventArgs e)
 {
     if (!(e.Text.Contains("Sorry") || e.Text.Contains("Connecting") || e.Text.Contains("Calling")))
     {
         this.IM_Received(this, new CallEventArgs(this.MenuRequest));
     }
 }
Exemple #8
0
        private void InstantMessageReceived(object sender, MessageSentEventArgs e)
        {
            var text = e.Text.Replace(Environment.NewLine, string.Empty);
            var conversationService = new ConversationService((InstantMessageModality)sender);

            SendToBot(conversationService, text);
        }
        public async Task SendAsync(MessageSentEventArgs args)
        {
            Log.WriteLine("Replying: " + args.Response.Text, overrideColor: ConsoleColor.Yellow);
            var text = args.Response.Text;

            try
            {
                if (text.StartsWith("/me"))
                {
                    text = text.Replace("/me", "*") + "*";
                }
                if (text.StartsWith("/"))
                {
                    text = text.Substring(1);
                }

                if (long.TryParse(args.Target, out var targetId))
                {
                    await Bot.SendTextMessageAsync(targetId, text, replyMarkup : CreateMarkupFromMenu(args.Response.Menu), parseMode : args.Response.ParseMode, disableNotification : args.IsSilent);
                }

                return;
            }

            catch (Exception ex)
            {
                Log.WriteLine(ex.ToString(), LogLevel.Error, null, "error.log");
            }
        }
Exemple #10
0
        private void ShowNewMessage(MessageSentEventArgs e)
        {
            string rtfString = string.Empty;

            if (e.Contents.TryGetValue(InstantMessageContentType.RichText, out rtfString))
            {
                //display the rtf in an image control
                this.Dispatcher.Invoke(new FillRichTextBoxDelegate(FillRichTextBox), new object[] { richTextBox1, rtfString });
            }

            string htmlString = string.Empty;

            if (e.Contents.TryGetValue(InstantMessageContentType.Html, out htmlString))
            {
                //display the html in an image control
                //webBrowser1.NavigateToString(htmlString);
                this.Dispatcher.Invoke(new FillWebBrowserDelegate(FillWebBrowser), new object[] { webBrowser1, htmlString });
            }

            string plainString = string.Empty;

            if (e.Contents.TryGetValue(InstantMessageContentType.PlainText, out plainString))
            {
                //display the plain text  in an image control
                this.Dispatcher.Invoke(new FillTextBoxDelegate(FillTextBox), new object[] { textBox1, plainString });
            }
        }
Exemple #11
0
 protected void OnGroupCreated(MessageSentEventArgs e)
 {
     if (GroupCreated != null)
     {
         GroupCreated(this, e);
     }
 }
Exemple #12
0
 protected void OnMessageSent(MessageSentEventArgs e)
 {
     if (MessageSent != null)
     {
         MessageSent(this, e);
     }
 }
Exemple #13
0
 private void MessageBusOnSent(object sender, MessageSentEventArgs messageSentEventArgs)
 {
     // TODO: Move this to be per-client so they can format for their audience?
     if (messageSentEventArgs.Message != null)
     {
         messageSentEventArgs.Target.Send(messageSentEventArgs.Message);
     }
 }
 private void SendMessage(MessageSentEventArgs messageSentEventArgs)
 {
     if (!this.commandLineParser.IsVerbose && messageSentEventArgs.MessageType <= MessageType.Verbose)
     {
         return;
     }
     this.OnMessageSent(messageSentEventArgs);
 }
Exemple #15
0
 private void MessageSentHandler(object?sender, MessageSentEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(e.Message) &&
         (string.IsNullOrWhiteSpace(e.Source) || e.Source == ApiSource.Discord))
     {
         Send(e.Message);
     }
 }
        private void Device_MessageSent(object sender, MessageSentEventArgs e)
        {
            if (e.Origin == null || !e.Origin.IsSubclassOf(typeof(MultiView)))
            {
                return;
            }

            this.Messages.Add(e.MessageId);
        }
        private void Device_MessageSent(object sender, MessageSentEventArgs e)
        {
            if (this.DeleteSide == eDeleteSide.UserOnly)
            {
                return;
            }

            this.OldMessages.Add(e.Message);
        }
Exemple #18
0
 void Page_InstantMessageReceived(object sender, MessageSentEventArgs e)
 {
     if (currentConversationList.Contains(_Conversation))
     {
     }
     else
     {
         SendMessage();
     }
 }
Exemple #19
0
        public void MessageSentEvent(string message, string source)
        {
            var handler = MessageSent;

            if (handler != null)
            {
                var args = new MessageSentEventArgs(message, source);
                handler(this, args);
            }
        }
        void Page_InstantMessageReceived(object sender, MessageSentEventArgs e)
        {
            if (currentConversationList.Contains(_Conversation))
            {

            }
            else
            {
                SendMessage();
            }
        }
Exemple #21
0
        private void ConnectionServiceOnMessageSent(object sender, MessageSentEventArgs e)
        {
            // ignored messages TODO should these be filtered with some input from ScriptBuilder, what message types it supports?
            if (e.Message is Commit ||
                e.Message is ListLengthRequest ||
                e.Message is ListItemRequest)
            {
                return;
            }

            AddStep(new MessageStep(e.Message));
        }
Exemple #22
0
        public static CommandResponse DoTest(CommandEventArgs args)
        {
            //This will send a command along without returning
            //First we build our message
            var message = new MessageSentEventArgs
            {
                Response = new CommandResponse("This is a test command"),
                Target   = args.Target //TODO Check this, not even sure it's in use in Telegram
            };

            //Now we send it
            args.Messenger.SendMessage(message);

            //we can also interact directly with the bot api as such
            args.Bot.SendTextMessageAsync(args.Message.Chat.Id, "This is a test button", replyMarkup: new InlineKeyboardMarkup(new[]
            {
                new InlineKeyboardButton()
                {
                    Text = "Grey Wolf Dev Channel",
                    Url  = "https://t.me/greywolfdev"
                },
                //can also use conditional statements when building menus
                true ? new InlineKeyboardButton()
                {
                    Text = "Para's Channel", Url = "https://t.me/para949"
                } : null
            }));

            // of course, if you saved the bot in your constructor, you can also use that
            Console.WriteLine(_bot.IsReceiving);

            //Another way to create a button menu is like this:
            var menu = new Menu
            {
                Columns = 3,
                Buttons = new List <InlineButton>
                {
                    new InlineButton("Column 1, Row 1", "test", "extra data 1"), //These buttons will trigger the callback command below
                    new InlineButton("Column 2, Row 1", "test", "extra data 2"),
                    new InlineButton("Column 3, Row 1", "test", "extra data 3"),
                    //This button will be the "remainder" (4 % 3 == 1) so it will span the bottom
                    new InlineButton("Grey Wolf Support", url: "https://t.me/werewolfsupport") //this button won't trigger a command, just opens the url.
                }
            };

            //now, return the method.  This can be null, in which case no text will be sent.
            // as you can see, we attached our custom menu
            return(new CommandResponse("Here's my response!", ResponseLevel.Public, menu));


            //Why have all these ways to send messages?  The idea here is flexibility, ease of use, but also the ability to really drill down into the bot if needed.
        }
Exemple #23
0
        public void TestMessageSentEventArgs()
        {
            var message = new MimeMessage();
            MessageSentEventArgs args;

            args = new MessageSentEventArgs(message, "response");

            Assert.AreEqual(message, args.Message);
            Assert.AreEqual("response", args.Response);

            Assert.Throws <ArgumentNullException> (() => new MessageSentEventArgs(null, "response"));
            Assert.Throws <ArgumentNullException> (() => new MessageSentEventArgs(message, null));
        }
Exemple #24
0
 private void MessageReceived(object sender, MessageSentEventArgs args)
 {
     try
     {
         var messageInfo = (InstantMessageModality)sender;
         ChatLog.Write(messageInfo, args.Text);
     }
     catch (Exception ex)
     {
         LogException("MessageReceived", ex);
         throw;
     }
 }
Exemple #25
0
        private void MessageSentHandler(object?sender, MessageSentEventArgs e)
        {
            using (var scope = serviceScopeFactory.CreateScope())
            {
                var twitchManager = scope.ServiceProvider.GetRequiredService <TwitchManager>();
                var user          = twitchManager.GetUser().Result;

                if (!string.IsNullOrWhiteSpace(e.Message) &&
                    (string.IsNullOrWhiteSpace(e.Source) || e.Source == ApiSource.Twitch))
                {
                    Send($"PRIVMSG #{user.login} :{e.Message}");
                }
            }
        }
Exemple #26
0
        private void StorageOnMessageSent(object sender, MessageSentEventArgs messageSentEventArgs)
        {
            Execute(() =>
            {
                _databaseLog.SaveMessage(messageSentEventArgs.Message);

                if (messageSentEventArgs.MessageStatus != null)
                {
                    _databaseLog.UpdateStatus(messageSentEventArgs.MessageStatus);
                }
            });

            eventLog.WriteEntry($"Сообщение с messageId {messageSentEventArgs.MessageStatus.MessageId} отправлен",
                                EventLogEntryType.Information);
        }
Exemple #27
0
        void LyncHMessageRecorder_InstantMessageReceived(object sender, MessageSentEventArgs e)
        {
            var messageModality = sender as InstantMessageModality;

            if (messageModality == null)
            {
                logger.Error(string.Format("sender is not of type InstantMessageModality, sender={0}", sender));
                return;
            }

            string senderName = messageModality.Endpoint.DisplayName;

            Console.WriteLine("Message from {0} received at {1}", ((InstantMessageModality)sender).Endpoint.DisplayName, DateTime.Now);
            foreach (var key in e.Contents.Keys)
            {
                var v = e.Contents[key];
                Console.WriteLine(key);
                Console.WriteLine(v);
            }

            string friendlyName = null;

            if (messageModality.Participant.Properties.ContainsKey(ParticipantProperty.Name))
            {
                friendlyName = messageModality.Participant.Properties[ParticipantProperty.Name].ToString();
            }
            else
            {
                friendlyName = senderName;
            }

            string message = e.Text.Trim();

            message = NormalizeMessage(friendlyName, message);

            List <string> participants = new List <string>();

            foreach (Participant p in messageModality.Conversation.Participants)
            {
                if (p.IsSelf)
                {
                    continue;
                }
                participants.Add(NormalizeAddress(p.Contact.Uri));
            }

            messageStore.SaveMessage(DateTime.Now, message, participants.ToArray());
        }
        private void handle_ImAction(object sender, MessageSentEventArgs e)
        {
            var modality = sender as InstantMessageModality;

            if (modality == null)
            {
                return;
            }

            var participants = modality.Conversation.Participants;

            var name    = (string)modality.Participant.Contact.GetContactInformation(ContactInformationType.DisplayName);
            var convKey = calculateKey(participants);

            update_Conversation(convKey, name, e.Text);
        }
        /// <summary>
        /// Handles the event raised when an IM is sent on the conversation.
        /// </summary>
        /// <param name="source">InstantMessageModality Modality </param>
        /// <param name="data">SendMessageEventArgs The new message.</param>
        void myInstantMessageModality_MessageReceived(Object source, MessageSentEventArgs data)
        {
            IDictionary <InstantMessageContentType, string> messageFormatProperty = data.Contents;
            string Sender = (string)((InstantMessageModality)source).Participant.Contact.GetContactInformation(ContactInformationType.DisplayName);

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            string receivedMessage;

            if (data.Contents.TryGetValue(InstantMessageContentType.Html, out receivedMessage))
            {
                //****************************************************************
                //Add newest message to conversation history list box data source.
                //****************************************************************
                _ConversationHistory.Add(receivedMessage);
            }
            else if (data.Contents.TryGetValue(InstantMessageContentType.PlainText, out receivedMessage))
            {
                //****************************************************************
                //Wrap plain text in DIV tags for consumption by the WebBrowser control.
                //****************************************************************
                receivedMessage = "<DIV style=\"font-size:" +
                                  "10pt;font-family:" +
                                  "MS Shell Dlg 2;color: #463939;direction: ltr\">" +
                                  receivedMessage +
                                  "</DIV>";
                _ConversationHistory.Add(receivedMessage);
            }
            else
            {
                //****************************************************************
                //Wrap message text in DIV tags for consumption by the WebBrowser control.
                //****************************************************************
                receivedMessage = "<DIV style=\"font-size:" +
                                  "18pt;font-family:" +
                                  "MS Shell Dlg 2;color: #463939;direction: ltr\">" +
                                  data.Text +
                                  "</DIV>";
                _ConversationHistory.Add(receivedMessage);
            }

            //****************************************************************
            //Invoke delegate to update conversation history list box on UI thread.
            //****************************************************************
            object[] actionObjectArray = { Sender, _ConversationHistory };
            this.Dispatcher.Invoke(FormActor, new object[] { FormActions.SetListContents, History_WebBrowser, actionObjectArray });
        }
Exemple #30
0
        private void ImModality_InstantMessageReceived(object sender, MessageSentEventArgs e)
        {
            InstantMessageModality im = (InstantMessageModality)sender;

            if (!im.Participant.IsSelf)
            {
                var botConversation = directLineCLient.Conversations.NewConversationWithHttpMessagesAsync().Result.Body;

                var message = new Message();
                message.ConversationId = botConversation.ConversationId;
                message.Text           = e.Text;
                var result = directLineCLient.Conversations.PostMessageWithHttpMessagesAsync(botConversation.ConversationId, message).Result;

                var response = directLineCLient.Conversations.GetMessagesWithHttpMessagesAsync(botConversation.ConversationId).Result;

                im.BeginSendMessage(response.Body.Messages.LastOrDefault().Text, null, response.Body.Messages.LastOrDefault());
            }
        }
        private void Client_MessageSent(object sender, MessageSentEventArgs e)
        {
            MimeMessage mimeMessage = e.Message;
            string      nameFile    = $"{UserParticipant.Name}_Reject_DTE_{mimeMessage.Date:dd-MM-yyyy-HH-mm-ss}" + ".eml";

            try
            {
                // SAVE FILE EML.
                new CreateFile(@"C:\Centralizador\Log\", mimeMessage, nameFile);
                //mimeMessage.WriteTo(nameFile);
                ProgressReport.Msg = $"Email send to {mimeMessage.To.FirstOrDefault().Name}, check de Log file.";
                ProgressReport.PercentageComplete--;
                Progress.Report(ProgressReport);
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #32
0
        private static void ChatRecived(object sender, MessageSentEventArgs e)
        {
            InstantMessageModality nananana = (InstantMessageModality)sender;
            // el user ees elPibe
            string elPibe = nananana.Endpoint.DisplayName.Substring(0, nananana.Endpoint.DisplayName.LastIndexOf("@"));
            // por ahora, luego habrá que separar los argumentos,
            //no mejor habria que derivar del comando cuantos y que arg lleva y preguntarlos y esas cosas que le gustan al Colo
            string elComando = e.Text;
            //loguear
            Console.WriteLine(DateTime.Now + ". " + elPibe + " dice: " + elComando);

            nananana.BeginSendMessage("Llegó, gracias " + elPibe, (ar) => {nananana.EndSendMessage(ar);}, null);

            //Executar comando y contar como va yendo y esa onda
            var elResul = Ejecuta(elPibe, elComando);
            Console.WriteLine(elResul);

            nananana.BeginSendMessage(elResul, (ar) => {nananana.EndSendMessage(ar);}, null);
        }
        private void conversation_InstantMessageSent(object sender, MessageSentEventArgs e)
        {
            var modality     = sender as InstantMessageModality;
            var participants = modality.Conversation.Participants;

            string name    = (string)modality.Participant.Contact.GetContactInformation(ContactInformationType.DisplayName);
            var    convKey = calculateKey(participants);

            if (conversationContent.ContainsKey(convKey))
            {
                var onGoingConv = conversationContent[convKey];
                onGoingConv.AddVerse(name, e.Text);
            }
            else
            {
                var newConv = new ConversationContext();
                newConv.AddVerse(name, e.Text);
                conversationContent.Add(convKey, newConv);
            }
        }
 private void conversation_InstantMessageSent(object sender, MessageSentEventArgs e)
 {
     var modality = sender as InstantMessageModality;
     var participants = modality.Conversation.Participants;
     
     string name = (string)modality.Participant.Contact.GetContactInformation(ContactInformationType.DisplayName);
     var convKey = calculateKey(participants);
     
     if (conversationContent.ContainsKey(convKey))
     {
         var onGoingConv = conversationContent[convKey];
         onGoingConv.AddVerse(name,e.Text);
     }
     else
     {
         var newConv = new ConversationContext();
         newConv.AddVerse(name,e.Text);
         conversationContent.Add(convKey,newConv);
     }      
 }
        void imModality_InstantMessageReceived(object sender, MessageSentEventArgs e)
        {
            try
            {
                var modality = (InstantMessageModality)sender;
                IDictionary<InstantMessageContentType, string> messageFormatProperty = e.Contents;

                string source = (string)modality.Participant.Contact.GetContactInformation(ContactInformationType.DisplayName);

                string text = "";
                string raw = "";
                if (messageFormatProperty.ContainsKey(InstantMessageContentType.PlainText))
                {
                    if (messageFormatProperty.TryGetValue(InstantMessageContentType.PlainText, out raw))
                    {
                        text = raw;
                    }
                }
                else if (messageFormatProperty.ContainsKey(InstantMessageContentType.RichText))
                {
                    if (messageFormatProperty.TryGetValue(InstantMessageContentType.RichText, out raw))
                    {
                        text = Util.TextFromRtf(raw);
                    }
                }
                else if (messageFormatProperty.ContainsKey(InstantMessageContentType.Html))
                {
                    if (messageFormatProperty.TryGetValue(InstantMessageContentType.Html, out raw))
                    {

                        var reg = new System.Text.RegularExpressions.Regex("<[^>]+>");
                        var stripped = reg.Replace(raw, "");
                        text = System.Web.HttpUtility.HtmlDecode(stripped);
                    }
                }
                //else if (messageFormatProperty.ContainsKey(InstantMessageContentType.Gif))
                //{
                //    if (messageFormatProperty.TryGetValue(InstantMessageContentType.Gif, out raw))
                //    {
                //        // gif, "base64:{data}"
                //    }
                //}
                //else if (messageFormatProperty.ContainsKey(InstantMessageContentType.Ink))
                //{
                //    // InkSerializedFormat (application/x-ms-ink)
                //    if (messageFormatProperty.TryGetValue(InstantMessageContentType.Ink, out raw))
                //    {
                //        // isf, just use Microsoft.Ink to Load/Save
                //    }
                //}

                if (!string.IsNullOrEmpty(text))
                {
                    if (whisperCat.HandleWhisper(modality.Conversation, modality.Participant, text))
                    {
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 void imModality_InstantMessageReceived(object sender, MessageSentEventArgs e)
 {
     throw new NotImplementedException();
 }
Exemple #37
0
        /// <summary>
        /// log to fileLog all messages of a conversation
        /// (InstantMessageReceived callback)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <param name="fileLog"></param>
        static void remoteImModality_InstantMessageReceived(object sender, MessageSentEventArgs e, String fileLog)
        {
            InstantMessageModality modality = (InstantMessageModality)sender;

            //gets the participant name
            string name = (string)modality.Participant.Contact.GetContactInformation(ContactInformationType.DisplayName);

            //reads the message in its plain text format (automatically converted)
            string message = e.Text;

            //write message to log
            using (FileStream stream = File.Open(fileLog, FileMode.Append, FileAccess.Write, FileShare.ReadWrite))
            {
                using (StreamWriter writer = new StreamWriter(stream))
                {
                    if (name.Contains(_name_shortener))
                    {
                        name = name.Substring(name.IndexOf(_name_shortener) + _name_shortener.Length);
                    }
                    writer.WriteLine(String.Format(LOG_MESSAGE, name, DateTime.Now.ToString("HH:mm:ss"), message));
                }
            }
        }
 protected void OnGroupCreated(MessageSentEventArgs e)
 {
     if (GroupCreated != null)
         GroupCreated(this, e);
 }
Exemple #39
0
 void Form1_InstantMessageReceived(object sender, MessageSentEventArgs e)
 {
     ((InstantMessageModality)sender).BeginSendMessage(e.Text + " - i hear ya", StartConversationCallback, null);
 }
 protected void OnMessageSent(MessageSentEventArgs e)
 {
     if (MessageSent != null)
         MessageSent(this, e);
 }
Exemple #41
0
        /// <summary>
        /// Called by the Lync SDK when a new message is received.
        /// </summary>
        private void remoteImModality_InstantMessageReceived(object sender, MessageSentEventArgs args)
        {
            try
            {
                //casts the modality
                InstantMessageModality modality = (InstantMessageModality)sender;

                //gets the participant name
                string name = (string)modality.Participant.Contact.GetContactInformation(ContactInformationType.DisplayName);

                //reads the message in its plain text format (automatically converted)
                string message = args.Text;

                //notifies the UI about the new message
                MessageRecived(message, name, modality);
            }
            catch (Exception ex)
            {
                MessageError(ex);
            }
        }
        void ImModality_InstantMessageReceived(object sender, MessageSentEventArgs e)
        {
            if (checkBox1.Checked)
            {
                // Get the instant mesage modality that raised this event, and the contact that it belongs to
                var imModality = (InstantMessageModality)sender;
                var contact = imModality.Participant.Contact;

                var instantMessageText = e.Text;
                string searchTerms = textBox1.Text;
                string[] terms = searchTerms.Split(';');
                foreach (string item in terms)
                {
                    if (instantMessageText.Contains(item) && item != string.Empty)
                    {
                        Dictionary<InstantMessageContentType, String> messages = new Dictionary<InstantMessageContentType, String>();
                        messages.Add(InstantMessageContentType.PlainText, coffeeBot.Text);

                        imModality.BeginSendMessage(messages, null, messages);
                        break;
                    }
                }
            }


            // Raise the NewInstantMessage event
            //OnNewInstantMessage(contact.Uri, instantMessageText);
        }
 /// <summary>
 /// Callback is invoked when IM Modality state changes upon receipt of message
 /// </summary>
 /// <param name="source">InstantMessageModality Modality </param>
 /// <param name="data">SendMessageEventArgs The new message.</param>
 void myInstantMessageModality_MessageReceived(Object source, MessageSentEventArgs data)
 {
     IDictionary<InstantMessageContentType, string> messageFormatProperty = data.Contents;
     if (messageFormatProperty.ContainsKey(InstantMessageContentType.PlainText))
     {
         string outVal = string.Empty;
         string Sender = (string)((InstantMessageModality)source).Participant.Contact.GetContactInformation(ContactInformationType.DisplayName);
         if (messageFormatProperty.TryGetValue(InstantMessageContentType.PlainText, out outVal))
         {
             //outVal will be an empty string if the received message contains only an image.
             MessageBox.Show("New message: " + outVal);
             //invoke delegate that sets text property of a form browser control with outVal
         }
     }
 }
 public void InstantMessageReceived(object sender, MessageSentEventArgs e)
 {
     _IncomingMessages.Enqueue(e.Text);
 }
Exemple #45
0
        private void MsgReceived(object sender, MessageSentEventArgs data)
        {
            RefreshChatId();
            var modality = (InstantMessageModality)sender;
            long userId = UserDb.GetDb().GetOrAddUserId(modality.Participant.Contact);
            if (userId <= 0)
                return;

            string plainMsg;
            if (!data.Contents.TryGetValue(InstantMessageContentType.PlainText, out plainMsg))
            {
                plainMsg = data.Text;
            }

            string htmlMsg;
            data.Contents.TryGetValue(InstantMessageContentType.Html, out htmlMsg);

            htmlMsg = htmlMsg ?? "";
            plainMsg = plainMsg ?? "";

            if (!string.IsNullOrEmpty(htmlMsg))
            {
                plainMsg = HtmlMsg2PlainMsg(htmlMsg);
            }

            AddMessage(_dbChatId, userId, htmlMsg, plainMsg, _convId);
        }