Skip to content

Commit

Permalink
fix: chat message detection
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele committed Jul 12, 2024
1 parent b4ef935 commit 2384b24
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ describe('7d2d event detection', () => {
});

it('[ChatMessage] Can detect chat message', async () => {
// Chat handled by mod 'CSMM Patrons': Chat (from 'Steam_76561198028175941', entity id '549', to 'Global'): 'Catalysm': /ping
// Chat handled by mod 'CSMM Patrons': Chat (from 'Steam_76561198028175941', entity id '549', to 'Global'): /ping
const emitter = new SevenDaysToDieEmitter(await mockConnectionInfo());

await emitter.parseMessage({
// eslint-disable-next-line quotes
msg: `Chat handled by mod 'CSMM Patrons': Chat (from 'Steam_76561198028175941', entity id '549', to 'Global'): 'Catalysm': fsafsafasf`,
msg: `Chat handled by mod 'CSMM Patrons': Chat (from 'Steam_76561198028175941', entity id '549', to 'Global'): fsafsafasf`,
});

expect(emitStub).to.have.been.calledTwice;
Expand Down Expand Up @@ -176,7 +176,7 @@ describe('7d2d event detection', () => {

await emitter.parseMessage({
// eslint-disable-next-line quotes
msg: `Chat handled by mod '1CSMM_Patrons': Chat (from 'Steam_76561198028175941', entity id '546', to 'Global'): 'Catalysm': &ping`,
msg: `Chat handled by mod '1CSMM_Patrons': Chat (from 'Steam_76561198028175941', entity id '546', to 'Global'): &ping`,
});

expect(emitStub).to.have.been.calledThrice;
Expand Down Expand Up @@ -204,10 +204,10 @@ describe('7d2d event detection', () => {
.map((message) => {
return [
{
msg: `Chat handled by mod 'ServerTools': Chat (from 'Steam_76561198028175941', entity id '2196446', to 'Global'): 'Catalysm': ${message}`,
msg: `Chat handled by mod 'ServerTools': Chat (from 'Steam_76561198028175941', entity id '2196446', to 'Global'): ${message}`,
},
{
msg: `Chat (from 'Steam_76561198028175941', entity id '-1', to 'Global'): 'Catalysm': ${message}`,
msg: `Chat (from 'Steam_76561198028175941', entity id '-1', to 'Global'): ${message}`,
},
];
})
Expand Down
2 changes: 1 addition & 1 deletion packages/lib-gameserver/src/gameservers/7d2d/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const EventRegexMap = {
/PlayerSpawnedInWorld \(reason: (JoinMultiplayer|EnterMultiplayer), position: [-\d]+, [-\d]+, [-\d]+\): EntityID=(?<entityId>[-\d]+), PltfmId='(Steam|XBL)_[\w\d]+', CrossId='EOS_[\w\d]+', OwnerID='(Steam|XBL)_\d+', PlayerName='(?<name>.+)'/,
[GameEvents.PLAYER_DISCONNECTED]: /(Player disconnected: )/,
[GameEvents.CHAT_MESSAGE]:
/Chat \(from '(?<platformId>[\w\d-]+)', entity id '(?<entityId>[-\d]+)', to '(?<channel>\w+)'\): '(?<name>.+)':(?<message>.+)/,
/Chat \(from '(?<platformId>[\w\d-]+)', entity id '(?<entityId>[-\d]+)', to '(?<channel>\w+)'\): (?<message>.+)/,
[GameEvents.PLAYER_DEATH]:
/GMSG: Player '(?<name1>.+)' died|\[CSMM_Patrons\]playerDied: (?<name2>.+) \((?<steamOrXboxId>.+)\) died @ (?<xCoord>[-\d]+) (?<yCoord>[-\d]+) (?<zCoord>[-\d]+)/,
[GameEvents.ENTITY_KILLED]:
Expand Down

0 comments on commit 2384b24

Please sign in to comment.