Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
accounting
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
accounting
Commits
aeead253
Commit
aeead253
authored
Jun 20, 2019
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
3862fb9c
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
34 deletions
+25
-34
app.js
app.js
+2
-1
message.js
message.js
+14
-8
package-lock.json
package-lock.json
+5
-0
package.json
package.json
+1
-0
test.js
test.js
+3
-25
No files found.
app.js
View file @
aeead253
...
@@ -371,7 +371,7 @@ async function generateText(current, num, msg) {
...
@@ -371,7 +371,7 @@ async function generateText(current, num, msg) {
}
}
runCron
()
async
function
runCron
()
{
async
function
runCron
()
{
let
admins
=
await
db
.
getAllAdmins
()
let
admins
=
await
db
.
getAllAdmins
()
let
name
=
'
./back/
'
+
'
backup-
'
+
moment
().
format
(
'
YYYY-MM-DD---HH-mm
'
)
+
'
.sql
'
let
name
=
'
./back/
'
+
'
backup-
'
+
moment
().
format
(
'
YYYY-MM-DD---HH-mm
'
)
+
'
.sql
'
...
@@ -385,6 +385,7 @@ async function runCron() {
...
@@ -385,6 +385,7 @@ async function runCron() {
});
});
for
(
let
i
=
0
;
i
<
admins
.
length
;
i
++
)
for
(
let
i
=
0
;
i
<
admins
.
length
;
i
++
)
{
{
bot
.
sendDocument
(
admins
[
i
].
teleid
,
name
)
bot
.
sendDocument
(
admins
[
i
].
teleid
,
name
)
}
}
}
}
...
...
message.js
View file @
aeead253
const
db
=
require
(
'
./db
'
)
const
db
=
require
(
'
./db
'
)
const
constant
=
require
(
'
./const
'
)
const
constant
=
require
(
'
./const
'
)
var
numeral
=
require
(
'
numeral
'
);
function
startMessage
(
bot
,
msg
)
{
function
startMessage
(
bot
,
msg
)
{
simpleMessage
(
bot
,
msg
,
'
به ربات حسابداری خودش آمدید.
'
)
simpleMessage
(
bot
,
msg
,
'
به ربات حسابداری خودش آمدید.
'
)
...
@@ -100,7 +101,7 @@ function userShowMessage(bot, msg, user) {
...
@@ -100,7 +101,7 @@ function userShowMessage(bot, msg, user) {
message_id
:
msg
.
message
.
message_id
message_id
:
msg
.
message
.
message_id
};
};
let
text
=
'
💷
'
let
text
=
'
💷
'
text
+=
Math
.
abs
(
user
.
toman_balance
)
+
'
'
+
'
تومان
'
+
'
'
text
+=
numberize
(
Math
.
abs
(
user
.
toman_balance
)
)
+
'
'
+
'
تومان
'
+
'
'
text
+=
user
.
toman_balance
===
0
?
''
:
text
+=
user
.
toman_balance
===
0
?
''
:
user
.
toman_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
user
.
toman_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
...
@@ -109,7 +110,7 @@ function userShowMessage(bot, msg, user) {
...
@@ -109,7 +110,7 @@ function userShowMessage(bot, msg, user) {
if
(
user
.
dollar_balance
!==
0
)
{
if
(
user
.
dollar_balance
!==
0
)
{
text
+=
'
💵
'
text
+=
'
💵
'
text
+=
Math
.
abs
(
user
.
dollar_balance
)
+
'
'
+
'
دلار
'
+
'
'
text
+=
numberize
(
Math
.
abs
(
user
.
dollar_balance
)
)
+
'
'
+
'
دلار
'
+
'
'
text
+=
user
.
dollar_balance
===
0
?
''
:
text
+=
user
.
dollar_balance
===
0
?
''
:
user
.
dollar_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
user
.
dollar_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
...
@@ -123,7 +124,7 @@ function userShowMessage(bot, msg, user) {
...
@@ -123,7 +124,7 @@ function userShowMessage(bot, msg, user) {
if
(
user
.
euro_balance
!==
0
)
{
if
(
user
.
euro_balance
!==
0
)
{
text
+=
'
💶
'
text
+=
'
💶
'
text
+=
Math
.
abs
(
user
.
euro_balance
)
+
'
'
+
'
یورو
'
+
'
'
text
+=
numberize
(
Math
.
abs
(
user
.
euro_balance
)
)
+
'
'
+
'
یورو
'
+
'
'
text
+=
user
.
euro_balance
===
0
?
''
:
text
+=
user
.
euro_balance
===
0
?
''
:
user
.
euro_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
user
.
euro_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
text
+=
'
\n
'
text
+=
'
\n
'
...
@@ -132,7 +133,7 @@ function userShowMessage(bot, msg, user) {
...
@@ -132,7 +133,7 @@ function userShowMessage(bot, msg, user) {
if
(
user
.
lir_balance
!==
0
)
{
if
(
user
.
lir_balance
!==
0
)
{
text
+=
'
💴
'
text
+=
'
💴
'
text
+=
Math
.
abs
(
user
.
lir_balance
)
+
'
'
+
'
لیر
'
+
'
'
text
+=
numberize
(
Math
.
abs
(
user
.
lir_balance
)
)
+
'
'
+
'
لیر
'
+
'
'
text
+=
user
.
lir_balance
===
0
?
''
:
text
+=
user
.
lir_balance
===
0
?
''
:
user
.
lir_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
user
.
lir_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
...
@@ -142,14 +143,14 @@ function userShowMessage(bot, msg, user) {
...
@@ -142,14 +143,14 @@ function userShowMessage(bot, msg, user) {
if
(
user
.
aed_balance
!==
0
)
{
if
(
user
.
aed_balance
!==
0
)
{
text
+=
'
💰
'
+
Math
.
abs
(
user
.
aed_balance
)
+
'
'
+
'
درهم
'
+
"
"
text
+=
'
💰
'
+
numberize
(
Math
.
abs
(
user
.
aed_balance
)
)
+
'
'
+
'
درهم
'
+
"
"
text
+=
user
.
aed_balance
===
0
?
''
:
text
+=
user
.
aed_balance
===
0
?
''
:
user
.
aed_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
user
.
aed_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
}
}
if
(
user
.
can_balance
!==
0
)
{
if
(
user
.
can_balance
!==
0
)
{
text
+=
'
💵
'
text
+=
'
💵
'
text
+=
Math
.
abs
(
user
.
can_balance
)
+
'
'
+
'
دلار کانادا
'
+
'
'
text
+=
numberize
(
Math
.
abs
(
user
.
can_balance
)
)
+
'
'
+
'
دلار کانادا
'
+
'
'
text
+=
user
.
can_balance
===
0
?
''
:
text
+=
user
.
can_balance
===
0
?
''
:
user
.
can_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
user
.
can_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
...
@@ -415,12 +416,12 @@ async function listRequest(bot, msg, reqs) {
...
@@ -415,12 +416,12 @@ async function listRequest(bot, msg, reqs) {
let
text
=
''
let
text
=
''
text
+=
reqs
[
i
].
type
.
replace
(
"
variz
"
,
"
واریز
"
).
replace
(
"
daryaft
"
,
"
دریافت
"
).
replace
(
"
buy
"
,
"
خرید
"
).
replace
(
"
sell
"
,
"
فروش
"
)
+
"
"
text
+=
reqs
[
i
].
type
.
replace
(
"
variz
"
,
"
واریز
"
).
replace
(
"
daryaft
"
,
"
دریافت
"
).
replace
(
"
buy
"
,
"
خرید
"
).
replace
(
"
sell
"
,
"
فروش
"
)
+
"
"
text
+=
reqs
[
i
].
count
+
"
"
text
+=
numberize
(
reqs
[
i
].
count
)
+
"
"
text
+=
reqs
[
i
].
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
+
"
"
text
+=
reqs
[
i
].
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
+
"
"
if
(
reqs
[
i
].
type
!==
'
variz
'
&&
reqs
[
i
].
type
!==
'
daryaft
'
)
{
if
(
reqs
[
i
].
type
!==
'
variz
'
&&
reqs
[
i
].
type
!==
'
daryaft
'
)
{
text
+=
'
با مبلغ
'
text
+=
'
با مبلغ
'
text
+=
'
'
text
+=
'
'
text
+=
reqs
[
i
].
fee
text
+=
numberize
(
reqs
[
i
].
fee
)
text
+=
'
'
text
+=
'
'
text
+=
reqs
[
i
].
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
text
+=
reqs
[
i
].
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
).
replace
(
'
can
'
,
'
دلار کانادا
'
)
text
+=
'
'
text
+=
'
'
...
@@ -491,6 +492,11 @@ async function showRequest(bot, msg, req) {
...
@@ -491,6 +492,11 @@ async function showRequest(bot, msg, req) {
await
showDocument
(
bot
,
msg
,
req
)
await
showDocument
(
bot
,
msg
,
req
)
}
}
function
numberize
(
num
)
{
return
numeral
(
num
).
format
(
'
0,0
'
);
}
module
.
exports
=
{
module
.
exports
=
{
...
...
package-lock.json
View file @
aeead253
...
@@ -546,6 +546,11 @@
...
@@ -546,6 +546,11 @@
}
}
}
}
},
},
"numeral"
:
{
"version"
:
"2.0.6"
,
"resolved"
:
"https://registry.npmjs.org/numeral/-/numeral-2.0.6.tgz"
,
"integrity"
:
"sha1-StCAk21EPCVhrtnyGX7//iX05QY="
},
"oauth-sign"
:
{
"oauth-sign"
:
{
"version"
:
"0.9.0"
,
"version"
:
"0.9.0"
,
"resolved"
:
"https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz"
,
"resolved"
:
"https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz"
,
...
...
package.json
View file @
aeead253
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
"
mysqldump
"
:
"
^3.0.0
"
,
"
mysqldump
"
:
"
^3.0.0
"
,
"
node-cron
"
:
"
^2.0.3
"
,
"
node-cron
"
:
"
^2.0.3
"
,
"
node-telegram-bot-api
"
:
"
^0.30.0
"
,
"
node-telegram-bot-api
"
:
"
^0.30.0
"
,
"
numeral
"
:
"
^2.0.6
"
,
"
sequelize
"
:
"
^4.38.1
"
"
sequelize
"
:
"
^4.38.1
"
}
}
}
}
test.js
View file @
aeead253
let
mysqldump
=
require
(
'
mysqldump
'
)
var
numeral
=
require
(
'
numeral
'
);
const
TelegramBot
=
require
(
'
node-telegram-bot-api
'
);
const
bot
=
new
TelegramBot
(
'
783628734:AAGHs5YcIGy4dhD3ZsKIQOKxcJVDD0ju4jY
'
,
{
polling
:
false
});
let
moment
=
require
(
'
moment-timezone
'
)
var
string
=
numeral
(
15285
).
format
(
'
0,0
'
);
test
()
console
.
log
(
string
)
async
function
test
()
{
let
name
=
'
./back/
'
+
'
backup-
'
+
moment
().
format
(
'
YYYY-MM-DD---HH-mm
'
)
+
'
.sql
'
const
result
=
await
mysqldump
({
connection
:
{
host
:
'
195.201.22.255
'
,
user
:
'
root
'
,
password
:
'
mahan7797
'
,
database
:
'
accounting
'
,
},
dumpToFile
:
name
,
});
bot
.
sendDocument
(
84169752
,
name
)
// console.log(result)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment