A very basic translator bot built with Matrix Bot SDK that will translate everything you say into Chinese.
Useful for bilingual communications.
Especially powerful when combined with bridges that can port over and synchronize your communications across multiple platforms like WhatsApp, Telegram etc. into Matrix.
- Fork or clone this repo.
- Setup the bot.
- Invite the bot into a room and start chatting.
All text posted in the room will be spontaneously translated into Chinese.
- A matrix account. Get one for free.
- A separate matrix account for the bot.
- The following information that should not be shared publicly.
a.BOT_HOMESERVER; information you will have after registering your bot matrix account.
b.BOT_USERNAME; information you will have after registering your bot matrix account.
c.BOT_PASSWORD; information you will have after registering your bot matrix account.
d.BOT_STORE; a json file to store information related to and accessible by the bot. e.BOT_CRYPT; a folder to store encryption information.
f.BOT_ACCESS_TOKEN; this can be retrieved by runningnode dist/bot-login.jsafter building the package.
When running locally, store the above as environment variables in a .env file.
When running on Github, store the above as actions secrets.
Run in terminal:
npm install
npm run build
node dist/basic-bot.jsStart a new workflow with this file in the repo.
The workflow action will terminate after every 6 hours due to usage limits on Github.
The bot uses a free Goolge Translate legacy service API gLFree by default.
A range of different services can be chosen by setting the SERVICE variable in src/basic-bot.ts. These include:
gLFree: Free legacy Google Translate API utilized by bregydoc's gtranslate.gFree: Another free Google Translate API, google-translate-free-api hosted by datpmt, with more functionalities exposed other than translation. However, datpmt will collect your IP information if you use the service.gcloud: The official Google Cloud Translation API. More credentials have to be provided, such as yourGCLOUD_API_KEYif you wish to use this service. The service is free up to a certain character limit (500000 as at Dec 2023) per month.baidu: Baidu Translation API. Credentials such yourBD_APPIDand aBD_SECRETare needed to access this service. You need a Baidu account registered as a developer to obtain the credentials. Baidu accounts are only available to people with a PRC mobile number who are residing in China. The service is free up to a certain character limit (2000000 as at Dec 2023) per month.
This bot is coded to automatically tally the total number of characters translated and stop the bot when the free monthly quota is exceeded. Update limits.json when the respective Google and Baidu policy changes.
