Skip to content

Latest commit

 

History

History
5 lines (3 loc) · 860 Bytes

Chat.md

File metadata and controls

5 lines (3 loc) · 860 Bytes

Chat

A bot may want to hook into chat for a number of reasons (e.g. as a command interface, or performing mischief). A common pitfall when making a bot which automatically responds to messages in a chat room is that it will try to respond to itself, getting into an infinite loop and spamming chat. Funny the first time and then very unfunny after that.

To avoid this, it is necessary for the bot to know who it is. This is trivially done by providing it with its own username or (better) its id, but the cleanest method of doing this (especially if the bot is intended to be used by an arbitrary account) is to use its token to ask the TETR.IO API who it is. The appropriate API call in this case is to the users/me endpoint. It is sufficient to query this once and store the value, as the user's id will probably not change.