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
9f947926
Commit
9f947926
authored
Mar 19, 2019
by
Ahmad Nemati
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
init
parent
650dcdc5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
51 additions
and
13 deletions
+51
-13
app.js
app.js
+8
-3
db.js
db.js
+31
-6
message.js
message.js
+12
-4
No files found.
app.js
View file @
9f947926
...
...
@@ -12,11 +12,12 @@ const bot = new TelegramBot(token, {polling: true});
bot
.
on
(
'
message
'
,
(
msg
)
=>
{
console
.
log
(
msg
)
console
.
log
(
msg
)
processMessage
(
msg
)
});
async
function
processMessage
(
msg
)
{
await
isAdmin
(
msg
)
...
...
@@ -47,6 +48,7 @@ async function processCallback(msg) {
else
if
(
msg
.
data
.
startsWith
(
"
buy_
"
))
showCurrency
(
msg
,
'
buy
'
)
else
if
(
msg
.
data
.
startsWith
(
"
sell_
"
))
showCurrency
(
msg
,
'
sell
'
)
else
if
(
msg
.
data
.
startsWith
(
"
variz_
"
))
showCurrency
(
msg
,
'
variz
'
)
else
if
(
msg
.
data
.
startsWith
(
"
daryaft_
"
))
showCurrency
(
msg
,
'
daryaft
'
)
else
if
(
msg
.
data
.
startsWith
(
"
toman_
"
))
showCount
(
msg
,
'
toman
'
)
else
if
(
msg
.
data
.
startsWith
(
"
dollar_
"
))
showCount
(
msg
,
'
dollar
'
)
else
if
(
msg
.
data
.
startsWith
(
"
euro_
"
))
showCount
(
msg
,
'
euro
'
)
...
...
@@ -104,6 +106,9 @@ async function showCurrency(msg, type) {
case
'
variz
'
:
msg
.
data
=
msg
.
data
.
replace
(
"
variz_
"
,
""
)
break
case
'
daryaft
'
:
msg
.
data
=
msg
.
data
.
replace
(
"
daryaft_
"
,
""
)
break
}
...
...
@@ -142,7 +147,7 @@ async function showCount(msg, unit) {
admin
.
data
.
vahed
=
unit
await
db
.
updateData
(
msg
,
JSON
.
stringify
(
admin
.
data
))
message
.
showCountMessage
(
bot
,
msg
,
type
===
'
variz
'
)
message
.
showCountMessage
(
bot
,
msg
,
type
===
'
variz
'
||
type
===
'
daryaft
'
)
}
async
function
elseMessage
(
msg
)
{
...
...
@@ -171,7 +176,7 @@ async function input1(msg) {
admin
.
data
=
JSON
.
stringify
(
admin
.
data
)
await
db
.
updateData
(
msg
,
admin
.
data
)
if
(
type
===
'
variz
'
)
if
(
type
===
'
variz
'
||
type
===
'
daryaft
'
)
message
.
sendDocMessage
(
bot
,
msg
)
else
message
.
showFeeMessage
(
bot
,
msg
)
...
...
db.js
View file @
9f947926
...
...
@@ -83,28 +83,53 @@ async function createRequest(data) {
}
function
runCurrency
(
data
,
user
)
{
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
.
action
===
'
daryaft
'
)
{
switch
(
data
.
vahed
)
{
case
'
toman
'
:
user
.
toman_balance
=
parseFloat
(
user
.
toman_balance
)
+
(
-
1
*
parseFloat
(
data
.
count
))
user
.
toman_balance
=
parseFloat
(
user
.
toman_balance
)
+
(
parseFloat
(
data
.
count
))
break
case
'
dollar
'
:
user
.
dollar_balance
=
user
.
dollar_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
user
.
dollar_balance
=
user
.
dollar_balance
+
(
parseFloat
(
data
.
count
))
break
case
'
euro
'
:
user
.
euro_balance
=
user
.
euro_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
user
.
euro_balance
=
user
.
euro_balance
+
(
parseFloat
(
data
.
count
))
break
case
'
lir
'
:
user
.
lir_balance
=
user
.
lir_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
user
.
lir_balance
=
user
.
lir_balance
+
(
parseFloat
(
data
.
count
))
break
case
'
aed
'
:
user
.
aed_balance
=
user
.
aed_balance
+
(
-
1
*
parseFloat
(
data
.
count
))
user
.
aed_balance
=
user
.
aed_balance
+
(
parseFloat
(
data
.
count
))
break
...
...
message.js
View file @
9f947926
...
...
@@ -244,6 +244,14 @@ async function userSubmitRequest(bot, msg, user) {
callback_data
:
'
variz_
'
+
user
.
id
}
],
[
{
text
:
'
دریافت
'
,
callback_data
:
'
daryaft_
'
+
user
.
id
}
]
...
...
@@ -266,7 +274,7 @@ async function showCountMessage(bot, msg, variz) {
};
await
db
.
updateStatus
(
msg
,
constant
.
input1
)
if
(
variz
)
bot
.
editMessageText
(
'
لطفا مبلغ فیش واریزی را وارد نمایید.
'
,
opts
)
bot
.
editMessageText
(
'
لطفا مبلغ فیش واریزی
یا دریافتی
را وارد نمایید.
'
,
opts
)
else
bot
.
editMessageText
(
'
لطفا مقدار مورد نیاز را وارد نمایید.
'
,
opts
)
...
...
@@ -387,10 +395,10 @@ async function listRequest(bot, msg, reqs) {
for
(
let
i
=
0
;
i
<
reqs
.
length
;
i
++
)
{
let
text
=
''
text
+=
reqs
[
i
].
type
.
replace
(
"
variz
"
,
"
واریز
"
).
replace
(
"
buy
"
,
"
خرید
"
).
replace
(
"
sell
"
,
"
فروش
"
)
+
"
"
text
+=
reqs
[
i
].
type
.
replace
(
"
variz
"
,
"
واریز
"
).
replace
(
"
daryaft
"
,
"
دریافت
"
).
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
'
)
{
if
(
reqs
[
i
].
type
!==
'
variz
'
&&
reqs
[
i
].
type
!==
'
daryaft
'
)
{
text
+=
'
با مبلغ
'
text
+=
'
'
text
+=
reqs
[
i
].
fee
...
...
@@ -422,7 +430,7 @@ async function showRequest(bot, msg, req) {
let
text
=
''
if
(
req
.
type
!==
'
variz
'
)
{
if
(
req
.
type
!==
'
variz
'
&&
req
.
type
!==
'
daryaft
'
)
{
text
+=
'
تعداد
'
text
+=
req
.
type
.
replace
(
"
sell
"
,
'
فروش
'
).
replace
(
"
buy
"
,
"
خرید
"
)
...
...
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