Skip to content

Commit

Permalink
Merge pull request #8 from GravityWolfNotAmused/GameStatus
Browse files Browse the repository at this point in the history
Add Activity Status variable to config.
  • Loading branch information
GravityWolfNotAmused authored Oct 17, 2021
2 parents f889b06 + c3b228d commit 24c2b90
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

DiscordPlayerCountBot/bin/Debug/netcoreapp3.1/Config.json
*.json
Binary file modified .vs/DiscordPlayerCountBot/v16/.suo
Binary file not shown.
12 changes: 10 additions & 2 deletions DiscordPlayerCountBot/BotConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class BotConfig
[JsonProperty]
public bool _userConfigNameAsLabel { get; set; }

[JsonProperty]
public int _activityStatus { get; set; }

public BotConfig()
{
_serverInformation = new List<DayZServerBot>();
Expand All @@ -36,6 +39,7 @@ public void CreateDefaults()
_updateTime = 30;
_steamAPIKey = "SteamAPIKeyHere";
_userConfigNameAsLabel = false;
_activityStatus = 1;
}
public async Task<List<string>> GetAddresses()
{
Expand All @@ -44,7 +48,9 @@ public async Task<List<string>> GetAddresses()
foreach (DayZServerBot bot in _serverInformation)
{
string ipAddress = bot.botAddress.Split(":")[0];
Console.WriteLine($"IPAddress: {ipAddress}");

if(_isDebug)
Console.WriteLine($"IPAddress: {ipAddress}");

if (ipAddress.ToLower() == "hostname")
{
Expand All @@ -55,7 +61,9 @@ public async Task<List<string>> GetAddresses()
Console.WriteLine("IP Address could not be resolved. Please contact Gravity Wolf on discord. GravityWolf#6981");
}
}
Console.WriteLine($"IPAddress after: {ipAddress}");

if(_isDebug)
Console.WriteLine($"IPAddress after: {ipAddress}");

if (!addresses.Contains(ipAddress))
{
Expand Down
9 changes: 6 additions & 3 deletions DiscordPlayerCountBot/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Discord.WebSocket;
using Discord;
using Discord.WebSocket;
using Newtonsoft.Json;
using PlayerCountBot;
using System;
Expand Down Expand Up @@ -53,7 +54,7 @@ async Task LoadConfig()
foreach (DayZServerBot bot in config._serverInformation)
{
DiscordSocketClient discordBot = new DiscordSocketClient();
await discordBot.LoginAsync(Discord.TokenType.Bot, bot.discordBotToken);
await discordBot.LoginAsync(TokenType.Bot, bot.discordBotToken);
await discordBot.SetGameAsync("Starting Bot watching: " + bot.botAddress);
await discordBot.StartAsync();

Expand Down Expand Up @@ -199,7 +200,9 @@ public async Task UpdatePlayerCounts()
if (config._isDebug)
Console.WriteLine("Changed Status of : " + serverAddress + ", Status: " + gameStatus);

await client.SetGameAsync(gameStatus);
var activityType = (ActivityType)(config._activityStatus <= 3 && config._activityStatus > 0 ? config._activityStatus : 0);

await client.SetGameAsync(gameStatus, null, activityType);
}
}
}
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 24c2b90

Please sign in to comment.