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
470c325c
Commit
470c325c
authored
Mar 17, 2019
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
d8b9b5f9
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
297 additions
and
49 deletions
+297
-49
app.js
app.js
+21
-7
db.js
db.js
+148
-5
message.js
message.js
+128
-37
No files found.
app.js
View file @
470c325c
...
@@ -18,6 +18,7 @@ bot.on('message', (msg) => {
...
@@ -18,6 +18,7 @@ bot.on('message', (msg) => {
});
});
async
function
processMessage
(
msg
)
{
async
function
processMessage
(
msg
)
{
await
isAdmin
(
msg
)
await
isAdmin
(
msg
)
if
(
msg
.
document
)
{
if
(
msg
.
document
)
{
commitDoc
(
msg
)
commitDoc
(
msg
)
...
@@ -39,12 +40,13 @@ bot.on('callback_query', function onCallbackQuery(msg) {
...
@@ -39,12 +40,13 @@ bot.on('callback_query', function onCallbackQuery(msg) {
});
});
async
function
processCallback
(
msg
)
{
async
function
processCallback
(
msg
)
{
console
.
log
(
msg
)
await
isAdmin
(
msg
)
await
isAdmin
(
msg
)
if
(
msg
.
data
.
startsWith
(
"
user_
"
))
showUser
(
msg
)
if
(
msg
.
data
.
startsWith
(
"
user_
"
))
showUser
(
msg
)
else
if
(
msg
.
data
.
startsWith
(
"
request_
"
))
request
(
msg
)
else
if
(
msg
.
data
.
startsWith
(
"
request_
"
))
request
(
msg
)
else
if
(
msg
.
data
.
startsWith
(
"
buy_
"
))
showCurrency
(
msg
,
'
buy
'
)
else
if
(
msg
.
data
.
startsWith
(
"
buy_
"
))
showCurrency
(
msg
,
'
buy
'
)
else
if
(
msg
.
data
.
startsWith
(
"
sell_
"
))
showCurrency
(
msg
,
'
sell
'
)
else
if
(
msg
.
data
.
startsWith
(
"
sell_
"
))
showCurrency
(
msg
,
'
sell
'
)
else
if
(
msg
.
data
.
startsWith
(
"
variz_
"
))
showCurrency
(
msg
,
'
variz
'
)
else
if
(
msg
.
data
.
startsWith
(
"
toman_
"
))
showCount
(
msg
,
'
toman
'
)
else
if
(
msg
.
data
.
startsWith
(
"
toman_
"
))
showCount
(
msg
,
'
toman
'
)
else
if
(
msg
.
data
.
startsWith
(
"
dollar_
"
))
showCount
(
msg
,
'
dollar
'
)
else
if
(
msg
.
data
.
startsWith
(
"
dollar_
"
))
showCount
(
msg
,
'
dollar
'
)
else
if
(
msg
.
data
.
startsWith
(
"
euro_
"
))
showCount
(
msg
,
'
euro
'
)
else
if
(
msg
.
data
.
startsWith
(
"
euro_
"
))
showCount
(
msg
,
'
euro
'
)
...
@@ -99,6 +101,9 @@ async function showCurrency(msg, type) {
...
@@ -99,6 +101,9 @@ async function showCurrency(msg, type) {
case
'
sell
'
:
case
'
sell
'
:
msg
.
data
=
msg
.
data
.
replace
(
"
sell_
"
,
""
)
msg
.
data
=
msg
.
data
.
replace
(
"
sell_
"
,
""
)
break
break
case
'
variz
'
:
msg
.
data
=
msg
.
data
.
replace
(
"
variz_
"
,
""
)
break
}
}
...
@@ -132,10 +137,12 @@ async function showCount(msg, unit) {
...
@@ -132,10 +137,12 @@ async function showCount(msg, unit) {
let
admin
=
await
db
.
findAdmin
(
msg
)
let
admin
=
await
db
.
findAdmin
(
msg
)
admin
.
data
=
JSON
.
parse
(
admin
.
data
)
admin
.
data
=
JSON
.
parse
(
admin
.
data
)
let
type
=
admin
.
data
.
action
console
.
log
(
admin
.
data
)
admin
.
data
.
vahed
=
unit
admin
.
data
.
vahed
=
unit
await
db
.
updateData
(
msg
,
JSON
.
stringify
(
admin
.
data
))
await
db
.
updateData
(
msg
,
JSON
.
stringify
(
admin
.
data
))
message
.
showCountMessage
(
bot
,
msg
)
message
.
showCountMessage
(
bot
,
msg
,
type
===
'
variz
'
)
}
}
async
function
elseMessage
(
msg
)
{
async
function
elseMessage
(
msg
)
{
...
@@ -158,11 +165,15 @@ async function input1(msg) {
...
@@ -158,11 +165,15 @@ async function input1(msg) {
let
admin
=
await
db
.
findAdmin
(
msg
)
let
admin
=
await
db
.
findAdmin
(
msg
)
admin
.
data
=
JSON
.
parse
(
admin
.
data
)
admin
.
data
=
JSON
.
parse
(
admin
.
data
)
let
type
=
admin
.
data
.
action
admin
.
data
.
count
=
msg
.
text
admin
.
data
.
count
=
msg
.
text
admin
.
data
=
JSON
.
stringify
(
admin
.
data
)
admin
.
data
=
JSON
.
stringify
(
admin
.
data
)
await
db
.
updateData
(
msg
,
admin
.
data
)
await
db
.
updateData
(
msg
,
admin
.
data
)
if
(
type
===
'
variz
'
)
message
.
sendDocMessage
(
bot
,
msg
)
else
message
.
showFeeMessage
(
bot
,
msg
)
message
.
showFeeMessage
(
bot
,
msg
)
}
}
...
@@ -184,8 +195,9 @@ async function input2(msg) {
...
@@ -184,8 +195,9 @@ async function input2(msg) {
}
}
async
function
yesNoDoc
(
msg
,
type
)
{
async
function
yesNoDoc
(
msg
,
type
)
{
console
.
log
(
"
Yes?????
"
)
if
(
type
.
includes
(
'
yes
'
))
{
if
(
type
.
includes
(
'
yes
'
))
{
message
.
deleteMessage
(
bot
,
msg
)
message
.
simpleMessage
(
bot
,
msg
,
'
لطفا فایل ضمیمه را ارسال کنید دقت شود که به عنوان فایل ارسال شود.
'
)
message
.
simpleMessage
(
bot
,
msg
,
'
لطفا فایل ضمیمه را ارسال کنید دقت شود که به عنوان فایل ارسال شود.
'
)
return
return
}
}
...
@@ -196,13 +208,13 @@ async function yesNoDoc(msg, type) {
...
@@ -196,13 +208,13 @@ async function yesNoDoc(msg, type) {
await
db
.
createRequest
(
admin
.
data
)
await
db
.
createRequest
(
admin
.
data
)
await
db
.
updateData
(
msg
,
null
)
await
db
.
updateData
(
msg
,
null
)
message
.
deleteMessage
(
bot
,
msg
)
message
.
simpleMessage
(
bot
,
msg
,
'
فیش با موفقیت ثبت شد.
'
)
message
.
simpleMessage
(
bot
,
msg
,
'
فیش با موفقیت ثبت شد.
'
)
}
}
async
function
commitRequest
(
msg
,
type
)
{
async
function
commitRequest
(
msg
,
type
)
{
console
.
log
(
"
Here
"
)
let
admin
=
await
db
.
findAdmin
(
msg
)
let
admin
=
await
db
.
findAdmin
(
msg
)
admin
.
data
=
JSON
.
parse
(
admin
.
data
)
admin
.
data
=
JSON
.
parse
(
admin
.
data
)
...
@@ -211,7 +223,7 @@ async function commitRequest(msg, type) {
...
@@ -211,7 +223,7 @@ async function commitRequest(msg, type) {
// await db.createRequest(admin.data)
// await db.createRequest(admin.data)
await
db
.
updateData
(
msg
,
JSON
.
stringify
(
admin
.
data
))
await
db
.
updateData
(
msg
,
JSON
.
stringify
(
admin
.
data
))
message
.
deleteMessage
(
bot
,
msg
)
message
.
sendDocMessage
(
bot
,
msg
,
userId
)
message
.
sendDocMessage
(
bot
,
msg
,
userId
)
}
}
...
@@ -293,6 +305,7 @@ async function canOrder(data, msg) {
...
@@ -293,6 +305,7 @@ async function canOrder(data, msg) {
async
function
showRequest
(
msg
)
{
async
function
showRequest
(
msg
)
{
msg
.
data
=
msg
.
data
.
replace
(
"
reqs_
"
,
""
)
msg
.
data
=
msg
.
data
.
replace
(
"
reqs_
"
,
""
)
let
req
=
await
db
.
findRequest
(
msg
.
data
)
let
req
=
await
db
.
findRequest
(
msg
.
data
)
message
.
deleteMessage
(
bot
,
msg
)
message
.
showRequest
(
bot
,
msg
,
req
)
message
.
showRequest
(
bot
,
msg
,
req
)
}
}
...
@@ -311,6 +324,7 @@ async function reportRequest(msg, date) {
...
@@ -311,6 +324,7 @@ async function reportRequest(msg, date) {
break
break
}
}
let
reqs
=
await
db
.
getRequestByDate
(
msg
.
data
,
date
)
let
reqs
=
await
db
.
getRequestByDate
(
msg
.
data
,
date
)
message
.
deleteMessage
(
bot
,
msg
)
message
.
listRequest
(
bot
,
msg
,
reqs
)
message
.
listRequest
(
bot
,
msg
,
reqs
)
}
}
...
...
db.js
View file @
470c325c
...
@@ -60,13 +60,20 @@ const Request = sequelize.define('request', {
...
@@ -60,13 +60,20 @@ const Request = sequelize.define('request', {
async
function
createRequest
(
data
)
{
async
function
createRequest
(
data
)
{
let
user
=
await
findUser
(
data
.
user
)
user
=
runCurrency
(
data
,
user
)
await
updateBalance
(
user
)
let
mRequest
=
await
Request
.
create
({
let
mRequest
=
await
Request
.
create
({
user_request
:
data
.
user
,
user_request
:
data
.
user
,
fee
:
data
.
fee
,
fee
:
data
.
fee
,
count
:
data
.
count
,
count
:
data
.
count
,
unit
:
data
.
vahed
,
unit
:
data
.
vahed
,
file_id
:
data
.
file_id
,
file_id
:
data
.
file_id
,
type
:
data
.
action
,
type
:
data
.
action
,
toUnit
:
data
.
to
,
toUnit
:
data
.
to
,
is_today
:
true
is_today
:
true
...
@@ -74,6 +81,128 @@ async function createRequest(data) {
...
@@ -74,6 +81,128 @@ async function createRequest(data) {
return
mRequest
;
return
mRequest
;
}
function
runCurrency
(
data
,
user
)
{
if
(
data
.
action
===
'
variz
'
)
{
switch
(
data
.
vahed
)
{
case
'
toman
'
:
user
.
toman_balance
=
parseFloat
(
user
.
toman_balance
)
+
(
-
1
*
parseFloat
(
data
.
count
))
break
case
'
dollar
'
:
user
.
dollar_balance
=
user
.
dollar_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
break
case
'
euro
'
:
user
.
euro_balance
=
user
.
euro_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
break
case
'
lir
'
:
user
.
lir_balance
=
user
.
lir_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
break
case
'
aed
'
:
user
.
aed_balance
=
user
.
aed_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
break
}
return
user
}
if
(
data
.
vahed
===
'
toman
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
toman_balance
=
user
.
toman_balance
+
parseFloat
(
data
.
count
)
else
user
.
toman_balance
=
user
.
toman_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
}
else
if
(
data
.
vahed
===
'
dollar
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
dollar_balance
=
user
.
dollar_balance
+
parseFloat
(
data
.
count
)
else
user
.
dollar_balance
=
user
.
dollar_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
}
else
if
(
data
.
vahed
===
'
euro
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
euro_balance
=
user
.
euro_balance
+
parseFloat
(
data
.
count
)
else
user
.
euro_balance
=
user
.
euro_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
}
else
if
(
data
.
vahed
===
'
lir
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
lir_balance
=
user
.
lir_balance
+
parseFloat
(
data
.
count
)
else
user
.
lir_balance
=
user
.
lir_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
}
else
if
(
data
.
vahed
===
'
aed
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
aed_balance
=
user
.
aed_balance
+
parseFloat
(
data
.
count
)
else
user
.
aed_balance
=
user
.
aed_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
}
if
(
data
.
to
===
'
toman
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
toman_balance
=
user
.
toman_balance
+
(
-
1
*
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
else
user
.
toman_balance
=
user
.
toman_balance
+
(
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
}
else
if
(
data
.
vahed
===
'
dollar
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
dollar_balance
=
user
.
dollar_balance
+
(
-
1
*
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
else
user
.
toman_balance
=
user
.
dollar_balance
+
(
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
}
else
if
(
data
.
vahed
===
'
euro
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
euro_balance
=
user
.
euro_balance
+
(
-
1
*
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
else
user
.
euro_balance
=
user
.
euro_balance
+
(
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
}
else
if
(
data
.
vahed
===
'
lir
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
lir_balance
=
user
.
lir_balance
+
(
-
1
*
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
else
user
.
lir_balance
=
user
.
lir_balance
+
(
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
}
else
if
(
data
.
vahed
===
'
aed
'
)
{
if
(
data
.
action
===
'
buy
'
)
user
.
aed_balance
=
user
.
aed_balance
+
(
-
1
*
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
else
user
.
aed_balance
=
user
.
aed_balance
+
(
parseFloat
(
data
.
count
)
*
parseFloat
(
data
.
fee
))
}
return
user
}
}
async
function
getAllUsers
()
{
async
function
getAllUsers
()
{
...
@@ -111,6 +240,22 @@ async function updateData(msg, data) {
...
@@ -111,6 +240,22 @@ async function updateData(msg, data) {
}
}
async
function
updateBalance
(
user
)
{
return
await
User
.
update
(
{
toman_balance
:
user
.
toman_balance
,
dollar_balance
:
user
.
dollar_balance
,
euro_balance
:
user
.
euro_balance
,
lir_balance
:
user
.
lir_balance
,
aed_balance
:
user
.
aed_balance
},
{
where
:
{
id
:
user
.
id
}})
}
async
function
updateStatus
(
msg
,
status
)
{
async
function
updateStatus
(
msg
,
status
)
{
return
await
Admin
.
update
(
return
await
Admin
.
update
(
{
{
...
@@ -133,8 +278,6 @@ async function findAdmin(msg) {
...
@@ -133,8 +278,6 @@ async function findAdmin(msg) {
})
})
}
}
async
function
findRequest
(
id
)
{
async
function
findRequest
(
id
)
{
...
...
message.js
View file @
470c325c
...
@@ -9,10 +9,12 @@ async function simpleMessage(bot, msg, text) {
...
@@ -9,10 +9,12 @@ async function simpleMessage(bot, msg, text) {
const
opts
=
{
const
opts
=
{
reply_markup
:
{
reply_markup
:
{
keyboard
:
[
keyboard
:
[
[
'
💷 لیست اعضا
'
]
[
'
💷 لیست اعضا
'
]
,
],
],
resize_keyboard
:
true
,
one_time_keyboard
:
true
}
}
};
};
...
@@ -32,17 +34,7 @@ async function listUserMessage(bot, msg, users) {
...
@@ -32,17 +34,7 @@ async function listUserMessage(bot, msg, users) {
for
(
let
i
=
0
;
i
<
users
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
users
.
length
;
i
++
)
{
let
text
=
users
[
i
].
first_name
+
"
"
+
users
[
i
].
last_name
+
'
'
+
'
اعتبار:
'
let
text
=
users
[
i
].
first_name
+
"
"
+
users
[
i
].
last_name
text
+=
generateText
(
'
تومان
'
,
users
[
i
].
toman_balance
)
if
(
users
[
i
].
dollar_balance
!==
0
)
text
+=
generateText
(
'
دلار
'
,
users
[
i
].
dollar_balance
)
if
(
users
[
i
].
euro_balance
!==
0
)
text
+=
generateText
(
'
یورو
'
,
users
[
i
].
euro_balance
)
if
(
users
[
i
].
lir_balance
!==
0
)
text
+=
generateText
(
'
لیر
'
,
users
[
i
].
lir_balance
)
if
(
users
[
i
].
aed_balance
!==
0
)
text
+=
generateText
(
'
درهم
'
,
users
[
i
].
aed_balance
)
opts
.
reply_markup
.
inline_keyboard
.
push
([{
opts
.
reply_markup
.
inline_keyboard
.
push
([{
text
:
text
,
text
:
text
,
...
@@ -63,6 +55,11 @@ function generateText(type, balance) {
...
@@ -63,6 +55,11 @@ function generateText(type, balance) {
}
}
async
function
deleteMessage
(
bot
,
msg
)
{
await
bot
.
deleteMessage
(
typeof
msg
.
chat
!==
'
undefined
'
?
msg
.
chat
.
id
:
msg
.
message
.
chat
.
id
,
typeof
msg
.
message_id
!==
'
undefined
'
?
msg
.
message_id
:
msg
.
message
.
message_id
)
}
function
userShowMessage
(
bot
,
msg
,
user
)
{
function
userShowMessage
(
bot
,
msg
,
user
)
{
var
opts
=
{
var
opts
=
{
...
@@ -110,9 +107,53 @@ function userShowMessage(bot, msg, user) {
...
@@ -110,9 +107,53 @@ function userShowMessage(bot, msg, user) {
chat_id
:
msg
.
message
.
chat
.
id
,
chat_id
:
msg
.
message
.
chat
.
id
,
message_id
:
msg
.
message
.
message_id
message_id
:
msg
.
message
.
message_id
};
};
let
text
=
'
💷
'
text
+=
Math
.
abs
(
user
.
toman_balance
)
+
'
'
+
'
تومان
'
+
'
'
text
+=
user
.
toman_balance
===
0
?
''
:
user
.
toman_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
text
+=
'
\n
'
text
+=
'
\n
'
if
(
user
.
dollar_balance
!==
0
)
{
text
+=
'
💵
'
text
+=
Math
.
abs
(
user
.
dollar_balance
)
+
'
'
+
'
دلار
'
+
'
'
text
+=
user
.
dollar_balance
===
0
?
''
:
user
.
dollar_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
text
+=
'
\n
'
text
+=
'
\n
'
}
if
(
user
.
euro_balance
!==
0
)
{
text
+=
'
💶
'
text
+=
Math
.
abs
(
user
.
euro_balance
)
+
'
'
+
'
یورو
'
+
'
'
text
+=
user
.
euro_balance
===
0
?
''
:
user
.
euro_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
text
+=
'
\n
'
text
+=
'
\n
'
}
if
(
user
.
lir_balance
!==
0
)
{
text
+=
'
💴
'
text
+=
Math
.
abs
(
user
.
lir_balance
)
+
'
'
+
'
لیر
'
+
'
'
text
+=
user
.
lir_balance
===
0
?
''
:
user
.
lir_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
text
+=
'
\n
'
text
+=
'
\n
'
}
if
(
user
.
aed_balance
!==
0
)
{
bot
.
editMessageText
(
'
لطفا کاربر مورد نظر را انتخاب کنید.
'
,
opts
)
text
+=
'
💰
'
+
Math
.
abs
(
user
.
aed_balance
)
+
'
'
+
'
درهم
'
+
"
"
text
+=
user
.
aed_balance
===
0
?
''
:
user
.
aed_balance
>
0
?
'
بدهکار
'
:
'
طلبکار
'
}
bot
.
editMessageText
(
text
,
opts
)
}
}
async
function
showCurrencyMessage
(
bot
,
msg
,
user
)
{
async
function
showCurrencyMessage
(
bot
,
msg
,
user
)
{
...
@@ -196,6 +237,14 @@ async function userSubmitRequest(bot, msg, user) {
...
@@ -196,6 +237,14 @@ async function userSubmitRequest(bot, msg, user) {
callback_data
:
'
sell_
'
+
user
.
id
callback_data
:
'
sell_
'
+
user
.
id
}
}
],
[
{
text
:
'
واریز
'
,
callback_data
:
'
variz_
'
+
user
.
id
}
]
]
...
@@ -211,12 +260,15 @@ async function userSubmitRequest(bot, msg, user) {
...
@@ -211,12 +260,15 @@ async function userSubmitRequest(bot, msg, user) {
}
}
async
function
showCountMessage
(
bot
,
msg
)
{
async
function
showCountMessage
(
bot
,
msg
,
variz
)
{
var
opts
=
{
var
opts
=
{
chat_id
:
msg
.
message
.
chat
.
id
,
chat_id
:
msg
.
message
.
chat
.
id
,
message_id
:
msg
.
message
.
message_id
message_id
:
msg
.
message
.
message_id
};
};
await
db
.
updateStatus
(
msg
,
constant
.
input1
)
await
db
.
updateStatus
(
msg
,
constant
.
input1
)
if
(
variz
)
bot
.
editMessageText
(
'
لطفا مبلغ فیش واریزی را وارد نمایید.
'
,
opts
)
else
bot
.
editMessageText
(
'
لطفا مقدار مورد نیاز را وارد نمایید.
'
,
opts
)
bot
.
editMessageText
(
'
لطفا مقدار مورد نیاز را وارد نمایید.
'
,
opts
)
}
}
...
@@ -302,7 +354,7 @@ async function sendDocMessage(bot, msg, user) {
...
@@ -302,7 +354,7 @@ async function sendDocMessage(bot, msg, user) {
{
{
text
:
'
خیر
'
,
text
:
'
خیر
'
,
callback_data
:
'
no_
'
+
user
.
id
callback_data
:
'
no_
'
+
user
}
}
],
],
...
@@ -322,16 +374,32 @@ async function sendDocMessage(bot, msg, user) {
...
@@ -322,16 +374,32 @@ async function sendDocMessage(bot, msg, user) {
async
function
listRequest
(
bot
,
msg
,
reqs
)
{
async
function
listRequest
(
bot
,
msg
,
reqs
)
{
const
opts
=
{
const
opts
=
{
reply_markup
:
{
reply_markup
:
{
inline_keyboard
:
[]
inline_keyboard
:
[],
}
}
};
};
let
print
=
"
ℹ️
"
;
print
+=
'
تعداد کل فیش ها:
'
print
+=
reqs
.
length
+
"
\n
"
reqs
=
reqs
.
reverse
()
for
(
let
i
=
0
;
i
<
reqs
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
reqs
.
length
;
i
++
)
{
let
text
=
"
فیش شماره
"
let
text
=
''
text
+=
reqs
[
i
].
id
text
+=
reqs
[
i
].
type
.
replace
(
"
variz
"
,
"
واریز
"
).
replace
(
"
buy
"
,
"
خرید
"
).
replace
(
"
sell
"
,
"
فروش
"
)
+
"
"
text
+=
reqs
[
i
].
count
+
"
"
text
+=
reqs
[
i
].
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
+
"
"
if
(
reqs
[
i
].
type
!==
'
variz
'
)
{
text
+=
'
با مبلغ
'
text
+=
'
'
text
+=
reqs
[
i
].
fee
text
+=
'
'
text
+=
reqs
[
i
].
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
text
+=
'
'
}
opts
.
reply_markup
.
inline_keyboard
.
push
([{
opts
.
reply_markup
.
inline_keyboard
.
push
([{
text
:
text
,
text
:
text
,
...
@@ -340,14 +408,23 @@ async function listRequest(bot, msg, reqs) {
...
@@ -340,14 +408,23 @@ async function listRequest(bot, msg, reqs) {
}
}
await
db
.
updateStatus
(
msg
,
constant
.
start
)
await
db
.
updateStatus
(
msg
,
constant
.
start
)
bot
.
sendMessage
(
typeof
msg
.
chat
!==
'
undefined
'
?
msg
.
chat
.
id
:
msg
.
message
.
chat
.
id
,
'
لطفا فیش مورد نظر را انتخاب کنید.
'
,
opts
)
bot
.
sendMessage
(
typeof
msg
.
chat
!==
'
undefined
'
?
msg
.
chat
.
id
:
msg
.
message
.
chat
.
id
,
print
,
opts
)
}
async
function
showDocument
(
bot
,
msg
,
req
)
{
let
d
=
await
bot
.
downloadFile
(
req
.
file_id
,
'
img
'
)
return
await
bot
.
sendPhoto
(
typeof
msg
.
chat
!==
'
undefined
'
?
msg
.
chat
.
id
:
msg
.
message
.
chat
.
id
,
d
)
}
}
async
function
showRequest
(
bot
,
msg
,
req
)
{
async
function
showRequest
(
bot
,
msg
,
req
)
{
let
text
=
"
فیش شماره
"
text
+=
req
.
id
text
+=
'
\n
'
let
text
=
''
if
(
req
.
type
!==
'
variz
'
)
{
text
+=
'
تعداد
'
text
+=
'
تعداد
'
text
+=
req
.
type
.
replace
(
"
sell
"
,
'
فروش
'
).
replace
(
"
buy
"
,
"
خرید
"
)
text
+=
req
.
type
.
replace
(
"
sell
"
,
'
فروش
'
).
replace
(
"
buy
"
,
"
خرید
"
)
text
+=
'
'
text
+=
'
'
...
@@ -361,12 +438,25 @@ async function showRequest(bot, msg, req) {
...
@@ -361,12 +438,25 @@ async function showRequest(bot, msg, req) {
text
+=
'
'
text
+=
'
'
text
+=
req
.
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
text
+=
req
.
toUnit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
text
+=
'
'
text
+=
'
'
}
else
{
text
+=
'
واریز مبلغ
'
text
+=
'
'
text
+=
req
.
count
text
+=
'
'
text
+=
req
.
unit
.
replace
(
'
toman
'
,
'
تومان
'
).
replace
(
'
dollar
'
,
'
دلار
'
).
replace
(
'
euro
'
,
'
یورو
'
).
replace
(
'
lir
'
,
'
لیر
'
).
replace
(
'
aed
'
,
'
درهم
'
)
text
+=
'
'
}
await
await
db
.
updateStatus
(
msg
,
constant
.
input3
)
await
await
db
.
updateStatus
(
msg
,
constant
.
input3
)
bot
.
sendMessage
(
typeof
msg
.
chat
!==
'
undefined
'
?
msg
.
chat
.
id
:
msg
.
message
.
chat
.
id
,
text
)
bot
.
sendMessage
(
typeof
msg
.
chat
!==
'
undefined
'
?
msg
.
chat
.
id
:
msg
.
message
.
chat
.
id
,
text
)
if
(
req
.
file_id
!==
null
&&
req
.
file_id
!==
''
)
await
showDocument
(
bot
,
msg
,
req
)
}
}
...
@@ -384,6 +474,7 @@ module.exports = {
...
@@ -384,6 +474,7 @@ module.exports = {
forwardCurrencyMessage
:
forwardCurrencyMessage
,
forwardCurrencyMessage
:
forwardCurrencyMessage
,
sendDocMessage
:
sendDocMessage
,
sendDocMessage
:
sendDocMessage
,
listRequest
:
listRequest
,
listRequest
:
listRequest
,
showRequest
:
showRequest
showRequest
:
showRequest
,
deleteMessage
:
deleteMessage
};
};
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