Beispiel #1
0
 static void SpecCommands(string a, Chat CurChat)
 {
     if (CurChat.IsAdmin())
     {
         Say(Answering(a), CurChat);
         if (a == "exit" || a == "shutdown")
         {
             LoveBot.StopReceiving();
             Thread.Sleep(1000);
             if (a == "shutdown")
             {
                 Process.Start("shutdown", "/s /t 0");
             }
             Environment.Exit(0);
         }
         else if (a == "block")
         {
             Process.Start(@"C:\WINDOWS\system32\rundll32.exe", "user32.dll,LockWorkStation");
         }
         else if (a == "show")
         {
             //Process.Start(@"msg.txt");
         }                /*
                           * else if (a == "full")
                           * {
                           *     string r="";
                           *     foreach (string s in CurChat.Song)
                           *     {
                           *             r += s + "\n";
                           *     }
                           *     Say(r, CurChat);
                           * }*/
     }
     else
     {
         Say(Answering("cannot"), CurChat);
     }
 }
Beispiel #2
0
        private static void GetMessage(object sender, Telegram.Bot.Args.MessageEventArgs e)
        {
            var msg = e.Message;

            if (msg == null)
            {
                return;
            }
            msg.Date = msg.Date.ToLocalTime();
            if (TurnOn == DateTime.MinValue || DateTime.Compare(msg.Date, TurnOn) < 0)
            {
                return;                                                                                    ///not first
            }
            Chat CurChat = DB.IDtoChat(msg.Chat.Id);

            if (CurChat.LastMsgId == msg.MessageId)
            {
                return;
            }
            if (msg.Type == Telegram.Bot.Types.Enums.MessageType.Voice && CurChat.IsAdmin())
            {
                SpecCommands("block", CurChat);
            }
            if (msg.Type == Telegram.Bot.Types.Enums.MessageType.Text)
            {
                if (msg.Text[0] == '/')
                {
                    CommandAnalyse(msg.Text, CurChat, msg.Date);
                }
                else
                {
                    bool FromBot = msg.ReplyToMessage != null && msg.ReplyToMessage.From.Id == BOT;
                    if (!CurChat.IsPrivate() && !StringChanger.ToLower(StringChanger.RemoveSymb(msg.Text, "none")).Contains("сапфир") && !FromBot)
                    {
                        return;
                    }
                    if (CurChat.mode == 0)
                    {
                        SimpleTextAnalyse(msg.Text, CurChat);
                    }
                    else if (!TextToResp(msg.Text, CurChat))
                    {
                        if (!FromBot && !CurChat.IsPrivate())
                        {
                            return;
                        }
                        if (CurChat.mode == 1)
                        {
                            FindPhoto(msg.Text, CurChat);
                        }
                        else if (CurChat.mode == 2)
                        {
                            msg.Text = StringChanger.RemoveSymb(msg.Text, "none");
                            msg.Text = StringChanger.ToLower(msg.Text);
                            FindSong(msg.Text, CurChat);
                        }
                        else if (CurChat.mode == 3)
                        {
                            msg.Text = StringChanger.RemoveSpaces(msg.Text);
                            FindRhyme(msg.Text, CurChat);
                        }
                    }
                }
            }
            CurChat.LastMsgId = msg.MessageId;
            DB.SaveChat(CurChat, false);
        }
Beispiel #3
0
        static public string Answering(string key, Chat CurChat = null)
        {
            string BotPrev;

            if (CurChat != null)
            {
                BotPrev = CurChat.BotPrev;
            }
            else
            {
                BotPrev = "";
            }
            string responce = "";

            if (key == null || key == "ignore")
            {
                return(null);
            }
            if (key == "привет" && BotPrev.Contains("привет"))
            {
                key = "а ты как";
            }
            if (key == "как дела" && !BotPrev.Contains("как дела"))
            {
                key += "+";
            }
            if ((key == "любима" || key == "любишь") && !CurChat.IsAdmin())
            {
                key += "-";
            }
            if (DB.ContainsKey(key))
            {
                responce = DB.RandResp(key) + " ";
                if (key == "приветствие")
                {
                    responce = DB.RandResp("привет") + ", " + responce + DB.RandResp("smile");
                }
                else if (key == "настроение")
                {
                    responce = DB.RandResp("настроение") + DB.RandResp("smile");
                }
                else if (key == "как дела+")
                {
                    responce = DB.RandResp("как дела") + ", " + responce;
                }
                else if ((key == "любима" || key == "любишь" || key == "пока") && CurChat.IsAdmin())
                {
                    responce += DB.RandResp("kiss");
                }
                else if (key.Contains("привет"))
                {
                    responce += DB.RandResp("smile");
                }
                else if (key == "none")
                {
                    responce += DB.RandResp("sad");
                }
            }
            else
            {
                responce = key;
            }
            return(responce);
        }