Ejemplo n.º 1
0
 public static void InsertNewApi(string apiKey)
 {
     _telebot = new Telebot(apiKey)
     {
         Timeout = new TimeSpan(2, 0, 0)
     };
 }
Ejemplo n.º 2
0
        public async Task RunAsync()
        {
            Console.WriteLine("Running Telebot with key: {0}", this._telegramApiKey);
            this._telebot = new Telebot(this._telegramApiKey);

            while (true)
            {
                try
                {
                    var updates = (await this._telebot.GetUpdatesAsync(this._offset)).ToList();
                    if (updates.Any())
                    {
                        this._offset = updates.Max(u => u.Id) + 1;

                        foreach (var update in updates)
                        {
                            switch (update.Type)
                            {
                            case UpdateType.Message:
                                await this.CheckMessagesAsync(update);

                                break;

                            case UpdateType.InlineQuery:
                                await this.CheckInlineQueryAsync(update);

                                break;

                            case UpdateType.ChosenInlineResult:
                                this.CheckChosenInlineResult(update);
                                break;

                            default:
                                throw new ArgumentOutOfRangeException();
                            }
                        }
                    }

                    await Task.Delay(TimeSpan.FromSeconds(1));
                }
                catch (Exception ex)
                {
                    LogException(ex);

                    Console.WriteLine("Press 'Enter' to continue...");
                    Console.ReadLine();

                    WriteLine(ConsoleColor.DarkGray, "----------------------------------------------");
                }
            }
        }
Ejemplo n.º 3
0
    public override Unit buildUnit(int unitId, string unitName)
    {
        Unit unit = base.buildUnit(unitId, unitName);


        TableEnvironment environment = createObject(typeof(TableEnvironment), unit.gameObject) as TableEnvironment;
        Telebot          robot       = createObject(typeof(Telebot), unit.gameObject) as Telebot;
        Controller       controller  = createObject(typeof(Controller), unit.gameObject) as Controller;
        PlaceCupInCrate  task        = createObject(typeof(PlaceCupInCrate), unit.gameObject) as PlaceCupInCrate;

        unit.constructUnit(environment, controller, robot, task);

        environment.initializeEnvironment();
        robot.initializeRobot();
        controller.initializeController(unitId, ag.seed);

        // Task Essentials
        List <GameObject> importantParts = new List <GameObject>();

        importantParts.Add(robot.parts[0]);

        List <GameObject> importantMembers = new List <GameObject>();

        importantMembers.Add(environment.members[6]);  // Crate Bottom
        importantMembers.Add(environment.members[11]); // Cup
        importantMembers.Add(environment.members[7]);  // The crate sides
        importantMembers.Add(environment.members[8]);  // The crate sides
        importantMembers.Add(environment.members[9]);  // The crate sides
        importantMembers.Add(environment.members[10]); // The crate sides

        task.initializeTask(importantParts, importantMembers, "");

        controller.isActive = true;

        return(unit);
    }