Skip to content

Utils

Scaffolds provide utility functions that can be used to perform common tasks when programming a bot.

update_is_for_me

python
def update_is_for_me(update: RelevantGameUpdate, my_id: PlayerID, my_small_id: PlayerSmallID) -> bool
java
public static boolean updateIsForMe(
    @NotNull Object update,
    @NotNull String myId,
    @NotNull int mySmallId
)

Determines whether a given RelevantGameUpdate is relevant to your bot using your bot's PlayerID and PlayerSmallID.

Updates that originate from your bot (e.g. alliance requests sent by your bot, messages sent by your bot) are not considered relevant.

The function considers an update to be relevant if:

  • It is an AllianceRequestUpdate where the recipient is your bot (someone asked you for an alliance).
  • It is an AllianceRequestReplyUpdate where the requester is your bot (you asked someone for an alliance and they replied).
  • It is a BrokeAllianceUpdate and your bot was the one betrayed (someone broke their alliance with you).
  • It is an AllianceExpiredUpdate and your bot was one of the parties in the expired alliance (an alliance you were in has expired).
  • It is an EmojiUpdate and the recipient is either your bot (someone sent you an emoji) or everyone (someone sent an emoji to everyone, including you).
  • It is a DisplayChatMessageUpdate and the recipient is your bot (someone sent you a chat message).