Esempio n. 1
0
        static void AdminComand(ref Browsing browse, string comand)
        {
            if (comand.Contains(COMAND.targetcmd))
            {
                //Remove the comand name before looking for contacts/groups/target
                string target = comand.Remove(comand.IndexOf(COMAND.targetcmd), COMAND.targetcmd.Length + 1);//+1 Because there is a space in front
                Console.WriteLine(target);
                browse.accesTarget(target);
            }
            else if (comand.Contains(COMAND.sendmsgtocmd)) // Ex: !sendmsgto ana are mere -Nimic -5
            {
                bool skipWhile = false;

                string buffer = comand.Remove(comand.IndexOf(COMAND.sendmsgtocmd), COMAND.sendmsgtocmd.Length + 1); //+1 Because there is a space in front
                Console.WriteLine();
                int space1 = buffer.IndexOf('-');                                                                   // Find first -
                int space2 = buffer.IndexOf('-', space1 + 1);                                                       // Find second -, using space1+1 as the starting position
                if (space2 == -1)                                                                                   // The function return -1 if substring not found
                {
                    space2    = buffer.IndexOf(' ', space1 + 1);
                    skipWhile = true;
                }
                if (space2 == -1)
                {
                    space2    = buffer.Length - space1;
                    skipWhile = true;
                }
                string msg    = buffer.Substring(0, space1);        // space1 in cazul asta este marimea substringului
                string target = buffer.Substring(space1 + 1, space2 - space1 - 1);

                space2++;
                int times = 1;
                if (skipWhile == false)
                {
                    while (buffer[space2] == ' ' || buffer[space2] > '9' || buffer[space2] < '1')
                    {
                        space2++;
                    }
                    times = buffer[space2] - 48;
                }
                Console.WriteLine(space2);
                //Console.WriteLine(buffer[space2]);
                Console.WriteLine(times);
                browse.sendMsgTo(msg, target, times);
            }
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Browsing browse = new Browsing();

            while (true)
            {
                string input = Console.ReadLine();
                AdminComand(ref browse, input);
                browse.accesTarget(input);
                while (true)
                {
                    browse.ReadMsgs(input);
                    System.Threading.Thread.Sleep(500); //KINDA needed to make sure i dont run the same comand twice
                }

                //AdminComand(ref browse, input);
            }
        }