ChatWars Telegram helper bot
This project demonstrates usage of cw-rest-api NPM package.
git clone [email protected]:alevinru/CWClientHelperAppBot.git
cd CWClientHelperAppBot
npm install
Bot needs a connection to a https://redis.io database to store authorization data. So you maybe need to build and run your own Redis instance.
By default bot connects to local Redis at default port. You could specify this behaviour with environment variables:
REDIS_HOST
, REDIS_PORT
, REDIS_DB
export CW_BOT_ID=ChatWars_Bot_ID
export BOT_TOKEN=Your_Telegram_Bot_Token
Also you need to export ChatWars API credentials as described in alevinru/CWClient setup section.
npm run start
Commands and other chat hooks are exported from src/middleware
Does async request to cwApi.sendAuth(userId)
then responds with success or error message to the chat.
User should forward the entire message with confirmation code.
The bot parses the forward and requests cwApi.sendGrantToken(userId, code)
to complete the authorization process.
Does async request to cwApi.requestProfile(userId, token)
then responds with raw json data.
Does async request to cwApi.requestStock(userId, token)
then responds with raw json data.
Alternate syntax is /wtb_itemCode_quantity_price
Moreover, any underscore in the command text may be replaced with space.
Command does cwApi.wantToBuy(userId, { itemCode, quantity, price }, token)
Bot responds with process.env.PHRASE_NOT_IMPLEMENTED to any unknown message.
Bot has trading-specific functionality descibed in src/commands.js