buypeeb-cs/Settings.cs

42 lines
1.3 KiB
C#
Raw Normal View History

2020-09-02 03:21:32 +00:00
using System;
2020-09-01 10:41:29 +00:00
using System.Collections.Generic;
namespace Buypeeb {
2020-09-02 04:12:56 +00:00
2020-09-01 10:41:29 +00:00
class Settings {
2020-09-02 04:12:56 +00:00
public int updateInterval { get; set; } = 10 * 60;
public int favouriteUpdateInterval { get; set; } = 5 * 60;
public int updateIntervalCritical { get; set; } = 60;
public int favouriteUpdateIntervalCritical { get; set; } = 30;
public Dictionary<string, Listing> watchlist {
get; set;
}
2020-09-01 10:41:29 +00:00
public Settings() {
2020-09-03 13:47:36 +00:00
if (this.watchlist == null) {
// either this is the first time the program has been run, or there's something wrong with userdata.json
this.watchlist = new Dictionary<string, Listing>();
// this.Watch("https://buypeeb.biz/whatever/k12345", "my thingy");
// this.Watch("https://buypeeb.biz/whatever/z09876", "your thingy");
// this.Watch("https://buypeeb.biz/whatever/h55555", "our thingy");
// for (int i = 0; i < 10; i++) {
// this.Watch($"https://buypeeb.biz/whatever/x{i * 123}", $"filler {i}");
// }
// this.watchlist["k12345"].Update();
2020-09-02 04:12:56 +00:00
}
2020-09-03 05:23:23 +00:00
2020-09-02 03:21:32 +00:00
}
public void Watch(string url, string name) {
string id = BuypeebApp.IDFromURL(url);
Console.WriteLine(id);
this.watchlist[id] = new Listing(url, id, name);
foreach (KeyValuePair<string, Listing> entry in this.watchlist) {
Console.WriteLine("{0} - {1}", entry.Value.name, entry.Value.price);
}
2020-09-01 10:41:29 +00:00
}
}
}