示例#1
0
 private void Skype_ChatMemberRoleChanged(IChatMember ichatmember, TChatMemberRole role)
 {
     this.Logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name);
 }
示例#2
0
        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
            }
        }
示例#3
0
        // **** There is no TChatMemberRole to text conversion supplied by Skype4COM. ****
        public void OurChatMemberRoleChanged(IChatMember ichatmember, TChatMemberRole role)
        {
            // Always use try/catch with ANY Skype calls.
            try
            {
                // Write Chat Memeber Role Changed to Window.
                AddTextToTextBox1(DateTime.Now.ToLocalTime() + ": " +
                 "Chat Member Role Changed - ChatMember Handle: " + ichatmember.Handle +
                 " - Chat Role : " + role +
                 "\r\n");
            }
            catch (Exception e)
            {
                // Possibly old Skype4COM version, log an error, drop into debug if wanted.
                AddTextToTextBox1(DateTime.Now.ToLocalTime() + ": " +
                 "Chat Member Role Changed Event Fired - Bad Text" +
                 " - Exception Source: " + e.Source + " - Exception Message: " + e.Message +
                 "\r\n");

                // If the "Use Auto Debug" check box is checked and we are in debug, drop into debug here when retry, otherwise, prompt for action.
                Debug.Assert(!this.UseAutoDebug.Checked);
            }
        }