mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
5.1 fixed, minimal chat mode
This commit is contained in:
parent
ba5fa1f4d0
commit
b857506fd6
8 changed files with 90 additions and 61 deletions
|
|
@ -14,10 +14,10 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Label="Feature">
|
<PropertyGroup Label="Feature">
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<AssemblyVersion>2.9.0.0</AssemblyVersion>
|
<AssemblyVersion>3.1.0.0</AssemblyVersion>
|
||||||
<FileVersion>2.9.0.0</FileVersion>
|
<FileVersion>3.1.0.0</FileVersion>
|
||||||
<Description>XIVLauncher addon injection</Description>
|
<Description>XIVLauncher addon injection</Description>
|
||||||
<Version>2.9.0</Version>
|
<Version>3.1.0</Version>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="EasyHook" Version="2.7.6270" />
|
<PackageReference Include="EasyHook" Version="2.7.6270" />
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Label="Feature">
|
<PropertyGroup Label="Feature">
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<AssemblyVersion>2.7.0.0</AssemblyVersion>
|
<AssemblyVersion>2.9.0.0</AssemblyVersion>
|
||||||
<Version>2.7.0</Version>
|
<Version>2.9.0</Version>
|
||||||
<FileVersion>2.7.0.0</FileVersion>
|
<FileVersion>2.9.0.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup Label="Resources">
|
<ItemGroup Label="Resources">
|
||||||
<None Include="$(SolutionDir)/Resources/**/*" CopyToOutputDirectory="PreserveNewest" Visible="false" />
|
<None Include="$(SolutionDir)/Resources/**/*" CopyToOutputDirectory="PreserveNewest" Visible="false" />
|
||||||
|
|
|
||||||
|
|
@ -260,62 +260,88 @@ namespace Dalamud.DiscordBot {
|
||||||
var avatarUrl = "";
|
var avatarUrl = "";
|
||||||
var lodestoneId = 0;
|
var lodestoneId = 0;
|
||||||
|
|
||||||
try {
|
if (!this.config.DisableEmbeds) {
|
||||||
dynamic charCandidates = await XivApi.GetCharacterSearch(sender, world);
|
try
|
||||||
|
{
|
||||||
|
dynamic charCandidates = await XivApi.GetCharacterSearch(sender, world);
|
||||||
|
|
||||||
if (charCandidates.Results.Count > 0) {
|
if (charCandidates.Results.Count > 0)
|
||||||
avatarUrl = charCandidates.Results[0].Avatar;
|
{
|
||||||
lodestoneId = charCandidates.Results[0].ID;
|
avatarUrl = charCandidates.Results[0].Avatar;
|
||||||
|
lodestoneId = charCandidates.Results[0].ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Log.Error(ex, "Could not get XIVAPI character search result.");
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
|
||||||
Log.Error(ex, "Could not get XIVAPI character search result.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread.Sleep(this.config.ChatDelayMs);
|
Thread.Sleep(this.config.ChatDelayMs);
|
||||||
|
|
||||||
|
var name = wasOutgoingTell
|
||||||
|
? "You"
|
||||||
|
: sender + (string.IsNullOrEmpty(world) || string.IsNullOrEmpty(sender)
|
||||||
|
? ""
|
||||||
|
: $" on {world}");
|
||||||
|
|
||||||
for (var chatTypeIndex = 0; chatTypeIndex < chatTypeConfigs.Count(); chatTypeIndex++) {
|
for (var chatTypeIndex = 0; chatTypeIndex < chatTypeConfigs.Count(); chatTypeIndex++) {
|
||||||
var embedBuilder = new EmbedBuilder
|
if (!this.config.DisableEmbeds) {
|
||||||
{
|
var embedBuilder = new EmbedBuilder
|
||||||
Author = new EmbedAuthorBuilder
|
|
||||||
{
|
{
|
||||||
IconUrl = avatarUrl,
|
Author = new EmbedAuthorBuilder
|
||||||
Name = wasOutgoingTell
|
{
|
||||||
? "You"
|
IconUrl = avatarUrl,
|
||||||
: sender + (string.IsNullOrEmpty(world) || string.IsNullOrEmpty(sender)
|
Name = name,
|
||||||
? ""
|
Url = lodestoneId != 0 ? "https://eu.finalfantasyxiv.com/lodestone/character/" + lodestoneId : null
|
||||||
: $" on {world}"),
|
},
|
||||||
Url = lodestoneId != 0 ? "https://eu.finalfantasyxiv.com/lodestone/character/" + lodestoneId : null
|
Description = message,
|
||||||
},
|
Timestamp = DateTimeOffset.Now,
|
||||||
Description = message,
|
Footer = new EmbedFooterBuilder { Text = type.GetDetails().FancyName },
|
||||||
Timestamp = DateTimeOffset.Now,
|
Color = new Color((uint)(chatTypeConfigs.ElementAt(chatTypeIndex).Color & 0xFFFFFF))
|
||||||
Footer = new EmbedFooterBuilder { Text = type.GetDetails().FancyName },
|
};
|
||||||
Color = new Color((uint)(chatTypeConfigs.ElementAt(chatTypeIndex).Color & 0xFFFFFF))
|
|
||||||
};
|
|
||||||
|
|
||||||
if (this.config.CheckForDuplicateMessages)
|
if (this.config.CheckForDuplicateMessages)
|
||||||
{
|
|
||||||
var recentMsg = this.recentMessages.FirstOrDefault(
|
|
||||||
msg => msg.Embeds.FirstOrDefault(
|
|
||||||
embed => embed.Description == embedBuilder.Description &&
|
|
||||||
embed.Author.HasValue &&
|
|
||||||
embed.Author.Value.Name == embedBuilder.Author.Name &&
|
|
||||||
embed.Timestamp.HasValue &&
|
|
||||||
Math.Abs(
|
|
||||||
(embed.Timestamp.Value.ToUniversalTime().Date -
|
|
||||||
embedBuilder
|
|
||||||
.Timestamp.Value.ToUniversalTime().Date)
|
|
||||||
.Milliseconds) < 15000)
|
|
||||||
!= null);
|
|
||||||
|
|
||||||
if (recentMsg != null)
|
|
||||||
{
|
{
|
||||||
Log.Verbose("Duplicate message: [{0}] {1}", embedBuilder.Author.Name, embedBuilder.Description);
|
var recentMsg = this.recentMessages.FirstOrDefault(
|
||||||
this.recentMessages.Remove(recentMsg);
|
msg => msg.Embeds.FirstOrDefault(
|
||||||
return;
|
embed => embed.Description == embedBuilder.Description &&
|
||||||
|
embed.Author.HasValue &&
|
||||||
|
embed.Author.Value.Name == embedBuilder.Author.Name &&
|
||||||
|
embed.Timestamp.HasValue &&
|
||||||
|
Math.Abs(
|
||||||
|
(embed.Timestamp.Value.ToUniversalTime().Date -
|
||||||
|
embedBuilder
|
||||||
|
.Timestamp.Value.ToUniversalTime().Date)
|
||||||
|
.Milliseconds) < 15000)
|
||||||
|
!= null);
|
||||||
|
|
||||||
|
if (recentMsg != null)
|
||||||
|
{
|
||||||
|
Log.Verbose("Duplicate message: [{0}] {1}", embedBuilder.Author.Name, embedBuilder.Description);
|
||||||
|
this.recentMessages.Remove(recentMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
await channels.ElementAt(chatTypeIndex).SendMessageAsync(embed: embedBuilder.Build());
|
await channels.ElementAt(chatTypeIndex).SendMessageAsync(embed: embedBuilder.Build());
|
||||||
|
} else {
|
||||||
|
var simpleMessage = $"{name}: {message}";
|
||||||
|
|
||||||
|
if (this.config.CheckForDuplicateMessages) {
|
||||||
|
var recentMsg = this.recentMessages.FirstOrDefault(
|
||||||
|
msg => msg.Content == simpleMessage);
|
||||||
|
|
||||||
|
if (recentMsg != null)
|
||||||
|
{
|
||||||
|
Log.Verbose("Duplicate message: {0}", simpleMessage);
|
||||||
|
this.recentMessages.Remove(recentMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await channels.ElementAt(chatTypeIndex).SendMessageAsync($"{name}: {message}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,14 @@ namespace Dalamud.DiscordBot
|
||||||
public class DiscordFeatureConfiguration
|
public class DiscordFeatureConfiguration
|
||||||
{
|
{
|
||||||
public string Token { get; set; }
|
public string Token { get; set; }
|
||||||
public ulong OwnerUserId { get; set; }
|
|
||||||
|
|
||||||
public bool CheckForDuplicateMessages { get; set; }
|
public bool CheckForDuplicateMessages { get; set; }
|
||||||
public int ChatDelayMs { get; set; }
|
public int ChatDelayMs { get; set; }
|
||||||
|
|
||||||
|
public bool DisableEmbeds { get; set; }
|
||||||
|
|
||||||
|
public ulong OwnerUserId { get; set; }
|
||||||
|
|
||||||
public List<ChatTypeConfiguration> ChatTypeConfigurations { get; set; }
|
public List<ChatTypeConfiguration> ChatTypeConfigurations { get; set; }
|
||||||
|
|
||||||
public ChannelConfiguration CfNotificationChannel { get; set; }
|
public ChannelConfiguration CfNotificationChannel { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ namespace Dalamud.Game.ClientState
|
||||||
public IntPtr JobGaugeData { get; set; }
|
public IntPtr JobGaugeData { get; set; }
|
||||||
|
|
||||||
protected override void Setup64Bit(SigScanner sig) {
|
protected override void Setup64Bit(SigScanner sig) {
|
||||||
ActorTable = sig.Module.BaseAddress + 0x1C01D90;
|
ActorTable = sig.Module.BaseAddress + 0x1BFBA38;
|
||||||
LocalContentId = sig.Module.BaseAddress + 0x1C2E000;
|
LocalContentId = sig.Module.BaseAddress + 0x1C2E000;
|
||||||
JobGaugeData = sig.Module.BaseAddress + 0x1BFD110;
|
JobGaugeData = sig.Module.BaseAddress + 0x1BFD110;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,8 @@ namespace Dalamud.Game.Internal.Gui {
|
||||||
|
|
||||||
//PopulateItemLinkObject = sig.ScanText("48 89 5C 24 08 57 48 83 EC 20 80 7A 06 00 48 8B DA 48 8B F9 74 14 48 8B CA E8 32 03 00 00 48 8B C8 E8 FA F2 B0 FF 8B C8 EB 1D 0F B6 42 14 8B 4A");
|
//PopulateItemLinkObject = sig.ScanText("48 89 5C 24 08 57 48 83 EC 20 80 7A 06 00 48 8B DA 48 8B F9 74 14 48 8B CA E8 32 03 00 00 48 8B C8 E8 FA F2 B0 FF 8B C8 EB 1D 0F B6 42 14 8B 4A");
|
||||||
|
|
||||||
//PopulateItemLinkObject = sig.ScanText("48 89 5C 24 08 57 48 83 EC 20 80 7A 06 00 48 8B DA 48 8B F9 74 14 48 8B CA E8 32 03 00 00 48 8B C8 E8 ?? ?? B0 FF 8B C8 EB 1D 0F B6 42 14 8B 4A"); 5.0
|
//PopulateItemLinkObject = sig.ScanText( "48 89 5C 24 08 57 48 83 EC 20 80 7A 06 00 48 8B DA 48 8B F9 74 14 48 8B CA E8 32 03 00 00 48 8B C8 E8 ?? ?? B0 FF 8B C8 EB 1D 0F B6 42 14 8B 4A"); 5.0
|
||||||
PopulateItemLinkObject = sig.ScanText("48 89 5C 24 08 57 48 83 EC 20 80 7A 06 00 48 8B DA 48 8B F9 74 14 48 8B CA E8 32 03 00 00 48 8B C8 E8 7A 12 AF FF 8B C8 EB 1D 0F B6 42 14 8B 4A");
|
PopulateItemLinkObject = sig.ScanText("48 89 5C 24 08 57 48 83 EC 20 80 7A 06 00 48 8B DA 48 8B F9 74 14 48 8B CA E8 32 03 00 00 48 8B C8 E8 ?? ?? ?? FF 8B C8 EB 1D 0F B6 42 14 8B 4A");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@ namespace Dalamud.Game.Internal.Network {
|
||||||
|
|
||||||
private void InjectActorControl(short cat, int param1) {
|
private void InjectActorControl(short cat, int param1) {
|
||||||
var packetData = new byte[] {
|
var packetData = new byte[] {
|
||||||
0x14, 0x00, 0x64, 0x01, 0x00, 0x00, 0x0E, 0x00, 0x17, 0x7C, 0xC5, 0x5D, 0x00, 0x00, 0x00, 0x00,
|
0x14, 0x00, 0x8D, 0x00, 0x00, 0x00, 0x0E, 0x00, 0x17, 0x7C, 0xC5, 0x5D, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x05, 0x00, 0x48, 0xB2, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x05, 0x00, 0x48, 0xB2, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x43, 0x7F, 0x00, 0x00
|
0x00, 0x00, 0x00, 0x00, 0x43, 0x7F, 0x00, 0x00
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ namespace Dalamud.Game.Network {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (opCode == ZoneOpCode.CfNotifyRoulette) {
|
if (opCode == ZoneOpCode.CfNotifyPop) {
|
||||||
var data = new byte[64];
|
var data = new byte[64];
|
||||||
Marshal.Copy(dataPtr, data, 0, 64);
|
Marshal.Copy(dataPtr, data, 0, 64);
|
||||||
|
|
||||||
|
|
@ -197,15 +197,15 @@ namespace Dalamud.Game.Network {
|
||||||
}
|
}
|
||||||
|
|
||||||
private enum ZoneOpCode {
|
private enum ZoneOpCode {
|
||||||
CfNotifyRoulette = 0xB3,
|
CfNotifyPop = 0x32D,
|
||||||
CfNotify = 0x8F,
|
CfNotify = 0x8F,
|
||||||
RetainerSaleItemId = 0x13F, // TODO these are probably not accurate
|
RetainerSaleItemId = 0x13F, // TODO these are probably not accurate
|
||||||
RetainerSaleFinish = 0x138,
|
RetainerSaleFinish = 0x138,
|
||||||
FateSpawn = 0x226,
|
FateSpawn = 0x226,
|
||||||
MarketTaxRates = 0x76,
|
MarketTaxRates = 0x39F,
|
||||||
MarketBoardItemRequestStart = 0x39D,
|
MarketBoardItemRequestStart = 0xF2,
|
||||||
MarketBoardOfferings = 0x36A,
|
MarketBoardOfferings = 0x1E2,
|
||||||
MarketBoardHistory = 0x194
|
MarketBoardHistory = 0x123
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue