This repository has been archived by the owner on Nov 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AUannounce.cs
55 lines (49 loc) · 1.98 KB
/
AUannounce.cs
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System.Threading.Tasks;
using Impostor.Api.Games.Managers;
using Impostor.Api.Innersloth;
using Impostor.Api.Plugins;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Configuration;
namespace Impostor.Plugins.AUannounce
{
[ImpostorPlugin("gg.impostor.AUannounce")]
public class AUannounce : PluginBase
{
private readonly ILogger<AUannounce> _logger;
private readonly IGameManager _gameManager;
internal static AUannounceSettings settings = new AUannounceSettings();
public AUannounce(ILogger<AUannounce> logger, IGameManager gameManager)
{
_logger = logger;
_gameManager = gameManager;
new ConfigurationBuilder()
.AddJsonFile("config.json", optional: false, reloadOnChange: false)
.Build()
.Bind("AUannounce", settings);
}
public override ValueTask EnableAsync()
{
if (settings.Enabled == true)
{
_logger.LogInformation("AUannounce is being enabled.");
string replaceWith = " ";
string removedBreaks = AUannounce.settings.Announcement.Replace("\r\n", replaceWith).Replace("\n", replaceWith).Replace("\r", replaceWith);
_logger.LogInformation($"The latest announcement is " + removedBreaks);
return new ValueTask();
}
else
{
_logger.LogInformation("AUannounce is off");
string replaceWith = " ";
string removedBreaks = AUannounce.settings.Announcement.Replace("\r\n", replaceWith).Replace("\n", replaceWith).Replace("\r", replaceWith);
_logger.LogInformation($"The last logged announcement is " + removedBreaks);
return new ValueTask();
}
}
public override ValueTask DisableAsync()
{
_logger.LogInformation("AUannounce is being disabled.");
return default;
}
}
}