protected override void OnStart()
        {
            if (string.IsNullOrEmpty(ApiKey))
            {
                return;
            }
            if (_Bot != null)
            {
                return;
            }

            _Bot = ShareableClass <TelegramBot, string> .GetOrCreate(this, ApiKey, CreateTelegramBotClient);

            if (_Bot != null)
            {
                if (IO.File.Exists(FileChatStore))
                {
                    long[] chats = SerializationHelper.DeserializeFromJson <long[]>(IO.File.ReadAllText(FileChatStore, Encoding.UTF8), false);
                    _Bot.Value.AllowedChatsClear();
                    _Bot.Value.AllowedChatsAdd(chats);
                }

                _Bot.Value.OnMessage += C_OnMessage;
            }
        }
示例#2
0
        protected override void OnStart()
        {
            if (string.IsNullOrEmpty(ApiKey))
            {
                return;
            }

            _Bot = ShareableClass <TelegramBot, string> .GetOrCreate(this, ApiKey, TelegramBotSubscribeProcess.CreateTelegramBotClient);
        }