Exemplo n.º 1
0
        private bool UnsubscribeInternal(long chatID)
        {
            if (!IsSubscribed(chatID))
            {
                Log.Write(LogLevel.NORMAL, "MedocTelegram: Cannot unsubscribe chat #" + chatID + " - already not subscribed");
                return(false);
            }

            if (!TelegramChatsStorage.TelegramChats.Remove(chatID))
            {
                Log.Write(LogLevel.NORMAL, "MedocTelegram: Cannot unsubscribe chat #" + chatID + " - something wrong with internal chat list");
                return(false);
            }

            // Does this user still subscribed?
            if (IsSubscribed(chatID))
            {
                Log.Write(LogLevel.NORMAL, "MedocTelegram: Cannot unsubscribe chat #" + chatID + " - chat list still has this chat in it");
                return(false);
            }

            TelegramChatsStorage.Save();

            return(true);
        }
Exemplo n.º 2
0
        private bool SubscribeInternal(long chatID)
        {
            if (IsSubscribed(chatID))
            {
                Log.Write(LogLevel.NORMAL, "MedocTelegram: Cannot subscribe chat #" + chatID + " - already subscribed");
                return(false);
            }

            TelegramChatsStorage.TelegramChats.Add(chatID);

            // Double check
            if (!IsSubscribed(chatID))
            {
                Log.Write(LogLevel.NORMAL, "MedocTelegram: Cannot subscribe chat #" + chatID + " - something wrong with internal chat list");
                return(false);
            }

            TelegramChatsStorage.Save();

            return(true);
        }