Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
marketParser
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
nazarf
marketParser
Commits
3fe0daba
Commit
3fe0daba
authored
May 17, 2021
by
nazarf
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add asset price to notify
parent
13b20f8f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
21 additions
and
10 deletions
+21
-10
notify.rb
app/models/notify.rb
+3
-1
show.html.haml
app/views/triggers/show.html.haml
+4
-2
20210517085301_add_price_to_notify.rb
db/migrate/20210517085301_add_price_to_notify.rb
+5
-0
schema.rb
db/schema.rb
+2
-1
atomic_market.rake
lib/tasks/atomic_market.rake
+6
-6
start_bot.rb
start_bot.rb
+1
-0
No files found.
app/models/notify.rb
View file @
3fe0daba
...
@@ -6,7 +6,9 @@ class Notify < ApplicationRecord
...
@@ -6,7 +6,9 @@ class Notify < ApplicationRecord
require
'telegram/bot'
require
'telegram/bot'
token
=
'1711433709:AAFn8Yczyc435Dz7aIDph2fptpGU0doRLhk'
token
=
'1711433709:AAFn8Yczyc435Dz7aIDph2fptpGU0doRLhk'
Telegram
::
Bot
::
Client
.
run
(
token
)
do
|
bot
|
Telegram
::
Bot
::
Client
.
run
(
token
)
do
|
bot
|
bot
.
api
.
sendMessage
(
chat_id:
"@MarketGrab"
,
text:
"collection:
#{
trigger
.
name
}
\n
rarity:
#{
trigger
.
rarity
}
\n
price:
#{
trigger
.
price
}
\n
#{
sale_link
}
"
)
# 396098026
# @MarketGrab
bot
.
api
.
sendMessage
(
chat_id:
"396098026"
,
text:
"collection:
#{
trigger
.
name
}
\n
rarity:
#{
trigger
.
rarity
}
\n
price:
#{
price
}
\n
#{
sale_link
}
"
)
end
end
end
end
...
...
app/views/triggers/show.html.haml
View file @
3fe0daba
...
@@ -31,9 +31,11 @@
...
@@ -31,9 +31,11 @@
%thead
%thead
%tr
%tr
%th
=
"name"
%th
=
"name"
%th
=
"price"
%th
Actions
%th
Actions
%tbody
%tbody
-
@trigger
.
notify
.
each
do
|
us
er
|
-
@trigger
.
notify
.
each
do
|
trigg
er
|
%tr
%tr
%td
=
link_to
user
.
sale_id
,
user
.
sale_link
,
target: :_blank
%td
=
link_to
trigger
.
sale_id
,
trigger
.
sale_link
,
target: :_blank
%td
=
trigger
.
price
.
present?
if
trigger
.
price
%td
%td
\ No newline at end of file
db/migrate/20210517085301_add_price_to_notify.rb
0 → 100644
View file @
3fe0daba
class
AddPriceToNotify
<
ActiveRecord
::
Migration
[
5.2
]
def
change
add_column
:notifies
,
:price
,
:string
end
end
db/schema.rb
View file @
3fe0daba
...
@@ -10,11 +10,12 @@
...
@@ -10,11 +10,12 @@
#
#
# It's strongly recommended that you check this file into your version control system.
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2021_05_1
5_14391
1
)
do
ActiveRecord
::
Schema
.
define
(
version:
2021_05_1
7_08530
1
)
do
create_table
"notifies"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
create_table
"notifies"
,
options:
"ENGINE=InnoDB DEFAULT CHARSET=utf8"
,
force: :cascade
do
|
t
|
t
.
string
"sale_id"
t
.
string
"sale_id"
t
.
bigint
"trigger_id"
t
.
bigint
"trigger_id"
t
.
string
"price"
t
.
index
[
"trigger_id"
],
name:
"index_notifies_on_trigger_id"
t
.
index
[
"trigger_id"
],
name:
"index_notifies_on_trigger_id"
end
end
...
...
lib/tasks/atomic_market.rake
View file @
3fe0daba
...
@@ -3,12 +3,12 @@ namespace :atomic_market do
...
@@ -3,12 +3,12 @@ namespace :atomic_market do
task
grep_sale: :environment
do
task
grep_sale: :environment
do
Trigger
.
enable
.
pluck
(
:collection_name
).
uniq
.
each
do
|
collection_name
|
Trigger
.
enable
.
pluck
(
:collection_name
).
uniq
.
each
do
|
collection_name
|
triggers
=
Trigger
.
find_by
(
collection_name:
collection_name
)
triggers
=
Trigger
.
find_by
(
collection_name:
collection_name
)
http
=
Curl
.
post
(
"http://wax.api.atomicassets.io/atomicmarket/v1/sales"
,
{
:collection_name
=>
triggers
.
collection_name
,
:order
=>
"desc"
,
:sort
=>
"created"
,
:symbol
=>
"WAX"
})
#
http = Curl.post("http://wax.api.atomicassets.io/atomicmarket/v1/sales", { :collection_name => triggers.collection_name, :order => "desc", :sort => "created", :symbol => "WAX" })
parsed
=
JSON
.
parse
(
http
.
body_str
)
#
parsed = JSON.parse(http.body_str)
#
file = open("test.json")
file
=
open
(
"test.json"
)
#
json = file.read
json
=
file
.
read
#
parsed = JSON.parse(json)
parsed
=
JSON
.
parse
(
json
)
parsed
[
"data"
].
each
do
|
shop
|
parsed
[
"data"
].
each
do
|
shop
|
name
=
shop
[
"assets"
][
0
][
"template"
][
"immutable_data"
][
"name"
]
name
=
shop
[
"assets"
][
0
][
"template"
][
"immutable_data"
][
"name"
]
...
@@ -22,7 +22,7 @@ namespace :atomic_market do
...
@@ -22,7 +22,7 @@ namespace :atomic_market do
if
trigger
.
rarity
==
rarity
if
trigger
.
rarity
==
rarity
if
trigger
.
price
.
to_i
>=
price
if
trigger
.
price
.
to_i
>=
price
if
Notify
.
find_by
(
sale_id:
sale_id
).
blank?
if
Notify
.
find_by
(
sale_id:
sale_id
).
blank?
Notify
.
create
(
sale_id:
sale_id
,
trigger:
trigger
)
Notify
.
create
(
sale_id:
sale_id
,
trigger:
trigger
,
price:
price
)
end
end
end
end
end
end
...
...
start_bot.rb
View file @
3fe0daba
...
@@ -5,6 +5,7 @@ Telegram::Bot::Client.run(token) do |bot|
...
@@ -5,6 +5,7 @@ Telegram::Bot::Client.run(token) do |bot|
case
message
.
text
case
message
.
text
when
'/start'
when
'/start'
bot
.
api
.
sendMessage
(
chat_id:
message
.
chat
.
id
,
text:
"Hello,
#{
message
.
from
.
first_name
}
"
)
bot
.
api
.
sendMessage
(
chat_id:
message
.
chat
.
id
,
text:
"Hello,
#{
message
.
from
.
first_name
}
"
)
p
message
.
chat
.
id
end
end
end
end
end
end
\ No newline at end of file
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