示例#1
0
        static void ProcessGroupMessage(Telegram.Bot.Args.MessageEventArgs e)
        {   // test group -482596285
            if (e.Message.Text.ToLower().StartsWith("/ann"))
            {
                if (e.Message.From.Username == "mcopper" || e.Message.From.Username == "Anatol93" || e.Message.From.Username == "novaoffice")
                {
                    SendANN();
                }
            }
            switch (e.Message.Text)
            {
            case "/giveaway@SavixRobot":
                if (String.IsNullOrEmpty(e.Message.From.Username))
                {
                    Workflow.SendMessage(e.Message, null, "Please set a username to use this bot!" + lf + "Go to Settings > Edit Profile > Set Username");
                    return;
                }
                WFGiveaway.DoGiveaway(UserController.GetOrAddItem(e.Message.From.Id, e.Message.From.FirstName, e.Message.From.LastName,
                                                                  e.Message.Date, e.Message.From.Username, e.Message.From.LanguageCode), e);
                break;

            case "/start@SavixRobot":
                if (String.IsNullOrEmpty(e.Message.From.Username))
                {
                    Workflow.SendMessage(e.Message, null, "Please set a username to use this bot!" + lf + "Go to Settings > Edit Profile > Set Username");
                    return;
                }
                WFWhitelist.DoWhitelist(UserController.GetOrAddItem(e.Message.From.Id, e.Message.From.FirstName, e.Message.From.LastName,
                                                                    e.Message.Date, e.Message.From.Username, e.Message.From.LanguageCode), e);
                break;
            }
        }
示例#2
0
 private void Form1_Load(object sender, EventArgs e)
 {
     UserController.Load(_file);
     WFGiveaway.LoadCount();
     labelGiveaway.Text = "Giveaway Count: " + WFGiveaway.Count;
     gridControlWhitelist.DataSource = UserController.GetItems();
     SavixBot.StartBot();
     simpleButtonStart.Enabled = false;
     simpleButtonStop.Enabled  = true;
     timerWhitelist.Interval   = 10000;
     timerWhitelist.Start();
 }
示例#3
0
        static void ParseCommand(User user, Telegram.Bot.Args.MessageEventArgs e)
        {
            switch (e.Message.Text.ToLower())
            {
            case "/ann":
                if (e.Message.From.Username == "mcopper" || e.Message.From.Username == "Anatol93" || e.Message.From.Username == "novaoffice")
                {
                    SendANN();
                }
                break;

            case "/start":
                WFWhitelist.DoWhitelist(user, e);
                break;

            case "/giveaway":
                WFGiveaway.DoGiveaway(user, e);
                break;

            default:
                // print commands
                break;
            }
        }
示例#4
0
        static void BotClient_OnMessage(object sender, Telegram.Bot.Args.MessageEventArgs e)
        {
            // ignore other bots
            if (e.Message.From.IsBot)
            {
                return;
            }

            if (Paused)
            {
                Workflow.SendMessage(e.Message, null, "Bot is in maintenance mode, please try again later...");
                return;
            }

            if (e.Message.Text == null)
            {
                return;
            }

            try
            {
                if (!IsMember(e.Message.From.Id, -1001354512306))
                {
                    Workflow.SendMessage(e.Message, null, "You must be a member of the Savix group (@savix_org) to continue" + lf + "Please join....");
                    return;
                }
            }
            catch (Exception ex)
            {
                Workflow.SendMessage(e.Message, null, "Error: " + ex.Message + lf + "Please try again...");
                return;
            }

            if (e.Message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Group || e.Message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Supergroup)
            {
                ProcessGroupMessage(e);
                return;
            }

            if (String.IsNullOrEmpty(e.Message.From.Username))
            {
                Workflow.SendMessage(e.Message, null, "Please set a username to use this bot!" + lf + "Go to Settings > Edit Profile > Set Username");
                return;
            }

            User user = UserController.GetOrAddItem(e.Message.Chat.Id, e.Message.Chat.FirstName, e.Message.Chat.LastName,
                                                    e.Message.Date, e.Message.Chat.Username, e.Message.From.LanguageCode);

            user.ChatProtocol.Add(e.Message.Text);


            if (e.Message.Text.StartsWith("/"))
            {
                ParseCommand(user, e);
            }
            else
            {
                switch (user.Workflow)
                {
                case "whitelist":
                    WFWhitelist.DoWhitelist(user, e);
                    break;

                case "giveaway":
                    WFGiveaway.DoGiveaway(user, e);
                    break;

                default:
                    break;
                }
            }
        }