Exemplo n.º 1
0
        static void Main(string[] args)
        {
            Bot bot = new Bot();

            foreach (var bottable in bot.Modules)
                bottable.OnConsoleLine(args);
        }
Exemplo n.º 2
0
    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());
    }
Exemplo n.º 3
0
    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()
        });
    }
Exemplo n.º 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);
    }
Exemplo n.º 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();
            }
        }
Exemplo n.º 6
0
 private static Game GetOrAddGameManager(Bot.Bot bot, long id) => GameManagers.GetOrAdd(id, i => new Game(bot, i));
Exemplo n.º 7
0
    public static Task DrawAsync(Bot.Bot bot, long id, int replyToMessageId, bool action = true)
    {
        Game manager = GetOrAddGameManager(bot, id);

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

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

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

        return(manager.StartNewGameAsync());
    }
Exemplo n.º 11
0
 static void Main(string[] args)
 {
     Bot bot = new Bot("config");
     bot.Run();
 }
Exemplo n.º 12
0
 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);
 }
Exemplo n.º 13
0
 public Game(Bot.Bot bot, ChatId chatId)
 {
     _bot    = bot;
     _chatId = chatId;
 }
Exemplo n.º 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);
        }
Exemplo n.º 15
0
Arquivo: Bot.cs Projeto: pluraldj/Bot
        /// <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();
        }