Esempio n. 1
0
        public static void GetLang(CallbackQuery query, string[] args)
        {
            var temp = args[1].Split('|');

            if (temp.Length == 1)
            {
                if (temp[0] == "cancel")
                {
                    Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, GetTranslation("ConfigDone", GetLanguage(query.Message.Chat.Id)));
                }
            }
            if (temp.Length > 1)
            {
                if (temp[0] == "get")
                {
                    Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, GetTranslation("ConfigDone", GetLanguage(query.Message.Chat.Id), temp[1]));
                    var lang = temp[1] + ".xml";
                    using (var sr = new StreamReader(Path.Combine(Constants.GetLangDirectory(), lang)))
                    {
                        // var file = new FileToSend(lang, sr.BaseStream);
                        BotMethods.SendDocument(query.Message.Chat.Id, new InputOnlineFile(sr.BaseStream, lang));
                    }
                }
            }
        }
Esempio n. 2
0
        public static void GroupListQuery(CallbackQuery query, string[] args)
        {
            var temp   = args[1].Split('|');
            var chatId = int.Parse(temp[0]);

            if (temp[1] == "done")
            {
                Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, GetTranslation("ConfigDone", GetLanguage(chatId)));
            }
            else
            {
                var langChosen = temp[1];
                using (var db = new SixNimmtDb())
                {
                    try
                    {
                        var groups = db.Groups.Where(x => x.GroupLink != null && x.ShowOnGroupList == true && x.Language == langChosen).ToList().Shuffle().Take(10).ToList();

                        var msg = $"{GetTranslation("GroupListForLang", GetLanguage(chatId), Program.Langs[langChosen].LanguageName)}\n";
                        foreach (var grp in groups)
                        {
                            msg += $"<a href='{grp.GroupLink}'>{grp.Name.FormatHTML()}</a>\n";
                        }
                        Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, msg);
                    }
                    catch (Exception e)
                    {
                        //
                    }
                }
            }
        }
Esempio n. 3
0
        public static void UploadLang(CallbackQuery call, string[] args)
        {
            var temp = args[1].Split('|');

            switch (temp[1])
            {
            case "current":
                Bot.Edit(call.Message.Chat.Id, call.Message.MessageId, "OK, I will do nothing.");
                return;

            default:
                UseNewLanguageFile(temp[1], call.Message.Chat.Id, call.Message.MessageId);
                return;
            }
        }
Esempio n. 4
0
        public static void UpdateQuery(CallbackQuery query, string[] args)
        {
            var temp   = args[1].Split('|');
            var update = temp[0];

            switch (update)
            {
            case "yes":
                Bot.Api.EditMessageReplyMarkupAsync(query.Message.Chat.Id, query.Message.MessageId, null).Wait();
                Commands.Update(query.Message, args);
                break;

            case "no":
                Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, "OK, I will do nothing.");
                break;
            }
        }
