示例#1
0
        public static async void processIndividualUpdate(TGUpdate update)
        {
            var msg      = update.message;
            var langcode = "en"; // default language is englsh
            var gc       = await GroupConfiguration.loadObject(update.message.chat.id);

            if (gc == null)
            {
                gc = GroupConfiguration.initializeObject(update.message.chat.id); // Init group config if it doesnt exist
            }

            //if (msg.from.language_code!=null)
            //{
            //   langcode = msg.from.language_code; // Check if the user has language settings
            //    Console.WriteLine(langcode);
            //} else
            {
                langcode = gc.langCode; // use group configuration if they don't.
            }
            Console.WriteLine(langcode);

            // Do captcha
            if (msg.new_chat_members != null)
            {
                var ncm = msg.new_chat_members;
                for (int i = 0; i < ncm.Length; i++)
                {
                    if (ncm[i].username == botUsername)
                    {
                        var cl1  = Localization.getLanguageFile(langcode);
                        var cl   = Localization.getStringLocalized(langcode, "locale/currentLangName");
                        var smsg = string.Format(Localization.getStringLocalized(langcode, "basic/xenfbot"), "3.0.0.1", cl, cl1.author, cl1.version, "@xayrga");
                        smsg += "\n\n";
                        smsg += Localization.getStringLocalized(langcode, "basic/welcome");

                        msg.replySendMessage(smsg);
                    }


                    ///// ADD FILTERS HERE ////
                    bool ok = true;
                    if (ok)
                    {
                        ok = await Filters.botscreen.Execute(msg, ncm[i], gc, langcode);
                    }
                    if (ok)
                    {
                        ok = await Filters.captcha.Execute(msg, ncm[i], gc, langcode);
                    }
                }
            }

            if (msg.text != null)
            {
                await CommandSystem.runCommand(msg, gc, langcode);
            }
        }
        public static void processIndividualUpdate(TGUpdate update)
        {
            var msg = update.message;

            if (msg.from.is_bot) // Don't process updates from other bots
            {
                return;
            }

            var langcode = "en"; // default language is englsh
            var gc       = GroupConfiguration.getConfig(update.message.chat.id);
            var VFD      = Verify.getVerifyData(update.message.from, update.message.chat, update.message);
            var doubt    = Verify.checkDoubt(update.message.from, update.message.chat);

            // Do captcha
            if (msg.new_chat_members != null)
            {
                var ncm = msg.new_chat_members;
                for (var i = 0; i < ncm.Length; i++)
                {
                    if (ncm[i].username == root.botUsername)
                    {
                        var cl1  = Localization.getLanguageInfo(langcode);
                        var cl   = Localization.getStringLocalized(langcode, "locale/currentLangName");
                        var smsg = Localization.getStringLocalized(langcode, "basic/xenfbot",
                                                                   " BRN 'MASTER' 4.0.8 (Noodle Dragon) ", cl, cl1.authors, cl1.version,
                                                                   "*****@*****.**");
                        smsg += "\n\n";
                        smsg += Localization.getStringLocalized(langcode, "basic/welcome");

                        msg.replySendMessage(smsg);
                    }

                    if (!ncm[i].is_bot)
                    {
                        root.callHook.Call("NewChatMember", gc, msg, VFD, doubt, ncm[i]);
                    }
                }
            }

            if (msg.text != null)
            {
                root.callHook.Call("OnTextMessage", gc, msg, VFD, doubt);
            }

            root.callHook.Call("OnRawMessage", gc, msg, VFD, doubt);
        }