Skip to content
This repository has been archived by the owner on Jun 26, 2019. It is now read-only.
/ rin Public archive

Simple useless multi-purpose bot for discord and telegram

License

Notifications You must be signed in to change notification settings

tioirawan/rin

Repository files navigation

Rin
a simple multi-burpose bot

Build Status License: MIT Npm Version Node Version Dependencies Status Styled With Prettier PRs Welcome Tested with Jest Maintainability Coverage Codacy

Installation

Install all dependencies using npm

$ npm install

Build

$ npm run build

Development

cp .env.example .env

add your token to .env

use cli.js (process.arv) as input

$ STATUS=debug npm start calc 1 + 1

for discord or telegram set TELEGRAM_TOKEN or DISCORD_TOKEN in .env

$ npm run dev auto reload (use telegram or discord based on given token)

build and start main.js from build

$ npm start

you can just add DISCORD_TOKEN without TELEGRAM_TOKEN

to create a command create a file in src/commands folder, create a class that have a method called handle, ready, and variable this.INFO with some data, you can see in other command file

Info

this.INFO use to define command (required), description (required), for (optional) and required (optional)

import Rin from '../core/rin'

export default class Command{
    constuctor() {
        this.INFO = {
            command: 'something',
            description: 'make your life easier',
            for: 'discord' // or array ['discord', 'cli']
            required: [
                {
                    value: process.env.COMMAND_TOKEN,
                    toBe: Rin.notEmpty
                }
            ]
        }
    }
}

Ready

ready is called when this.INFO.required passed (optional)

import Rin from '../core/rin'

export default class Command{
    constuctor() {
        this.INFO = {
            command: 'sapi',
            description: 'make me happy',
            required: [
                {
                    value: process.env.SAPI_TOKEN,
                    toBe: Rin.notEmpty
                }
            ]
        }

        this.SAPI = new SOMETHING_API()
    }
    
    ready() {
        this.SAPI.register(process.env.SAPI_TOKEN)
    }
}

Handle

handle is called when user type the command

export default class Command{
    constuctor() {
        this.INFO = {
            command: 'kill',
            description: 'kill your ex'
        }
    }
    
    handle(message) {
        const exname = message.join(' ')

        return `${exname} has been killed`
    }
}

for helper, create a method in Rin class src/core/rin.js

always run $ npm run lint if you want to create a PR

Testing

$ npm test

create a unit test in test/command folder for subcommand testing and test/__data__ for mock data, testing are test src folder, so we don't need to rebuild

Contributing

  1. Fork this repository
  2. Create a feature branch (never edit your master branch) $ git checkout -b add-eat-command
  3. Create your features, see: development section
  4. Push your changes $ git push origin add-eat-command
  5. Create a pull request

I am very happy if you want to contribute!

License

This project is licensed under the terms of the MIT license.

Image License: I don't know

About

Simple useless multi-purpose bot for discord and telegram

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •