Exemple #1
0
        static void Main(string[] args)
        {
            Bot bot = new Bot();

            foreach (var bottable in bot.Modules)
                bottable.OnConsoleLine(args);
        }
    public static async Task <List <Deck <CardAction> > > GetActionDecksAsync(Bot.Bot bot)
    {
        if (bot.Config.ActionsGoogleRange is null)
        {
            throw new NullReferenceException(nameof(bot.Config.ActionsGoogleRange));
        }
        IList <CardAction> cards =
            await DataManager.GetValuesAsync <CardAction>(bot.GoogleSheetsProvider, bot.Config.ActionsGoogleRange);

        return(cards.GroupBy(c => c.Tag)
               .Select(g => CreateActionDeck(g.Key, g.ToList()))
               .ToList());
    }
    public static async Task <Deck <Card> > GetQuestionsDeckAsync(Bot.Bot bot)
    {
        if (bot.Config.QuestionsGoogleRange is null)
        {
            throw new NullReferenceException(nameof(bot.Config.QuestionsGoogleRange));
        }
        IList <Card> cards =
            await DataManager.GetValuesAsync <Card>(bot.GoogleSheetsProvider, bot.Config.QuestionsGoogleRange);

        return(new Deck <Card>("❓")
        {
            Cards = cards.ToList()
        });
    }
Exemple #4
0
    public BotSingleton(IOptions <Config> options)
    {
        Config config = options.Value;

        if (config.GoogleCredential is null || (config.GoogleCredential.Count == 0))
        {
            if (string.IsNullOrWhiteSpace(config.GoogleCredentialJson))
            {
                throw new NullReferenceException(nameof(config.GoogleCredentialJson));
            }

            config.GoogleCredential =
                JsonConvert.DeserializeObject <Dictionary <string, string> >(config.GoogleCredentialJson);
        }
        Bot = new Bot.Bot(config);
    }
Exemple #5
0
        public static void Main()
        {
            AppConfiguration configuration = new AppConfiguration();
            TBot             bot           = new TBot(configuration);

            try
            {
                Task task = bot.StartAsync();
                task.Wait();
                Console.WriteLine("ok");

                /*
                 * var taskUser = bot.GetUser("DMAAPrivateBot");
                 * taskUser.Wait();
                 * BotUser user = taskUser.Result;
                 *
                 * var taskUser2 = bot.GetUser("its_alright");
                 * taskUser2.Wait();
                 * BotUser user2 = taskUser2.Result;
                 */

                Console.WriteLine("Активируйте чат бота.");
                Console.ReadLine();

                Task <bool> activateTask = bot.ActivateChatAsync();
                activateTask.Wait();
                bool activated = activateTask.Result;

                if (activated)
                {
                    Console.WriteLine("Бот запущен");
                }
                else
                {
                    Console.WriteLine("Не удалось активировать чат бота.");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                Console.ReadLine();
            }
        }
 private static Game GetOrAddGameManager(Bot.Bot bot, long id) => GameManagers.GetOrAdd(id, i => new Game(bot, i));
    public static Task DrawAsync(Bot.Bot bot, long id, int replyToMessageId, bool action = true)
    {
        Game manager = GetOrAddGameManager(bot, id);

        return(manager.DrawAsync(replyToMessageId, action));
    }
    public static Task <bool> ChangeChoiceChanceAsync(float choiceChance, Bot.Bot bot, long id)
    {
        Game manager = GetOrAddGameManager(bot, id);

        return(manager.ChangeChoiceChanceAsync(choiceChance));
    }
    public static Task <bool> ChangePlayersAmountAsync(ushort playersAmount, Bot.Bot bot, long id)
    {
        Game manager = GetOrAddGameManager(bot, id);

        return(manager.ChangePlayersAmountAsync(playersAmount));
    }
    public static Task StartNewGameAsync(Bot.Bot bot, long id)
    {
        Game manager = GetOrAddGameManager(bot, id);

        return(manager.StartNewGameAsync());
    }
Exemple #11
0
 static void Main(string[] args)
 {
     Bot bot = new Bot("config");
     bot.Run();
 }
 public void TableState(TableStateMessage message)
 {
     var bot = bots.Find(b => { return b.GetTableId() == message.tableId; });
     if (bot == null) {
         bot = new Bot(message.tableId, username);
         bots.Add(bot);
     }
     bot.SetPlayers(message.message.players);
 }
Exemple #13
0
 public Game(Bot.Bot bot, ChatId chatId)
 {
     _bot    = bot;
     _chatId = chatId;
 }
Exemple #14
0
        public async Task RunLadder(Bot bot, Race myRace, string[] args)
        {
            var commandLineArgs = new CLArgs(args);

            await RunLadder(bot, myRace, commandLineArgs.GamePort, commandLineArgs.StartPort);
        }
Exemple #15
0
        /// <summary>
        /// Connects to all servers according to ServerDescriptors in separate threads and suspends itself in a loop waiting for console input
        /// </summary>
        public static void Run(List<ServerDescriptor> servers, IConfig globalSettings)
        {
            Thread.CurrentThread.Name = "Main";

            foreach (ServerDescriptor server in servers)
            {
                ThreadStart threadStart = delegate { Bot instance = new Bot(server, globalSettings); instance.Connect(); };
                Thread thread = new Thread(threadStart);
                thread.Start();
            }

            do
            {
                string input = Console.ReadLine();
                if (input == "die" || input == "quit" || input == "exit")
                    quit = true;
            } while (!quit);

            Exit();
        }