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
1cdecdb9
Commit
1cdecdb9
authored
Oct 29, 2020
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
901c2de3
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
491 additions
and
6 deletions
+491
-6
message.js
message.js
+58
-2
package-lock.json
package-lock.json
+431
-0
package.json
package.json
+1
-0
test.js
test.js
+1
-4
No files found.
message.js
View file @
1cdecdb9
const
db
=
require
(
'
./db
'
)
const
constant
=
require
(
'
./const
'
)
var
numeral
=
require
(
'
numeral
'
);
const
nodeHtmlToImage
=
require
(
'
node-html-to-image
'
)
function
startMessage
(
bot
,
msg
)
{
simpleMessage
(
bot
,
msg
,
'
به ربات حسابداری خودش آمدید.
'
)
}
...
...
@@ -54,7 +54,9 @@ async function deleteMessage(bot, msg) {
}
function
userShowMessage
(
bot
,
msg
,
user
)
{
async
function
userShowMessage
(
bot
,
msg
,
user
)
{
let
table
=
tableGenerator
(
'
🇮🇷
'
,
'
تومان
'
,
numberize
(
Math
.
abs
(
user
.
toman_balance
)),
user
.
toman_balance
===
0
?
''
:
user
.
toman_balance
>
0
?
'
بدهکار
'
:
'
بستانکار
'
)
var
opts
=
{
reply_markup
:
{
...
...
@@ -116,6 +118,9 @@ function userShowMessage(bot, msg, user) {
text
+=
'
\n
'
text
+=
'
\n
'
table
+=
tableGenerator
(
'
🇺🇸
'
,
'
دلار
'
,
numberize
(
Math
.
abs
(
user
.
dollar_balance
)),
user
.
dollar_balance
===
0
?
''
:
user
.
dollar_balance
>
0
?
'
بدهکار
'
:
'
بستانکار
'
)
}
...
...
@@ -129,6 +134,9 @@ function userShowMessage(bot, msg, user) {
user
.
euro_balance
>
0
?
'
بدهکار
'
:
'
بستانکار
'
text
+=
'
\n
'
text
+=
'
\n
'
table
+=
tableGenerator
(
'
🇪🇺
'
,
'
یورو
'
,
numberize
(
Math
.
abs
(
user
.
euro_balance
)),
user
.
euro_balance
===
0
?
''
:
user
.
euro_balance
>
0
?
'
بدهکار
'
:
'
بستانکار
'
)
}
if
(
user
.
lir_balance
!==
0
)
{
...
...
@@ -139,6 +147,9 @@ function userShowMessage(bot, msg, user) {
text
+=
'
\n
'
text
+=
'
\n
'
table
+=
tableGenerator
(
'
🇹🇷
'
,
'
لیر
'
,
numberize
(
Math
.
abs
(
user
.
lir_balance
)),
user
.
lir_balance
===
0
?
''
:
user
.
lir_balance
>
0
?
'
بدهکار
'
:
'
بستانکار
'
)
}
if
(
user
.
aed_balance
!==
0
)
{
...
...
@@ -148,6 +159,9 @@ function userShowMessage(bot, msg, user) {
user
.
aed_balance
>
0
?
'
بدهکار
'
:
'
بستانکار
'
text
+=
'
\n
'
text
+=
'
\n
'
table
+=
tableGenerator
(
'
🇦🇪
'
,
'
لیر
'
,
numberize
(
Math
.
abs
(
user
.
aed_balance
)),
user
.
aed_balance
===
0
?
''
:
user
.
aed_balance
>
0
?
'
بدهکار
'
:
'
بستانکار
'
)
}
if
(
user
.
can_balance
!==
0
)
{
...
...
@@ -158,6 +172,10 @@ function userShowMessage(bot, msg, user) {
text
+=
'
\n
'
text
+=
'
\n
'
table
+=
tableGenerator
(
'
🇨🇦
'
,
'
دلار کانادا
'
,
numberize
(
Math
.
abs
(
user
.
can_balance
)),
user
.
can_balance
===
0
?
''
:
user
.
can_balance
>
0
?
'
بدهکار
'
:
'
بستانکار
'
)
}
if
(
user
.
pon_balance
!==
0
)
{
...
...
@@ -168,6 +186,9 @@ function userShowMessage(bot, msg, user) {
text
+=
'
\n
'
text
+=
'
\n
'
table
+=
tableGenerator
(
'
🇬🇧
'
,
'
پوند
'
,
numberize
(
Math
.
abs
(
user
.
pon_balance
)),
user
.
pon_balance
===
0
?
''
:
user
.
pon_balance
>
0
?
'
بدهکار
'
:
'
بستانکار
'
)
}
if
(
user
.
aud_balance
!==
0
)
{
...
...
@@ -178,6 +199,10 @@ function userShowMessage(bot, msg, user) {
text
+=
'
\n
'
text
+=
'
\n
'
table
+=
tableGenerator
(
'
🇦🇺
'
,
'
دلار استرالیا
'
,
numberize
(
Math
.
abs
(
user
.
aud_balance
)),
user
.
aud_balance
===
0
?
''
:
user
.
aud_balance
>
0
?
'
بدهکار
'
:
'
بستانکار
'
)
}
if
(
user
.
rmb_balance
!==
0
)
{
...
...
@@ -188,12 +213,43 @@ function userShowMessage(bot, msg, user) {
text
+=
'
\n
'
text
+=
'
\n
'
table
+=
tableGenerator
(
'
🇨🇳
'
,
'
یوان چین
'
,
numberize
(
Math
.
abs
(
user
.
rmb_balance
)),
user
.
rmb_balance
===
0
?
''
:
user
.
rmb_balance
>
0
?
'
بدهکار
'
:
'
بستانکار
'
)
}
nodeHtmlToImage
({
output
:
'
./image.png
'
,
html
:
htmlGenerator
(
table
)
})
.
then
(()
=>
bot
.
sendPhoto
(
typeof
msg
.
chat
!==
'
undefined
'
?
msg
.
chat
.
id
:
msg
.
message
.
chat
.
id
,
'
./image.png
'
))
bot
.
editMessageText
(
text
,
opts
)
}
function
tableGenerator
(
flag
,
curName
,
value
,
type
)
{
let
q
=
` <tr>
<td>
${
flag
}
</td>
<td>
${
curName
}
</td>
<td>
${
value
}
</td>
<td>
${
type
}
</td>
</tr>
`
return
q
}
function
htmlGenerator
(
table
)
{
let
html
=
'
<!DOCTYPE html>
\n
<html>
\n
<head>
\n
<meta name="viewport" content="width=device-width, initial-scale=5">
\n
<style>
\n
table {
\n
border-collapse: collapse;
\n
border-spacing: 0;
\n
width: 100%;
\n
border: 1px solid #ddd;
\n
}
\n\n
th, td {
\n
text-align: right;
\n
padding: 8px;
\n
}
\n\n
tr:nth-child(even){background-color: #f2f2f2}
\n
</style>
\n
</head>
\n
<body>
\n\n\n
<div style="overflow-x:auto;">
\n
<table dir="rtl">
\n
<tr >
\n
<th>*</th>
\n
<th>نام ارز</th>
\n
<th>مانده حساب</th>
\n
<th>وضعیت</th>
\n
\n
</tr>
\n
salam
\n
\n
</table>
\n
</div>
\n\n
</body>
\n
</html>
\n\n\n
'
html
=
html
.
replace
(
'
salam
'
,
table
)
return
html
}
async
function
showCurrencyMessage
(
bot
,
msg
,
user
)
{
var
opts
=
{
reply_markup
:
{
...
...
package-lock.json
View file @
1cdecdb9
This diff is collapsed.
Click to expand it.
package.json
View file @
1cdecdb9
...
...
@@ -13,6 +13,7 @@
"
mysql2
"
:
"
^1.6.1
"
,
"
mysqldump
"
:
"
^3.0.0
"
,
"
node-cron
"
:
"
^2.0.3
"
,
"
node-html-to-image
"
:
"
^3.1.0
"
,
"
node-telegram-bot-api
"
:
"
^0.30.0
"
,
"
numeral
"
:
"
^2.0.6
"
,
"
sequelize
"
:
"
^4.38.1
"
...
...
test.js
View file @
1cdecdb9
var
numeral
=
require
(
'
numeral
'
);
const
nodeHtmlToImage
=
require
(
'
node-html-to-image
'
)
var
string
=
numeral
(
15285
).
format
(
'
0,0
'
);
console
.
log
(
string
)
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