diff --git a/src/api/commands/groups/fishing/nearby.ts b/src/api/commands/groups/fishing/nearby.ts index 2f2ffe4..f0a5cb1 100644 --- a/src/api/commands/groups/fishing/nearby.ts +++ b/src/api/commands/groups/fishing/nearby.ts @@ -16,7 +16,7 @@ export const nearby = new Command( let loc = locations.find(loc => loc.id == inventory.location); if (!loc) loc = locations[0]; - logger.debug(loc.nearby); + // logger.debug(loc.nearby); const nearbyList: string[] = []; diff --git a/src/api/fish/fishers.ts b/src/api/fish/fishers.ts index b61b0b6..92238f6 100644 --- a/src/api/fish/fishers.ts +++ b/src/api/fish/fishers.ts @@ -43,7 +43,12 @@ export async function tick() { const r = Math.random(); if (r < 0.1) { - stopFishing(winner.id, winner.userID, winner.autofish); + stopFishing( + winner.id, + winner.userID, + winner.autofish, + winner.autofish_t + ); const animal = randomFish(inventory.location); addItem(inventory.fishSack as TFishSack, animal); await updateInventory(inventory); @@ -91,28 +96,42 @@ export function startFishing( id: string, userId: string, isDM: boolean = false, - autofish: boolean = false + autofish: boolean = false, + autofish_t: number = Date.now() ) { fishers[id + "~" + userId] = { id, userID: userId, t: Date.now(), isDM, - autofish + autofish, + autofish_t }; } export function stopFishing( id: string, userId: string, - autofish: boolean = false + autofish: boolean = false, + autofish_t: number = Date.now() ) { let key = id + "~" + userId; let fisher = fishers[key]; delete fishers[key]; + const t = Date.now(); + if (t > autofish_t + 5 * 60000) { + addBack(fisher.id, { + m: "sendchat", + message: `Friend @${fisher.userID}'s AUTOFISH has sibsided after 5.0 minutes.`, + isDM: fisher.isDM, + id: fisher.userID + }); + return; + } + if (autofish) { - startFishing(id, userId, true, true); + startFishing(id, userId, true, true, autofish_t); } } diff --git a/src/mpp/bot/Bot.ts b/src/mpp/bot/Bot.ts index 3d93735..9092921 100644 --- a/src/mpp/bot/Bot.ts +++ b/src/mpp/bot/Bot.ts @@ -192,20 +192,25 @@ export class MPPNetBot { let lines = text.split("\n"); for (const line of lines) { - if (line.length <= 510) { - (this.client as any).sendArray([ - { - m: "a", - message: `\u034f${line - .split("\t") - .join("") - .split("\r") - .join("")}`, - reply_to: reply - } - ]); - } else { - this.sendChat(line); + const splits = line.match(/.{510}|.{1,509}/gi); + if (!splits) continue; + + for (const split of splits) { + if (split.length <= 510) { + (this.client as any).sendArray([ + { + m: "a", + message: `\u034f${split + .split("\t") + .join("") + .split("\r") + .join("")}`, + reply_to: reply + } + ]); + } else { + this.sendChat(split); + } } } } diff --git a/src/util/types.d.ts b/src/util/types.d.ts index 6ddd3ec..d1109d0 100644 --- a/src/util/types.d.ts +++ b/src/util/types.d.ts @@ -107,6 +107,7 @@ interface TFisher { t: number; isDM: boolean; autofish: boolean; + autofish_t: number; } type TPokedex = IPokemon[];