riot-translatebot

A simple riot bot which provides Status about Weblate
git clone git://archive.git.mtrnord.blog/Nordgedanken/riot-translatebot.git
Log | Files | Refs | README | LICENSE

commands.js (1524B)


      1 import Weblate from './weblate';
      2 import config from '../config.json';
      3 
      4 export default class Commands {
      5     constructor(client){
      6         this.client = client;
      7         this.weblate = new Weblate();
      8     }
      9 
     10     help = room => {
     11         return this.client.sendHtmlNotice(room.roomId, `Help for you!\n Commands:\n * !languages`, `Help for you!<br> Commands:<br> <ul><li>languages</li></ul>`).catch(error => console.log(error));
     12     };
     13 
     14     languages = room => {
     15         return this.weblate.getLangs().then(body => {
     16             let message = 'Currently known languages:\n';
     17             for (let key in body['results']) {
     18                 message += body['results'][key]['code'] + '\n'
     19             }
     20             return this.client.sendNotice(room.roomId, message).catch(error => console.log(error));
     21         })
     22         .catch(err => {
     23             console.log(err);
     24         });
     25     };
     26 
     27     projects = room => {
     28         return this.weblate.getProjects().then(body => {
     29             let message = 'Projects on the Server:\n';
     30             for (let key in body['results']) {
     31                 message += body['results'][key]["name"] + '\n'
     32                 message += 'Direct Link: '+ config["weblateApiRoot"].replace('api/', 'projects/') + body['results'][key]["slug"] + '\n'
     33             }
     34             return this.client.sendNotice(room.roomId, message).catch(error => console.log(error));
     35         })
     36         .catch(err => {
     37             console.log(err);
     38         });
     39     };
     40 
     41     status = (room, lang) => {
     42         return undefined;
     43     }
     44 }