Exemple #1
0
        public static void runTask()
        {
            if (Helpers.getUnixTime() < last + delay)
            {
                return;
            }

            last = Helpers.getUnixTime();
            var data = SQL.Query("SELECT * FROM `verify` WHERE `verified`=false OR `notified`=false");

            foreach (DataRow row in data)
            {
                var groupID    = (long)row["group"];
                var GCO        = GroupConfiguration.getConfig(groupID);
                var verified   = (bool)row["verified"];
                var notified   = (bool)row["notified"];
                var whenexpire = (int)row["texpire"];
                var user       = (long)row["user"];
                var mid        = (long)row["message"];
                var jmid       = (long)row["joinmessage"];

                if (verified == false)
                {
                    //Console.WriteLine($"{whenexpire} -- {Helpers.getUnixTime()}");
                    if (whenexpire < Helpers.getUnixTime())
                    {
                        doRemoval(user, mid, groupID, GCO, jmid);
                    }
                }
                else if ((notified == false) & verified)
                {
                    doNotify(user, mid, groupID, GCO, jmid);
                }
            }
        }
Exemple #2
0
        public static void runTask()
        {
            if (Helpers.getUnixTime() < last + delay)
            {
                return;
            }

            last = Helpers.getUnixTime();

            var data = SQL.Query("SELECT * FROM `cleanup`");

            if (data != null)
            {
                foreach (DataRow dr in data)
                {
                    var GCO = GroupConfiguration.getConfig((long)dr["group"]);

                    if ((int)dr["when"] + (int)dr["life"] < Helpers.getUnixTime())
                    {
                        Telegram.deleteMessage(new TGChat {
                            id = (long)dr["group"]
                        }, (long)dr["mid"]);
                        var qry = $"DELETE FROM `cleanup` WHERE `uid`={(long) dr["uid"]}";
                        var ra  = 0;
                        SQL.NonQuery(qry, out ra);
                    }
                }
            }
        }
Exemple #3
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);
        }