Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion SysBot.Pokemon.Discord/Commands/CloneModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ public class CloneModule : ModuleBase<SocketCommandContext>
public async Task CloneAsync(int code)
{
var cfg = Info.Hub.Config;
var sudo = Context.GetHasRole(cfg.DiscordRoleSudo);
var sudo = Context.GetIsSudo(cfg);
var allowed = sudo || (Context.GetHasRole(cfg.DiscordRoleCanClone) && Info.CanQueue);

if (!sudo && !Info.CanQueue)
{
await ReplyAsync("Sorry, I am not currently accepting queue requests!").ConfigureAwait(false);
return;
}

if (!allowed)
{
await ReplyAsync("Sorry, you are not permitted to use this command!").ConfigureAwait(false);
Expand All @@ -35,6 +42,7 @@ public async Task CloneAsync(int code)
}

[Command("clone")]
[Alias("c")]
[Summary("Clones the Pokemon you show via Link Trade.")]
public async Task CloneAsync()
{
Expand Down
11 changes: 9 additions & 2 deletions SysBot.Pokemon.Discord/Commands/DuduModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ public class DuduModule : ModuleBase<SocketCommandContext>
public async Task SeedCheckAsync(int code)
{
var cfg = Info.Hub.Config;
var sudo = Context.GetHasRole(cfg.DiscordRoleSudo);
var sudo = Context.GetIsSudo(cfg);
var allowed = sudo || (Context.GetHasRole(cfg.DiscordRoleCanDudu) && Info.CanQueue);

if (!sudo && !Info.CanQueue)
{
await ReplyAsync("Sorry, I am not currently accepting queue requests!").ConfigureAwait(false);
return;
}

if (!allowed)
{
await ReplyAsync("Sorry, you are not permitted to use this command!").ConfigureAwait(false);
Expand Down Expand Up @@ -122,4 +129,4 @@ private bool AddToTradeQueue(PK8 pk8, int code, string trainerName, bool sudo, P
return true;
}
}
}
}
16 changes: 15 additions & 1 deletion SysBot.Pokemon.Discord/Commands/TradeModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ public async Task TradeAsync([Summary("Trade Code")]int code, [Remainder][Summar
var cfg = Info.Hub.Config;
var sudo = Context.GetIsSudo(cfg);
var allowed = sudo || (Context.GetHasRole(cfg.DiscordRoleCanTrade) && Info.CanQueue);

if (!sudo && !Info.CanQueue)
{
await ReplyAsync("Sorry, I am not currently accepting queue requests!").ConfigureAwait(false);
return;
}

if (!allowed)
{
await ReplyAsync("Sorry, you are not permitted to use this command!").ConfigureAwait(false);
Expand Down Expand Up @@ -80,6 +87,13 @@ public async Task TradeAsync([Summary("Showdown Set")][Remainder]string content)
var cfg = Info.Hub.Config;
var sudo = Context.GetIsSudo(cfg);
var allowed = sudo || (Context.GetHasRole(cfg.DiscordRoleCanTrade) && Info.CanQueue);

if (!sudo && !Info.CanQueue)
{
await ReplyAsync("Sorry, I am not currently accepting queue requests!").ConfigureAwait(false);
return;
}

if (!allowed)
{
await ReplyAsync("Sorry, you are not permitted to use this command!").ConfigureAwait(false);
Expand Down Expand Up @@ -157,4 +171,4 @@ private bool AddToTradeQueue(PK8 pk8, int code, string trainerName, bool sudo, P
return true;
}
}
}
}
2 changes: 1 addition & 1 deletion SysBot.Pokemon.Discord/Helpers/DiscordTradeNotifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void TradeInitialize(PokeRoutineExecutor routine, PokeTradeDetail<T> info
public void TradeSearching(PokeRoutineExecutor routine, PokeTradeDetail<T> info)
{
var name = Info.TrainerName;
var trainer = string.IsNullOrEmpty(name) ? string.Empty : $", ({name})";
var trainer = string.IsNullOrEmpty(name) ? string.Empty : $", {name}";
Context.User.SendMessageAsync($"I'm searching for you{trainer}! Your code is {Code:0000}.").ConfigureAwait(false);
}

Expand Down
2 changes: 1 addition & 1 deletion SysBot.Pokemon.Twitch/Helpers/TwitchTradeNotifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public void TradeInitialize(PokeRoutineExecutor routine, PokeTradeDetail<T> info
public void TradeSearching(PokeRoutineExecutor routine, PokeTradeDetail<T> info)
{
var name = Info.TrainerName;
var trainer = string.IsNullOrEmpty(name) ? string.Empty : $", ({name})";
var trainer = string.IsNullOrEmpty(name) ? string.Empty : $", {name}";
Client.SendWhisper(Username, $"I'm searching for you{trainer}! Use the code you whispered me to search!");
}
}
Expand Down
14 changes: 7 additions & 7 deletions SysBot.Pokemon/Actions/PokeRoutineExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ protected async Task EnterTradeCode(int code, CancellationToken token)
// Confirm Code outside of this method (allow synchronization)
}

public async Task EnsureConnectedToYCom(CancellationToken token)
public async Task EnsureConnectedToYComm(CancellationToken token)
{
if (!await IsGameConnectedToYCom(token).ConfigureAwait(false))
if (!await IsGameConnectedToYComm(token).ConfigureAwait(false))
{
Connection.Log("Reconnecting to Y-Com...");
await ReconnectToYCom(token).ConfigureAwait(false);
Connection.Log("Reconnecting to Y-Comm...");
await ReconnectToYComm(token).ConfigureAwait(false);
}
}

Expand All @@ -149,14 +149,14 @@ public async Task<string> GetTradePartnerName(TradeMethod tradeMethod, Cancellat
return StringConverter.GetString7(data, 0, 26);
}

public async Task<bool> IsGameConnectedToYCom(CancellationToken token)
public async Task<bool> IsGameConnectedToYComm(CancellationToken token)
{
// Reads the Y-Com Flag is the Game is connected Online
// Reads the Y-Comm Flag is the Game is connected Online
var data = await Connection.ReadBytesAsync(IsConnectedOffset, 1, token).ConfigureAwait(false);
return data[0] == 1;
}

public async Task ReconnectToYCom(CancellationToken token)
public async Task ReconnectToYComm(CancellationToken token)
{
// Press B in case a Error Message is Present
await Click(B, 2000, token).ConfigureAwait(false);
Expand Down
5 changes: 3 additions & 2 deletions SysBot.Pokemon/BotTrade/PokeTradeBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private async Task DoTrades(SAV8SWSH sav, CancellationToken token)

waitCounter = 0;
Connection.Log($"Starting next {type} Bot Trade. Getting data...");
await EnsureConnectedToYCom(token).ConfigureAwait(false);
await EnsureConnectedToYComm(token).ConfigureAwait(false);
var result = await PerformLinkCodeTrade(sav, detail, token).ConfigureAwait(false);
if (result != PokeTradeResult.Success) // requeue
{
Expand All @@ -118,7 +118,7 @@ private async Task DoSurpriseTrades(SAV8SWSH sav, CancellationToken token)
while (!token.IsCancellationRequested && Config.NextRoutineType == PokeRoutineType.SurpriseTrade)
{
var pkm = Hub.Ledy.Pool.GetRandomSurprise();
await EnsureConnectedToYCom(token).ConfigureAwait(false);
await EnsureConnectedToYComm(token).ConfigureAwait(false);
var _ = await PerformSurpriseTrade(sav, pkm, token).ConfigureAwait(false);
}
}
Expand Down Expand Up @@ -477,6 +477,7 @@ private void ReplyWithZ3Results(PokeTradeDetail<PK8> detail, PK8 result)
var msg = match.ToString();
detail.SendNotification(this, msg);
}
Connection.Log("Seed calculation completed.");
}

private void WaitAtBarrierIfApplicable(CancellationToken token)
Expand Down