Esempio n. 5
0
 public static void Update(Message msg, string[] args)
 {
     if (msg.Date > DateTime.UtcNow.AddSeconds(-3) || msg.From.Id == Bot.Me.Id)
     {
         var     txt = "Waiting for games to finish and then I will update the bot.";
         Message sent;
         if (msg.From.Id == Bot.Me.Id)
         {
             sent = Bot.Edit(msg.Chat.Id, msg.MessageId, $"{msg.Text}\n\n{txt}");
         }
         else
         {
             sent = msg.Reply(txt);
         }
         Process.Start(Path.Combine(@"C:\SixNimmtBot\", "Updater.exe"), msg.Chat.Id.ToString());
         Program.MaintMode = true;
         new Thread(x => CheckCurrentGames(sent)).Start();
     }
 }
Esempio n. 6
0
        public static void ConfigQuery(CallbackQuery query, string[] args)
        {
            var temp   = args[1].Split('|');
            var chatId = long.Parse(temp[1]);

            if (temp[0] == "lang")
            {
                if (temp.Length == 2)
                {
                    var menu = Handler.GetConfigLangMenu(chatId);
                    Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, GetTranslation(chatId > 0 ? "ChoosePMLanguage" : "ChooseLanguage", GetLanguage(chatId)), menu);
                }
                if (temp.Length > 2)
                {
                    var chosenLang = temp[2];
                    Handler.SetLanguage(chatId, chosenLang);
                    var menu   = Handler.GetConfigMenu(chatId);
                    var toSend = GetTranslation("ReceivedButton", GetLanguage(chatId)) + Environment.NewLine + GetTranslation("WhatToDo", GetLanguage(chatId));
                    Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, toSend, menu);
                }
            }
            else if (temp[0] == "table")
            {
                if (temp.Length == 2)
                {
                    var menu          = Handler.GetConfigTableMenu(chatId);
                    var groupOrPlayer = Helpers.GetGroupOrPlayer(chatId);
                    var current       = groupOrPlayer.UseSticker;
                    Bot.Edit(query.Message.Chat.Id, query.Message.MessageId,
                             GetTranslation("ChooseTable", GetLanguage(chatId),
                                            current == true ? GetTranslation("ChooseUseSticker", GetLanguage(chatId)) : GetTranslation("ChooseUseText", GetLanguage(chatId))), menu);
                }
                if (temp.Length > 2)
                {
                    var chosen = temp[2] == "sticker";
                    Handler.SetTableConfig(chatId, chosen);
                    var menu   = Handler.GetConfigMenu(chatId);
                    var toSend = GetTranslation("ReceivedButton", GetLanguage(chatId)) + Environment.NewLine + GetTranslation("WhatToDo", GetLanguage(chatId));
                    Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, toSend, menu);
                }
            }
            else if (temp[0] == "deck")
            {
                if (temp.Length == 2)
                {
                    var menu = Handler.GetConfigCardDeckMenu(chatId);
                    // should be group only
                    var group   = Helpers.GetGroup(chatId);
                    var current = group.DynamicDeck;
                    Bot.Edit(query.Message.Chat.Id, query.Message.MessageId,
                             GetTranslation("ConfigCardDeckDetail", GetLanguage(chatId),
                                            current == true ? GetTranslation("ConfigDynamicDeck", GetLanguage(chatId)) : GetTranslation("ConfigStaticDeck", GetLanguage(chatId))), menu);
                }
                if (temp.Length > 2)
                {
                    var chosen = temp[2] == "dynamic";
                    Handler.SetCardDeckConfig(chatId, chosen);
                    var menu   = Handler.GetConfigMenu(chatId);
                    var toSend = GetTranslation("ReceivedButton", GetLanguage(chatId)) + Environment.NewLine + GetTranslation("WhatToDo", GetLanguage(chatId));
                    Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, toSend, menu);
                }
            }
            else if (temp[0] == "choosetime")
            {
                if (temp.Length == 2)
                {
                    var menu = Handler.GetConfigChooseCardTimeMenu(chatId);
                    // should be group only
                    var group   = Helpers.GetGroup(chatId);
                    var current = group.ChooseCardTime ?? Constants.ChooseCardTime;
                    Bot.Edit(query.Message.Chat.Id, query.Message.MessageId,
                             GetTranslation("ConfigChooseCardTimeDetail", GetLanguage(chatId), current), menu);
                }
                if (temp.Length > 2)
                {
                    var chosen = int.Parse(temp[2]);
                    Handler.SetChooseCardTimeConfig(chatId, chosen);
                    var menu   = Handler.GetConfigMenu(chatId);
                    var toSend = GetTranslation("ReceivedButton", GetLanguage(chatId)) + Environment.NewLine + GetTranslation("WhatToDo", GetLanguage(chatId));
                    Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, toSend, menu);
                }
            }
            else if (temp[0] == "grouplist")
            {
                if (temp.Length == 2)
                {
                    var menu = Handler.GetConfigGroupListMenu(chatId);
                    // should be group only
                    var group   = Helpers.GetGroup(chatId);
                    var current = group.ShowOnGroupList ?? false;
                    Bot.Edit(query.Message.Chat.Id, query.Message.MessageId,
                             GetTranslation("ConfigGroupListDetail", GetLanguage(chatId),
                                            current == true ? GetTranslation("ConfigYes", GetLanguage(chatId)) : GetTranslation("ConfigNo", GetLanguage(chatId))), menu);
                }
                if (temp.Length > 2)
                {
                    var chosen = temp[2] == "yes";
                    Handler.SetGroupListConfig(chatId, chosen);
                    var menu   = Handler.GetConfigMenu(chatId);
                    var toSend = GetTranslation("ReceivedButton", GetLanguage(chatId)) + Environment.NewLine + GetTranslation("WhatToDo", GetLanguage(chatId));
                    Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, toSend, menu);
                }
            }
            else if (temp[0] == "done")
            {
                Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, GetTranslation("ConfigDone", GetLanguage(chatId)));
            }
            else if (temp[0] == "back")
            {
                Bot.Edit(query.Message.Chat.Id, query.Message.MessageId, GetTranslation("WhatToDo", Handler.GetLanguage(chatId)), Handler.GetConfigMenu(chatId));
            }
            return;
        }