Example #1
0
 public static void Handler(ParamResponse e, TGUpl a)
 {
     if (polls[0] != null)
     {
         int i = 0;
         for (; i < polls.Length; i++)
         {
             if (polls[i].chat_id == e.call_chat_id && polls[i].message_id == e.call_message_id)
             {
                 polls[i].votes[Int32.Parse(e.call_data)].votes++;
                 break;
             }
         }
         Poll tmp = PollHandler.GetPoll(e.call_chat_id, e.call_message_id);
         if (tmp.chat_id != null)
         {
             a.EditMessage(polls[i].chat_id, polls[i].message_id, polls[i].Text, polls[i].GetMarkup());
         }
         a.answerCallbackQuery(e.call_id);
     }
     return;
 }
Example #2
0
        public void CommandCentre(ParamResponse e)
        {
            TGUpl a = new TGUpl();

            if (e.callback == true)
            {
                PollHandler.Handler(e, a);
            }
            else
            {
                int CureChat = GetChat(e.chatId);
                if (CureChat == -1)
                {
                    if (e.UId == MainModer.UId)
                    {
                        this.AddChat(MakeChat(e, a));
                    }
                    else if (e.UId == e.chatId)
                    {
                        this.AddChat(MakeChat(e, a));
                    }
                    else
                    {
                        a.LeaveTheGroup(e.chatId);
                    }
                }
                string[] parsResult = ParsMessage(e.message);
                switch (parsResult[0])
                {
                case "/st": CommandST(parsResult, e, a); break;

                case "/dt": CommandDT(parsResult, e, a); break;

                case "/sm": CommandSM(parsResult, e, a); break;

                case "/dm": CommandDM(parsResult, e, a); break;

                case "/gtl": CommandGTL(parsResult, e, a); break;

                case "/i": CommandI(parsResult, e, a); break;

                case "/si": CommandSI(parsResult, e, a); break;

                case "/p_ddg": CommandPDDG(parsResult, e, a); break;

                case "/info": CommandInfo(parsResult, e, a); break;

                case "/get_info": CommandGetInfo(parsResult, e, a); break;

                case "/reg_me": CommandRegMe(parsResult, e, a); break;

                case "/mp": a.SendPoll(e.message, e.chatId, e.replyMessageText); break;

                default: break;
                }
                if (e.NewMember != null && e.NewMemberID == TGReq.TGUpl.BotUID)
                {
                    if (e.UId == MainModer.UId)
                    {
                        this.AddChat(MakeChat(e, a));
                    }
                    else
                    {
                        a.LeaveTheGroup(e.chatId);
                    }
                }
                if (e.NewMember != "" && e.NewMember != null && e.NewMemberID != TGReq.TGUpl.BotUID)
                {
                    SayHello(e, a);
                }
                if (e.MemberQuit != "" && e.MemberQuit != null && e.MemberQuitID == TGReq.TGUpl.BotUID)
                {
                    a.SendMessage("Бот был исключен из чата " + e.chatId, MainModer.UId);
                }
                if (e.UId == MainModer.UId)
                {
                    switch (parsResult[0])
                    {
                    case "/gcs": MainModerCommandGCS(parsResult, e, a); break;

                    case "/mt": MainModerCommandMT(parsResult, e, a); break;

                    case "/mta": MainModerCommandMTA(parsResult, e, a); break;

                    case "/rchd": RepairChatData(); break;

                    case "/sa": WriteData(a); break;

                    case "/rdftxt": MainModerCommandRDFTXT(parsResult, e, a); break;

                    default: break;
                    }
                }
                TResponse(e.message, e, a);
            }
        }