Ejemplo n.º 1
0
 private static void SaveSettings()
 {
     try
     {
         string jsonText = JsonConvert.SerializeObject(_settings);
         File.WriteAllText(settingsPathString, jsonText);
     }
     catch (Exception ex)
     {
         GarbageFunctionality.Log(ex);
         throw new Exception("Could not save settings", ex);
     }
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            try
            {
                var settings = Settings.Instance();
                using (var context = BotDbContextFactory.Create(Settings.Instance().connectionString))
                {
                    var listFromDb = (from all in context.Shitposts select all).ToList();
                    ShitpostQueue.posts = listFromDb;
                }

                var api = new TelegramAPIClass(settings.token);
            }
            catch (Exception ex)
            {
                GarbageFunctionality.Log("Shutting down");
            }
        }
Ejemplo n.º 3
0
 private static Settings ReadSettings()
 {
     try
     {
         var jsonText = File.ReadAllText(settingsPathString);
         var jsonObj  = JsonConvert.DeserializeObject <Settings>(jsonText);
         if (jsonObj == null)
         {
             throw new JsonException("Could not deserialize " + jsonText);
         }
         else if (jsonObj.token == noTokenString)
         {
             throw new FormatException("Please change default token in settings.json to your Telegram Bot API token");
         }
         return(jsonObj);
     }
     catch (Exception ex)
     {
         GarbageFunctionality.Log(ex);
         throw new Exception("Could not read settings", ex);
     }
 }