public void Skype_MessageStatus(IChatMessage ichatmessage, TChatMessageStatus Status) { // Write Message Status to Window //if (ichatmessage.Type == TChatMessageType.cmeSaid) // return; if ((ichatmessage.Status != TChatMessageStatus.cmsReceived)) { return; } this.textBox1.AppendText("Message Status: " + skype.Convert.ChatMessageStatusToText(Status)); this.textBox1.AppendText(" - " + Status.ToString() + Environment.NewLine); string botsAnswer = pi.chatWithPrelude(ichatmessage.Body); this.textBox1.AppendText("Prelude: " + botsAnswer); ichatmessage.Chat.SendMessage(botsAnswer); this.textBox1.ScrollToCaret(); }
public void Skype_MessageStatus(IChatMessage ichatmessage, TChatMessageStatus Status) { // Write Message Status to Window //if (ichatmessage.Type == TChatMessageType.cmeSaid) // return; if ((ichatmessage.Status != TChatMessageStatus.cmsReceived)) return; this.textBox1.AppendText("Message Status: " + skype.Convert.ChatMessageStatusToText(Status)); this.textBox1.AppendText(" - " + Status.ToString() + Environment.NewLine); string botsAnswer = pi.chatWithPrelude(ichatmessage.Body); this.textBox1.AppendText("Prelude: " + botsAnswer); ichatmessage.Chat.SendMessage(botsAnswer); this.textBox1.ScrollToCaret(); }
private void skype_MessageStatus(ChatMessage msg, TChatMessageStatus status) { main._labelMessageStatus = status.ToString(); // Proceed only if the incoming message is a trigger, the message is of the correct type (status) if (msg.Body.IndexOf(trigger) == 0 && (TChatMessageStatus.cmsSent == status || TChatMessageStatus.cmsReceived == status) ) { last_msg = msg; string user = msg.Sender.FullName.ToString(); string profile = msg.Sender.Handle.ToString(); #region Get Role //note, I have no idea how this works TChatMemberRole sender_role = new TChatMemberRole(); IChatMemberCollection ichatm = msg.Chat.MemberObjects; for (int i = 1; i - 1 < msg.Chat.MemberObjects.Count; i++) { if (ichatm[i].Handle == msg.Sender.Handle) { sender_role = ichatm[i].Role; i = 1000; //ridiculously large arbitrary number } } string role = sender_role.ToString(); #endregion #region blacklist/botspam //loads/checks blacklist bool test1 = true; for (int i = 0; i < blacklist.Length; i++) { if (profile == blacklist[i]) test1 = false; //only needs to be true once for the block to be active. } bool test2 = false; for (int i = 0; i < blacklist.Length; i++) //note- blacklist can be both a whitelist or a blacklist depending on the variable it receives. { if (profile == blacklist[i]) test2 = true; } //tests for botspam if ((test1 != false && sbprop._EnableBlacklist == true) || (test2 == true && sbprop._EnableWhitelist == true)) //blacklist test { if ((msg.Timestamp > last_msg_time.AddSeconds(2) || user != last_user) && profile != nick) //always blocks bot itself, regardless of blacklist { ichat = skype.get_Chat(msg.Chat.Name); string command = msg.Body.Remove(0, trigger.Length); //isolates arguments and command int a = command.IndexOf(" ", 0); string arg = ""; if (a > 0) { arg = command.Substring(a + 1); command = command.Substring(0, a).ToLower(); } else command = command.ToLower(); string full = ProcessCommand(command, arg, user, role); #region send message main._labelCommand = command + " " + arg; main._labelMessageSender = user; last_user = user; if (command == "help") skype.SendMessage(msg.Sender.Handle, full); //sends PM to the user who sent the commands else ichat.SendMessage(full); //sends to whatever chat sent the message. last_msg_time = msg.Timestamp; msg.Seen = true; #endregion } //if botspam else skype.SendMessage(msg.Sender.Handle, MasterBot[0][1]); } #endregion } }
private void Skype_MessageStatus(ChatMessage pMessage, TChatMessageStatus aStatus) { try { WriteToLog(pMessage.Sender.Handle.ToString() + " " + aStatus.ToString() + " " + pMessage.Body); string peer = pMessage.Chat.DialogPartner; string password = GetToken(peer); if (aStatus == TChatMessageStatus.cmsSending) { if (!string.IsNullOrEmpty(password)) { // encrypt byte[] msgbytes = SkypeEncryptor.Encrypt(System.Text.Encoding.Unicode.GetBytes(pMessage.Body), password); pMessage.Body = Convert.ToBase64String(msgbytes); // alter the message body WriteToLog("Message encrypted"); } } else if (aStatus == TChatMessageStatus.cmsReceived || aStatus == TChatMessageStatus.cmsRead) { if (!string.IsNullOrEmpty(password)) { // decrypt byte[] msgbytes = Convert.FromBase64String(pMessage.Body); byte[] dec = SkypeEncryptor.Decrypt(msgbytes, password); string msg = System.Text.Encoding.Unicode.GetString(dec); WriteToLog("Message decrypted: " + msg); //pMessage.Body = msg; // which is not editable } if (false) // (pMessage.Type == TChatMessageType.cmeSaid) { // Make sure the request came from the mobile account if (pMessage.Sender.Handle.Equals(this._strMobileUser)) { // OK, they want to make a change request or send an SMS try { if (pMessage.Body.Length > 3 && pMessage.Body.ToLower().Substring(0, 3).Equals("sms")) { // This is an SMS request WriteToLog("SMS request received from " + this._strMobileUser); // Get the number to SMS to string[] strBits = pMessage.Body.Split(" ".ToCharArray()); // The number to call is the second argument // (string is in the format "sms [number] [message]" string strSmsTarget = strBits[1]; // See if it is a quickswitch number int intQuickSwitch; if (int.TryParse(strSmsTarget, out intQuickSwitch) && (intQuickSwitch > 0 && intQuickSwitch < _strShortCutNums.Length)) { // Yes, this is a quickswitch number. Get the number for it strSmsTarget = this._strShortCutNums[intQuickSwitch]; } WriteToLog("Sending SMS to " + strSmsTarget); // Get the message string strMessage = pMessage.Body.Substring(pMessage.Body.IndexOf(" ", 4) + 1); WriteToLog("Message is: " + strMessage); // Send the SMS _objSkype.SendSms(strSmsTarget, strMessage, null); WriteToLog("SMS sent"); pMessage.Chat.SendMessage("SMS sent to " + strSmsTarget); WriteToLog(); } else { // This is a SkypeOut change request WriteToLog("Forwarding change request received from " + this._strMobileUser); string strNewNum = ""; switch (pMessage.Body.ToLower()) { case "off": // Switch off forwarding _objSkype.CurrentUserProfile.CallApplyCF = false; _objSkype.CurrentUserProfile.CallForwardRules = ""; break; case "1": case "2": case "3": case "4": case "5": // Quick switch number strNewNum = this._strShortCutNums[int.Parse(pMessage.Body)]; break; case "contacts": // List all the contact numbers string strContacts = "Quick switch numbers:" + Environment.NewLine; for (int i = 1; i <= 5; i++) { strContacts += i.ToString() + ": " + this._strShortCutNums[i] + Environment.NewLine; } WriteToLog("Sending user the list of quick switch numbers"); pMessage.Chat.SendMessage(strContacts); return; // Exit out of the function completely default: strNewNum = pMessage.Body; break; } if (string.IsNullOrEmpty(strNewNum)) { pMessage.Chat.SendMessage("Switched off call forwarding"); WriteToLog("Switched off call forwarding"); } else { _objSkype.CurrentUserProfile.CallApplyCF = true; _objSkype.CurrentUserProfile.CallForwardRules = "0,60," + strNewNum; _objSkype.CurrentUserProfile.CallNoAnswerTimeout = 5; pMessage.Chat.SendMessage("Reset call forwarding to " + strNewNum); WriteToLog("Changed SkypeOut forwarding to " + strNewNum); } } } catch (Exception ex) { pMessage.Chat.SendMessage("Error: " + ex.Message); } } else { // Someone else? Log and ignore WriteToLog("Chat message received from " + pMessage.Sender.Handle + " was ignored"); WriteToLog("Message was: " + pMessage.Body); } } } } catch (Exception) { } }
private void Skype_MessageStatus(ChatMessage chatmessage, TChatMessageStatus status) { this.Logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name); this.Logger.Debug(" status = " + status); switch (status) { case TChatMessageStatus.cmsRead: break; case TChatMessageStatus.cmsReceived: this.Logger.Debug(" body = " + chatmessage.Body); this.OnMessageReceived(chatmessage); break; case TChatMessageStatus.cmsSending: break; case TChatMessageStatus.cmsSent: break; default: throw new System.InvalidOperationException(status.ToString()); } }