Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
TapuCosmo committed Jan 18, 2021
0 parents commit b0eb6cd
Show file tree
Hide file tree
Showing 23 changed files with 3,823 additions and 0 deletions.
200 changes: 200 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
{
"env": {
"es2020": true,
"node": true,
"commonjs": true
},
"extends": "eslint:recommended",
"rules": {
"accessor-pairs": "error",
"arrow-body-style": "error",
"arrow-parens": [
"error",
"as-needed"
],
"arrow-spacing": [
"error",
{
"after": true,
"before": true
}
],
"block-scoped-var": "error",
"brace-style": [
"error",
"1tbs"
],
"callback-return": "error",
"camelcase": "off",
"class-methods-use-this": "error",
"comma-dangle": "error",
"comma-spacing": [
"error",
{
"after": true,
"before": false
}
],
"comma-style": [
"error",
"last"
],
"dot-notation": "error",
"eqeqeq": "error",
"func-call-spacing": "error",
"func-name-matching": "error",
"function-paren-newline": "error",
"global-require": "off",
"guard-for-in": "error",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"implicit-arrow-linebreak": [
"error",
"beside"
],
"indent": "off",
"indent-legacy": "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "error",
"keyword-spacing": [
"error",
{
"after": true,
"before": true
}
],
"max-len": "off",
"new-cap": "off",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"no-alert": "error",
"no-array-constructor": "error",
"no-buffer-constructor": "error",
"no-caller": "error",
"no-catch-shadow": "error",
"no-confusing-arrow": "off",
"no-duplicate-imports": "error",
"no-else-return": "off",
"no-empty": "off",
"no-eq-null": "error",
"no-eval": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
"no-floating-decimal": "error",
"no-implicit-globals": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lonely-if": "error",
"no-loop-func": "off",
"no-magic-numbers": "off",
"no-mixed-requires": "error",
"no-multi-spaces": "error",
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-negated-in-lhs": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-process-env": "error",
"no-proto": "error",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": [
"error",
"except-parens"
],
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "error",
"no-shadow-restricted-names": "error",
"no-spaced-func": "error",
"no-sync": "error",
"no-tabs": "error",
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef": "error",
"no-undef-init": "error",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-vars": ["error", {"args": "none"}],
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "error",
"no-void": "error",
"no-whitespace-before-property": "error",
"no-with": "error",
"nonblock-statement-body-position": "error",
"object-curly-spacing": "error",
"object-property-newline": "error",
"one-var": "off",
"one-var-declaration-per-line": "error",
"operator-assignment": "error",
"operator-linebreak": "error",
"padded-blocks": "off",
"padding-line-between-statements": "error",
"prefer-const": "error",
"prefer-numeric-literals": "error",
"prefer-promise-reject-errors": "error",
"prefer-spread": "error",
"quote-props": "off",
"quotes": [
"error",
"double"
],
"radix": "off",
"require-await": "error",
"rest-spread-spacing": "error",
"semi": "error",
"semi-spacing": "error",
"semi-style": [
"error",
"last"
],
"sort-imports": "off",
"sort-keys": "off",
"space-before-blocks": "error",
"space-before-function-paren": "off",
"space-in-parens": [
"error",
"never"
],
"space-infix-ops": "error",
"space-unary-ops": "error",
"strict": [
"error",
"global"
],
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": [
"error",
"never"
],
"yield-star-spacing": "error"
}
}
29 changes: 29 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: On Release
on:
workflow_dispatch:
release:
types: [published]

jobs:
deploy:
name: GitHub Pages
runs-on: ubuntu-20.04
strategy:
matrix:
node-version: [14.x]
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
submodules: true
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run docs:build
- name: Deploy Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/out
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Documentation output
docs/out
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2021 Vietbao Tran (TapuCosmo)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Signal-Bot

A library for creating bots that interact with the Signal application. Not affiliated with the Signal project or Open Whisper Systems.

Install with `npm install signal-bot`.

Currently only works on Linux, with Node.js >=14.0.0.

This library requires a working installation of [signal-cli](https://github.com/AsamK/signal-cli)
running in daemon mode with the phone number you want to use.
Use [this Python script](https://gist.github.com/Vic3198/f0c9e17ef3d70e7b8c066bfd8cf4db2d) for an easy installation process

Tested on v0.7.2 of signal-cli.

## Example Usage

### Basic Commands

```js
const {Client} = require("signal-bot");

const bot = new Client();

const prefix = "!";

bot.on("message", msg => {
if (!msg.content.startsWith(prefix)) return;
const command = msg.content.slice(prefix.length);

if (command === "hello") {
msg.conversation.sendMessage("Hello World!");
} else if (command === "whoami") {
msg.conversation.sendMessage(`You are ${msg.author.id}`);
}
});

bot.connect();
```

Send the bot `!hello` and it should respond with `Hello World!`.

Send the bot `!whoami` and it should respond with `You are <phone number>`.

## Missing Features

* signal-cli D-Bus missing features:
- Group conversation invite event
- Group conversation leave event
- Reactions
- Stickers
* Contact management
* Additional user/group member information/profiles
* Group conversation member list
* Group conversation admin functions
38 changes: 38 additions & 0 deletions docs/jsdoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"opts": {
"recurse": true,
"encoding": "utf8",
"template": "node_modules/docdash",
"destination": "./docs/out/"
},
"plugins": [
"plugins/markdown"
],
"templates": {
"default": {
"cleverLinks": true,
"includeDate": false
},
"docdash": {
"typedefs": true,
"openGraph": {
"title": "signal-bot Documentation",
"type": "website",
"site_name": "signal-bot",
"url": ""
},
"meta": {
"title": "signal-bot Documentation",
"description": "A library for creating bots that interact with the Signal application. Not affiliated with the Signal project or Open Whisper Systems.",
"keyword": "signal bot client"
}
}
},
"source": {
"include": [
"./src/",
"./README.md"
],
"includePattern": ".+\\.js$"
}
}
Loading

0 comments on commit b0eb6cd

Please sign in to comment.