Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
 protected override void OnStop()
 {
     if (_Bot != null && _Bot.Free(this, TelegramBot.ReleaseCreateTelegramBotClient))
     {
         _Bot.Value.OnMessage -= C_OnMessage;
         _Bot = null;
     }
 }
Exemplo n.º 3
0
 protected override void OnStop()
 {
     if (_Bot != null)
     {
         _Bot.Free(this, TelegramBot.ReleaseCreateTelegramBotClient);
         _Bot = null;
     }
 }
Exemplo n.º 4
0
        protected override void OnStart()
        {
            if (string.IsNullOrEmpty(ApiKey))
            {
                return;
            }

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