Fix long messages and stop autofishing after five minutes
This commit is contained in:
parent
98a1f70307
commit
4073a87f4e
|
@ -16,7 +16,7 @@ export const nearby = new Command(
|
||||||
let loc = locations.find(loc => loc.id == inventory.location);
|
let loc = locations.find(loc => loc.id == inventory.location);
|
||||||
if (!loc) loc = locations[0];
|
if (!loc) loc = locations[0];
|
||||||
|
|
||||||
logger.debug(loc.nearby);
|
// logger.debug(loc.nearby);
|
||||||
|
|
||||||
const nearbyList: string[] = [];
|
const nearbyList: string[] = [];
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,12 @@ export async function tick() {
|
||||||
const r = Math.random();
|
const r = Math.random();
|
||||||
|
|
||||||
if (r < 0.1) {
|
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);
|
const animal = randomFish(inventory.location);
|
||||||
addItem(inventory.fishSack as TFishSack, animal);
|
addItem(inventory.fishSack as TFishSack, animal);
|
||||||
await updateInventory(inventory);
|
await updateInventory(inventory);
|
||||||
|
@ -91,28 +96,42 @@ export function startFishing(
|
||||||
id: string,
|
id: string,
|
||||||
userId: string,
|
userId: string,
|
||||||
isDM: boolean = false,
|
isDM: boolean = false,
|
||||||
autofish: boolean = false
|
autofish: boolean = false,
|
||||||
|
autofish_t: number = Date.now()
|
||||||
) {
|
) {
|
||||||
fishers[id + "~" + userId] = {
|
fishers[id + "~" + userId] = {
|
||||||
id,
|
id,
|
||||||
userID: userId,
|
userID: userId,
|
||||||
t: Date.now(),
|
t: Date.now(),
|
||||||
isDM,
|
isDM,
|
||||||
autofish
|
autofish,
|
||||||
|
autofish_t
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stopFishing(
|
export function stopFishing(
|
||||||
id: string,
|
id: string,
|
||||||
userId: string,
|
userId: string,
|
||||||
autofish: boolean = false
|
autofish: boolean = false,
|
||||||
|
autofish_t: number = Date.now()
|
||||||
) {
|
) {
|
||||||
let key = id + "~" + userId;
|
let key = id + "~" + userId;
|
||||||
let fisher = fishers[key];
|
let fisher = fishers[key];
|
||||||
delete 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) {
|
if (autofish) {
|
||||||
startFishing(id, userId, true, true);
|
startFishing(id, userId, true, true, autofish_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,20 +192,25 @@ export class MPPNetBot {
|
||||||
let lines = text.split("\n");
|
let lines = text.split("\n");
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
if (line.length <= 510) {
|
const splits = line.match(/.{510}|.{1,509}/gi);
|
||||||
(this.client as any).sendArray([
|
if (!splits) continue;
|
||||||
{
|
|
||||||
m: "a",
|
for (const split of splits) {
|
||||||
message: `\u034f${line
|
if (split.length <= 510) {
|
||||||
.split("\t")
|
(this.client as any).sendArray([
|
||||||
.join("")
|
{
|
||||||
.split("\r")
|
m: "a",
|
||||||
.join("")}`,
|
message: `\u034f${split
|
||||||
reply_to: reply
|
.split("\t")
|
||||||
}
|
.join("")
|
||||||
]);
|
.split("\r")
|
||||||
} else {
|
.join("")}`,
|
||||||
this.sendChat(line);
|
reply_to: reply
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
|
this.sendChat(split);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,7 @@ interface TFisher {
|
||||||
t: number;
|
t: number;
|
||||||
isDM: boolean;
|
isDM: boolean;
|
||||||
autofish: boolean;
|
autofish: boolean;
|
||||||
|
autofish_t: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
type TPokedex = IPokemon[];
|
type TPokedex = IPokemon[];
|
||||||
|
|
Loading…
Reference in New Issue