Esempio n. 1
0
        public Bot(System.String api) : base(api)
        {
            DataBase db = Singleton.GetInstance().Context;

            _exitEvent = new AutoResetEvent(false);

            BotClient.OnMessage            += BotAnaliz;
            BotClient.OnCallbackQuery      += CallBack;
            BotClient.OnUpdate             += BotClient_OnUpdate;
            BotClient.OnInlineQuery        += BotClient_OnInlineQuery;
            BotClient.OnInlineResultChosen += BotClient_OnInlineResultChosen;
            BotClient.OnReceiveError       += BotClient_OnReceiveError;


            BotClient.StartReceiving();
            Console.WriteLine(BotClient.GetMeAsync().Result);

            var tempUsers = db.GetCalendarUsers();

            if (tempUsers != null)
            {
                users_calendar = GetCalendarUsers(tempUsers);
            }

            UpdateSystem.DeletePinnedMessages(BotClient);
        }
        public async Task <IActionResult> Register(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get")]
            HttpRequest request)
        {
            var me = await BotClient.GetMeAsync();

            return(new OkObjectResult(me.Username));
        }
Esempio n. 3
0
        public MyBot(System.String api) : base(api)
        {
            _exitEvent = new AutoResetEvent(false);

            BotClient.OnMessage       += OnMessage;
            BotClient.OnCallbackQuery += OnCallbackQuery;
            BotClient.OnUpdate        += OnUpdate;

            BotClient.StartReceiving();
            Console.WriteLine(BotClient.GetMeAsync().Result);
        }
Esempio n. 4
0
        static async Task Main(string[] args)
        {
            try
            {
                var settings      = File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(), "settings.json"));
                var configuration = JsonConvert.DeserializeObject <BotConfiguration>(settings);
                var bot           = new BotClient(configuration);
                var self          = await bot.GetMeAsync();

                Console.WriteLine($"Self id: {self.Id}");
                bot.Start();
                Console.WriteLine("Started bot");

                await Task.Delay(Timeout.Infinite);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Simple method that shows bot id and bot name (Use it for testing connection)
        /// </summary>
        public void PrintBotName()
        {
            var me = BotClient.GetMeAsync().Result;

            MessageBox.Show($"Hello, my name is {me.FirstName} and my id is {me.Id}");
        }
Esempio n. 6
0
        public Bot(System.String api) : base(api)
        {
            System.Console.WriteLine(BotClient.GetMeAsync().Result);

            calendars = new List <ICalendar>()
            {
                #region 1
                new CalendarBot(),
                new Next(),
                new Back(),
                new BackToStart(),
                new BackToCalendar(),
                new AddReminder(),
                new ShowOneDayCalendar(),
                new AddContextReminder(),
                new AddContextPurpose(),
                new AddContextEvent(),
                new BackToMenuReminder(),
                new AddTime(),
                new AddReminderReiteration(),
                new EachDayReminder(),
                new EachWeakReminder(),
                new EachMouthReminder(),
                new EachYearReminder(),
                new EachDayPurpose(),
                new EachWeakPurpose(),
                new EachMouthPurpose(),
                new EachYearPurpose(),
                new EachDayEvent(),
                new EachWeakEvent(),
                new EachMouthEvent(),
                new EachYearEvent(),
                new BackToevent(),
                new AddPurpose(),
                new AddPurooseReiteration(),
                new AddEventReiteration(),
                new DurationPurpose(),
                new BackToPurpose(),
                new BackToReminder(),
                new DurationPurposeTime15(),
                new DurationPurposeTime30(),
                new DurationPurposeTime1(),
                new DurationPurposeTime2(),
                new AddEventNotBusy(),
                new AddEventBusy(),
                new AddEventNotBusy2(),
                new AddLocation(),
                new ShowEvent(),
                new ShowReminder(),
                new ShowPurpose(),
                new BackToChoseDate(),
                new ChangeReminderName(),
                new ChangeReminderNote(),
                new ChangeReminderReiteration(),
                new DeleteAllEvent(),
                new ChangeAllTime(),
                #endregion
                new ChangePurposeName(),
                new ChangePurposeNote(),
                new ChangePurposeReiteration(),
                new ChangeEventLocation(),
                new ChangeEventReiteration(),
                new BackToChangePurpose(),
                new BackToChangeReminder(),
                new BackToChangeEvent(),
                new OrganizerSattisticDay(),
                new ChangeEventName(),
                new ChangeEventNote()
            };

            BotClient.OnMessage       += BotAnaliz;
            BotClient.OnCallbackQuery += CallBack;

            BotClient.StartReceiving();
        }