Added more item details in getitem
This commit is contained in:
parent
cd006fb268
commit
612435eb09
@ -78,7 +78,7 @@ public class ConnectedComputer : CommandRouter, ITaskWaitSource {
|
|||||||
public override Task<ResponseType> RootAnswer(SocketUserMessage message, CancellationToken ct)
|
public override Task<ResponseType> RootAnswer(SocketUserMessage message, CancellationToken ct)
|
||||||
=> Task.FromResult(ResponseType.AsString("The Minecraft server is connected!"));
|
=> Task.FromResult(ResponseType.AsString("The Minecraft server is connected!"));
|
||||||
public override Task<ResponseType> FallbackHandler(SocketUserMessage message, string method, string[] parameters, CancellationToken ct)
|
public override Task<ResponseType> FallbackHandler(SocketUserMessage message, string method, string[] parameters, CancellationToken ct)
|
||||||
=> Task.FromResult(ResponseType.AsString($"What the fuck do you mean by '{method}'?"));
|
=> throw new ReplyException($"What the fuck do you mean by '{method}'?");
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ITaskWaitSource {
|
public interface ITaskWaitSource {
|
||||||
@ -118,6 +118,8 @@ public class Fluid {
|
|||||||
public override string ToString() => Amount > 10000
|
public override string ToString() => Amount > 10000
|
||||||
? $"{Amount / 1000.0f:n2} B of {DisplayName}"
|
? $"{Amount / 1000.0f:n2} B of {DisplayName}"
|
||||||
: $"{Amount:n0} mB of {DisplayName}";
|
: $"{Amount:n0} mB of {DisplayName}";
|
||||||
|
[JsonIgnore]
|
||||||
|
public string CleanDisplayName => DisplayName[1..^2];
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonConverter(typeof(ModItemIdJsonConverter))]
|
[JsonConverter(typeof(ModItemIdJsonConverter))]
|
||||||
|
@ -228,8 +228,8 @@ public class Program : IDisposable, ICommandHandler<ResponseType> {
|
|||||||
} catch (TaskCanceledException) {
|
} catch (TaskCanceledException) {
|
||||||
return ResponseType.AsString("Your request could not be processed in time!");
|
return ResponseType.AsString("Your request could not be processed in time!");
|
||||||
} catch (ReplyException e) {
|
} catch (ReplyException e) {
|
||||||
await LogWarningAsync(BotSource, e.Message);
|
await LogInfoAsync(BotSource, e.Message);
|
||||||
return ResponseType.AsString($"Your request failed: {e.Message}");
|
return ResponseType.AsString(e.Message);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
await LogErrorAsync(BotSource, e);
|
await LogErrorAsync(BotSource, e);
|
||||||
return ResponseType.AsString($"Oopsie doopsie, this should not have happened!");
|
return ResponseType.AsString($"Oopsie doopsie, this should not have happened!");
|
||||||
|
@ -8,7 +8,7 @@ public class RefinedStorageService : CommandRouter {
|
|||||||
public override string HelpTextPrefix => "!rs ";
|
public override string HelpTextPrefix => "!rs ";
|
||||||
public RefinedStorageService(ITaskWaitSource taskSource) : base() => _taskSource = taskSource;
|
public RefinedStorageService(ITaskWaitSource taskSource) : base() => _taskSource = taskSource;
|
||||||
public override Task<ResponseType> FallbackHandler(SocketUserMessage message, string method, string[] parameters, CancellationToken ct)
|
public override Task<ResponseType> FallbackHandler(SocketUserMessage message, string method, string[] parameters, CancellationToken ct)
|
||||||
=> Task.FromResult(ResponseType.AsString($"The RS system has no command '{method}'!"));
|
=> throw new ReplyException($"The RS system has no command '{method}'!");
|
||||||
public override Task<ResponseType> RootAnswer(SocketUserMessage message, CancellationToken ct)
|
public override Task<ResponseType> RootAnswer(SocketUserMessage message, CancellationToken ct)
|
||||||
=> Task.FromResult(ResponseType.AsString("The RS system is online!"));
|
=> Task.FromResult(ResponseType.AsString("The RS system is online!"));
|
||||||
|
|
||||||
@ -73,12 +73,13 @@ public class RefinedStorageService : CommandRouter {
|
|||||||
if (parameters.Length is 1 or 2) {
|
if (parameters.Length is 1 or 2) {
|
||||||
itemid = parameters[0];
|
itemid = parameters[0];
|
||||||
if (parameters.Length is 2)
|
if (parameters.Length is 2)
|
||||||
if (int.TryParse(parameters[1], out var value)) amount = value;
|
amount = int.TryParse(parameters[1], out var value)
|
||||||
else return ResponseType.AsString($"I expected an amount to craft, not '{parameters[1]}'!");
|
? value
|
||||||
|
: throw new ReplyException($"I expected an amount to craft, not '{parameters[1]}'!");
|
||||||
} else return parameters.Length is < 1
|
} else return parameters.Length is < 1
|
||||||
? ResponseType.AsString("You have to give me at least an item name!")
|
? throw new ReplyException("You have to give me at least an item name!")
|
||||||
: parameters.Length is > 2
|
: parameters.Length is > 2
|
||||||
? ResponseType.AsString("Yo, those are way too many arguments! I want only item name and maybe an amount!")
|
? throw new ReplyException("Yo, those are way too many arguments! I want only item name and maybe an amount!")
|
||||||
: throw new InvalidOperationException($"Forgot to match parameter length {parameters.Length}!");
|
: throw new InvalidOperationException($"Forgot to match parameter length {parameters.Length}!");
|
||||||
return await CraftItem(itemid, amount, ct)
|
return await CraftItem(itemid, amount, ct)
|
||||||
? ResponseType.AsString($"Alright, I'm starting to craft {amount} {itemid}.")
|
? ResponseType.AsString($"Alright, I'm starting to craft {amount} {itemid}.")
|
||||||
@ -98,8 +99,15 @@ public class RefinedStorageService : CommandRouter {
|
|||||||
: parameters.Length is > 2
|
: parameters.Length is > 2
|
||||||
? ResponseType.AsString("Yo, those are way too many arguments! I want only item name and maybe an amount!")
|
? ResponseType.AsString("Yo, those are way too many arguments! I want only item name and maybe an amount!")
|
||||||
: throw new InvalidOperationException($"Forgot to match parameter length {parameters.Length}!");
|
: throw new InvalidOperationException($"Forgot to match parameter length {parameters.Length}!");
|
||||||
var data = await GetItemData(itemid, ct);
|
var item = await GetItemData(itemid, ct);
|
||||||
return ResponseType.AsString(data.ToString());
|
var sb = new StringBuilder();
|
||||||
|
sb.Append($"We currently have {item.Amount:n0} {item.CleanDisplayName}!");
|
||||||
|
if (item.Tags is not null and var tags) {
|
||||||
|
sb.AppendLine("\nThis item has the following tags:");
|
||||||
|
sb.AppendJoin('\n',tags.Select(tag => $"- {tag}"));
|
||||||
|
}
|
||||||
|
sb.Append($"\nRefer to this item with fingerprint {item.Fingerprint}");
|
||||||
|
return ResponseType.AsString(sb.ToString());
|
||||||
}
|
}
|
||||||
[CommandHandler(CmdItemName, HelpText = "Filter items by name.")]
|
[CommandHandler(CmdItemName, HelpText = "Filter items by name.")]
|
||||||
public async Task<ResponseType> HandleItemName(SocketUserMessage message, string[] parameters, CancellationToken ct) {
|
public async Task<ResponseType> HandleItemName(SocketUserMessage message, string[] parameters, CancellationToken ct) {
|
||||||
|
Loading…
Reference in New Issue
Block a user