Aller au contenu
Afficher dans l'application

Une meilleure façon de naviguer. En savoir plus.

Asterobot

Une application plein écran sur votre écran d'accueil avec notifications push, badges et plus encore.

Pour installer cette application sur iOS et iPadOS
  1. Appuyez sur Icône de partage dans Safari
  2. Faites défiler le menu et appuyez sur Ajouter à l'écran d'accueil.
  3. Appuyez sur Ajouter dans le coin supérieur droit.
Pour installer cette application sur Android
  1. Appuyez sur le menu à trois points (⋮) dans le coin supérieur droit du navigateur.
  2. Appuyez sur Ajouter à l'écran d'accueil ou Installer l'application.
  3. Confirmez en appuyant sur Installer.

Traffic

(0 notes)

Every message a script receives comes as a traffic object: in on() and onTraffic() handlers, from wait() and request(), and in interceptors.

What a traffic object looks like

A chat line on the general channel reaches a handler like this:

{
  sequence: 1842n,
  direction: "inbound",
  kind: "event",
  uid: -1,
  type: "ChatChannelMessageEvent",
  wireType: "abc", // an example: the real name is scrambled and changes between game versions
  typeUrl: "type.ankama.com/abc",
  unknown: false,
  payload: {
    channel: "GLOBAL",
    senderName: "Airelle",
    senderCharacterId: 123456789012n,
    content: "Anyone up for a dungeon?",
    // ...and the other fields of the message
  },
  rawAny: new Uint8Array([/* the bytes of the fields */]),
}

Properties

Property Value What it tells you
sequence BigInt The message's place in the bot's traffic. See Sequence numbers.
direction "inbound" or "outbound" "inbound" for a message travelling towards the client, "outbound" for one travelling towards the game server.
kind "event", "response", "request" or "unknown" Which kind of message it is. See Direction and kind.
uid number The number that pairs a response with its request. -1 for events and for requests that don't expect a response.
type string The readable name, such as ChatChannelMessageEvent. An empty string when Asterobot has no name for the message.
wireType string The scrambled name the message carries on the wire. It changes from one game version to the next.
typeUrl string The full type identifier on the wire: type.ankama.com/ followed by the scrambled name.
payload object, or absent The message's fields, when Asterobot could decode them. Payloads explains how each kind of field reads.
unknown boolean true when there's no payload.
decodeError string, or absent What went wrong while decoding the message. It can be present next to a payload.
rawAny Uint8Array The bytes of the message's fields, exactly as they arrived. Always present. It's empty when there were no bytes, as for a message without fields.

The editor marks every property as read-only. Changing one in a handler only changes what the next handlers see: One object for every handler explains why.

Direction and kind

Message direction kind uid
Something the server announces "inbound" "event" -1
The server's answer to a request that expects one "inbound" "response" The request's uid
A request sent with send(), from the Network tool, or by the Dofus client of a MITM bot "outbound" "request" -1
A request sent with request(), or one the Dofus client of a MITM bot expects an answer to "outbound" "request" 0 or more
A message sent to the client, by a script with { to: "client" } or with To the client in the Network tool "inbound" "event" -1

"unknown" exists in the typings, but Asterobot never delivers a message it couldn't classify, so scripts don't receive it. When a message is so damaged that Asterobot can't even tell its kind, a Full socket bot's game connection closes, and the script stops with an error that starts with Game session closed:. A MITM bot passes such a message on without delivering it to scripts.

On a Full socket bot, the game server isn't expected to send requests. If one arrives, it's still decoded, and its decodeError is unexpected inbound game envelope.

Messages Asterobot can't decode

When Asterobot can't decode a message, its traffic object has no payload, unknown is true, type is empty, and decodeError says why:

decodeError starts with Why
obfuscated protobuf wire name is not mapped: Asterobot has no readable name for this message. This is the common case: only part of the protocol has readable names so far.
unmarshal game Any The name is known, but the bytes don't match the message's definition.
invalid Ankama protobuf type URL: The message's type identifier isn't valid. wireType is empty too.
game envelope has no Any payload The message carried nothing at all. wireType and typeUrl are empty too.

With an empty type, a handler registered with a message name never receives these messages. To catch them, use the "*" selector, a function selector, or onTraffic(), and test traffic.unknown. Listening describes selectors.

What stays usable is wireType and rawAny. wireType tells two unknown messages apart, but only within one game version, and a message without a readable name can't be sent.

The bot's Network tool sometimes shows fields for such a message, with the Schema badge, because it also decodes messages under their scrambled names. Scripts don't get that: for a script the message stays unknown, with only its bytes. Finding messages explains the badges.

Raw bytes

rawAny holds the bytes of the message's fields before decoding, whether decoding worked or not. It's a copy, so changing it changes nothing. It doesn't include the part around the fields that states the message's kind and name, so it isn't something you could send back as it is. Asterobot has no function that decodes these bytes for you.

For an unknown message, the bytes are all there is. This script writes the start of each unknown message to the bot's console:

import { session, botDebug } from "asterobot:bot";
import { onTraffic, send } from "asterobot:protocol";

export default async function behavior(launch) {
  onTraffic((traffic) => {
    if (!traffic.unknown) return;

    // Sixteen bytes keep each console line readable.
    const start = Array.from(traffic.rawAny.slice(0, 16), (byte) => byte.toString(16).padStart(2, "0"));
    botDebug(`${traffic.direction} ${traffic.wireType}, ${traffic.rawAny.length} bytes: ${start.join(" ")}`);
  });

  // A new game connection starts with this message. MITM bots never launch
  // with "initial": the Dofus client has already identified their session.
  if (launch.reason === "initial") {
    await send("IdentificationRequest", {
      ticketKey: session.gameToken,
      languageCode: session.language,
    });
  }
}

Sequence numbers

sequence counts the messages of one game connection, both directions together, starting at 1n. A new game connection starts again from 1n.

The numbers a script sees aren't always consecutive or in order:

  • A message an interceptor drops keeps its number and never reaches handlers, which leaves a gap.
  • On a MITM bot, Asterobot skips messages for scripts when it can't keep up with the traffic, which also leaves gaps. Sessions explains when that happens.
  • A message a script sends from inside an interceptor goes out before the message being decided, and reaches handlers first, while carrying a higher number.

Handlers receive messages in the order they went through the bot. Use sequence as a label, not to sort messages.

On a MITM bot, the traffic object request() resolves with has sequence set to 0n. Handlers receive the same response with its real number.

One object for every handler

When several handlers and waits receive the same message, they all get the same object. A handler that changes traffic.payload changes what the handlers after it see, and nothing on the wire. To change a message on its way through the bot, use an interceptor, which receives its own copy: see Intercepting.

Next, Finding messages shows how to find the name and fields of the message you need. The asterobot:protocol reference lists every function that receives traffic.

Commentaires des utilisateurs

Aucun avis à afficher.

Compte

Navigation

Recherche

Recherche

Configurer les notifications push du navigateur

Chrome (Android)
  1. Appuyez sur l'icône de cadenas à côté de la barre d'adresse.
  2. Tap Autorisations → Notifications.
  3. Ajustez vos préférences.
Chrome (Desktop)
  1. Cliquez sur l'icône représentant un cadenas dans la barre d'adresse..
  2. Select Paramètres du site.
  3. Find Notifications et ajustez vos préférences.