-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfig.cs
More file actions
40 lines (35 loc) · 1.4 KB
/
Config.cs
File metadata and controls
40 lines (35 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
namespace TeleBot
{
public static class Config
{
private static Dictionary<string, string> config;
private static Dictionary<string, string> secret;
static Config()
{
config = JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText("config.json"))!;
var reader = new StreamReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("TeleBot.secret-config.json")!);
secret = JsonSerializer.Deserialize<Dictionary<string, string>>(reader.ReadToEnd())!;
}
public static void save()
{
File.WriteAllText("config.json", JsonSerializer.Serialize(config));
}
public static string api_id => secret["api_id"];
public static string api_hash => secret["api_hash"];
public static string last_acc {
get { return File.ReadAllText("last"); }
set { File.WriteAllText("last", value); }
}
public static int sendMessageDelay => Convert.ToInt32(config["SendMessageDelay"]);
public static int getMessageDelay => Convert.ToInt32(config["GetMessageDelay"]);
public static int getMessageBatch => Convert.ToInt32(config["GetMessageBatch"]);
}
}