forked from fengnz/fengdoorbot
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
CATCH\dengy
committed
Mar 30, 2019
1 parent
0269b5c
commit 5de86c9
Showing
42 changed files
with
2,877 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"scriptId":"1lKsYEkqF9zFvW_-NHWm8DvISTdC01ubu5PkAEwysH5tHXG1hGztmFdsR"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
jsconfig.json | ||
tsconfig.json | ||
.gitignore | ||
node_modules/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,269 @@ | ||
{ | ||
"env": { | ||
"browser": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"parserOptions": { | ||
"ecmaVersion": 3 | ||
}, | ||
"rules": { | ||
"accessor-pairs": "error", | ||
"array-bracket-newline": "off", | ||
"array-bracket-spacing": [ | ||
"error", | ||
"never" | ||
], | ||
"array-callback-return": "off", | ||
"array-element-newline": "off", | ||
"arrow-body-style": "error", | ||
"arrow-parens": "error", | ||
"arrow-spacing": "error", | ||
"block-scoped-var": "off", | ||
"block-spacing": "error", | ||
"brace-style": "off", | ||
"callback-return": "error", | ||
"capitalized-comments": "off", | ||
"class-methods-use-this": "error", | ||
"comma-dangle": "off", | ||
"comma-spacing": "off", | ||
"comma-style": [ | ||
"error", | ||
"last" | ||
], | ||
"complexity": "off", | ||
"computed-property-spacing": [ | ||
"error", | ||
"never" | ||
], | ||
"consistent-return": "off", | ||
"consistent-this": "error", | ||
"curly": "off", | ||
"default-case": "off", | ||
"dot-location": "error", | ||
"dot-notation": [ | ||
"error", | ||
{ | ||
"allowKeywords": false | ||
} | ||
], | ||
"eol-last": "off", | ||
"eqeqeq": "off", | ||
"func-call-spacing": "error", | ||
"func-name-matching": "error", | ||
"func-names": "off", | ||
"func-style": [ | ||
"error", | ||
"declaration" | ||
], | ||
"function-paren-newline": "off", | ||
"generator-star-spacing": "error", | ||
"global-require": "error", | ||
"guard-for-in": "off", | ||
"handle-callback-err": "error", | ||
"id-blacklist": "error", | ||
"id-length": "off", | ||
"id-match": "error", | ||
"implicit-arrow-linebreak": "error", | ||
"indent": "off", | ||
"indent-legacy": "off", | ||
"init-declarations": "off", | ||
"jsx-quotes": "error", | ||
"key-spacing": "error", | ||
"keyword-spacing": "off", | ||
"line-comment-position": "off", | ||
"linebreak-style": "off", | ||
"lines-around-comment": "off", | ||
"lines-around-directive": "error", | ||
"lines-between-class-members": "error", | ||
"max-classes-per-file": "error", | ||
"max-depth": "off", | ||
"max-len": "off", | ||
"max-lines": "off", | ||
"max-lines-per-function": "off", | ||
"max-nested-callbacks": "error", | ||
"max-params": "error", | ||
"max-statements": "off", | ||
"max-statements-per-line": "error", | ||
"multiline-comment-style": [ | ||
"error", | ||
"separate-lines" | ||
], | ||
"multiline-ternary": "error", | ||
"new-parens": "error", | ||
"newline-after-var": "off", | ||
"newline-before-return": "off", | ||
"newline-per-chained-call": "error", | ||
"no-alert": "error", | ||
"no-array-constructor": "error", | ||
"no-async-promise-executor": "error", | ||
"no-await-in-loop": "error", | ||
"no-bitwise": "error", | ||
"no-buffer-constructor": "error", | ||
"no-caller": "error", | ||
"no-catch-shadow": "error", | ||
"no-confusing-arrow": "error", | ||
"no-continue": "off", | ||
"no-div-regex": "error", | ||
"no-duplicate-imports": "error", | ||
"no-else-return": "off", | ||
"no-empty-function": "error", | ||
"no-eq-null": "off", | ||
"no-eval": "error", | ||
"no-extend-native": "off", | ||
"no-extra-bind": "error", | ||
"no-extra-label": "error", | ||
"no-extra-parens": "off", | ||
"no-floating-decimal": "error", | ||
"no-implicit-globals": "off", | ||
"no-implied-eval": "error", | ||
"no-inline-comments": "off", | ||
"no-inner-declarations": [ | ||
"error", | ||
"functions" | ||
], | ||
"no-invalid-this": "error", | ||
"no-iterator": "error", | ||
"no-label-var": "error", | ||
"no-labels": "error", | ||
"no-lone-blocks": "error", | ||
"no-lonely-if": "off", | ||
"no-loop-func": "error", | ||
"no-magic-numbers": "off", | ||
"no-misleading-character-class": "error", | ||
"no-mixed-operators": "off", | ||
"no-mixed-requires": "error", | ||
"no-multi-assign": "off", | ||
"no-multi-spaces": "off", | ||
"no-multi-str": "error", | ||
"no-multiple-empty-lines": "off", | ||
"no-native-reassign": "error", | ||
"no-negated-condition": "off", | ||
"no-negated-in-lhs": "error", | ||
"no-nested-ternary": "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-param-reassign": "off", | ||
"no-path-concat": "error", | ||
"no-plusplus": "off", | ||
"no-process-env": "error", | ||
"no-process-exit": "error", | ||
"no-proto": "error", | ||
"no-prototype-builtins": "off", | ||
"no-restricted-globals": "error", | ||
"no-restricted-imports": "error", | ||
"no-restricted-modules": "error", | ||
"no-restricted-properties": "error", | ||
"no-restricted-syntax": "error", | ||
"no-return-assign": "error", | ||
"no-return-await": "error", | ||
"no-script-url": "error", | ||
"no-self-compare": "error", | ||
"no-sequences": "error", | ||
"no-shadow": "off", | ||
"no-shadow-restricted-names": "error", | ||
"no-spaced-func": "error", | ||
"no-sync": "error", | ||
"no-tabs": "off", | ||
"no-template-curly-in-string": "error", | ||
"no-ternary": "error", | ||
"no-throw-literal": "error", | ||
"no-trailing-spaces": "off", | ||
"no-undef-init": "error", | ||
"no-undefined": "error", | ||
"no-underscore-dangle": "off", | ||
"no-unmodified-loop-condition": "error", | ||
"no-unneeded-ternary": "error", | ||
"no-unused-expressions": "error", | ||
"no-use-before-define": "off", | ||
"no-useless-call": "error", | ||
"no-useless-computed-key": "error", | ||
"no-useless-concat": "off", | ||
"no-useless-constructor": "error", | ||
"no-useless-rename": "error", | ||
"no-useless-return": "error", | ||
"no-var": "off", | ||
"no-void": "error", | ||
"no-warning-comments": "error", | ||
"no-whitespace-before-property": "error", | ||
"no-with": "error", | ||
"object-curly-newline": "error", | ||
"object-curly-spacing": "off", | ||
"object-shorthand": "off", | ||
"one-var": "off", | ||
"one-var-declaration-per-line": "error", | ||
"operator-assignment": "off", | ||
"operator-linebreak": [ | ||
"error", | ||
"before" | ||
], | ||
"padded-blocks": "off", | ||
"padding-line-between-statements": "error", | ||
"prefer-arrow-callback": "off", | ||
"prefer-const": "error", | ||
"prefer-destructuring": "off", | ||
"prefer-numeric-literals": "error", | ||
"prefer-object-spread": "error", | ||
"prefer-promise-reject-errors": "error", | ||
"prefer-reflect": "off", | ||
"prefer-rest-params": "error", | ||
"prefer-spread": "error", | ||
"prefer-template": "off", | ||
"quote-props": "off", | ||
"quotes": "off", | ||
"radix": [ | ||
"error", | ||
"as-needed" | ||
], | ||
"require-atomic-updates": "error", | ||
"require-await": "error", | ||
"require-jsdoc": "off", | ||
"require-unicode-regexp": "off", | ||
"rest-spread-spacing": "error", | ||
"semi": "off", | ||
"semi-spacing": [ | ||
"error", | ||
{ | ||
"after": true, | ||
"before": false | ||
} | ||
], | ||
"semi-style": "off", | ||
"sort-imports": "error", | ||
"sort-keys": "off", | ||
"sort-vars": "error", | ||
"space-before-blocks": "off", | ||
"space-before-function-paren": "off", | ||
"space-in-parens": [ | ||
"error", | ||
"never" | ||
], | ||
"space-infix-ops": "off", | ||
"space-unary-ops": "error", | ||
"spaced-comment": "off", | ||
"strict": [ | ||
"error", | ||
"never" | ||
], | ||
"switch-colon-spacing": "error", | ||
"symbol-description": "error", | ||
"template-curly-spacing": "error", | ||
"template-tag-spacing": "error", | ||
"unicode-bom": [ | ||
"error", | ||
"never" | ||
], | ||
"valid-jsdoc": "error", | ||
"vars-on-top": "off", | ||
"wrap-iife": "error", | ||
"wrap-regex": "off", | ||
"yield-star-spacing": "error", | ||
"yoda": [ | ||
"error", | ||
"never" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
Array.prototype.unique = function() { | ||
return this.filter(function (value, index, self) { | ||
return self.indexOf(value) === index; | ||
}); | ||
} | ||
|
||
function debugArray(){ | ||
debug(); | ||
} | ||
|
||
// https://tc39.github.io/ecma262/#sec-array.prototype.includes | ||
if (!Array.prototype.includes) { | ||
Object.defineProperty(Array.prototype, 'includes', { | ||
value: function(searchElement, fromIndex) { | ||
|
||
if (this == null) { | ||
throw new TypeError('"this" is null or not defined'); | ||
} | ||
|
||
// 1. Let O be ? ToObject(this value). | ||
var o = Object(this); | ||
|
||
// 2. Let len be ? ToLength(? Get(O, "length")). | ||
var len = o.length >>> 0; | ||
|
||
// 3. If len is 0, return false. | ||
if (len === 0) { | ||
return false; | ||
} | ||
|
||
// 4. Let n be ? ToInteger(fromIndex). | ||
// (If fromIndex is undefined, this step produces the value 0.) | ||
var n = fromIndex | 0; | ||
|
||
// 5. If n ≥ 0, then | ||
// a. Let k be n. | ||
// 6. Else n < 0, | ||
// a. Let k be len + n. | ||
// b. If k < 0, let k be 0. | ||
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0); | ||
|
||
function sameValueZero(x, y) { | ||
return x === y || (typeof x === 'number' && typeof y === 'number' && isNaN(x) && isNaN(y)); | ||
} | ||
|
||
// 7. Repeat, while k < len | ||
while (k < len) { | ||
// a. Let elementK be the result of ? Get(O, ! ToString(k)). | ||
// b. If SameValueZero(searchElement, elementK) is true, return true. | ||
if (sameValueZero(o[k], searchElement)) { | ||
return true; | ||
} | ||
// c. Increase k by 1. | ||
k++; | ||
} | ||
|
||
// 8. Return false | ||
return false; | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 可以使用谷歌代码触发器每隔一段时间调用这个函数清除没有验证的过期用户 | ||
function removePendingUsers() { | ||
var find = { | ||
"status": "pending", | ||
}; | ||
|
||
var findString = JSON.stringify(find); | ||
var members = mongo.get(Const.memberColl, "filter=" + findString); | ||
for (var i = 0; i < members.length; i++) { | ||
var member = members[i]; | ||
|
||
//based on the gap between now and member join date, we decided whether need to add the kick payload | ||
var pending_time = Date.now() / 1000 - member.date; | ||
if (pending_time > member.timeout && member.timeout != 0) { | ||
// The user will be kicked and ban for 1 minute | ||
var kickPayload = { | ||
"method": "kickChatMember", | ||
"chat_id": member.chat.id, | ||
"user_id": member.user.id, | ||
"until_date": Date.now() / 1000 + 60, | ||
}; | ||
|
||
postTelegram(kickPayload); | ||
|
||
} | ||
} | ||
} |
Oops, something went wrong.