-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdiscordbot.rb
330 lines (279 loc) · 10.3 KB
/
discordbot.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
require 'nokogiri'
require 'discordrb'
require 'faraday'
require 'open-uri'
require 'rest-client'
file = File.read('config.json')
config = JSON.parse(file)
bot = Discordrb::Commands::CommandBot.new token: config['token'], client_id: config['client_id'], prefix: '!'
@tgwo,@dsm,@eflash,@kith = true,true,true,true
@agentList = ["Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20130331 Firefox/21.0","Mozilla/5.0 (Windows NT 6.2; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0","Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.93 Safari/537.36"]
@user_agent = @agentList.sample
bot.command :checkstock do |event, url|
sizearr,stockarr = [],[]
if url.include?('?variant')
url = url.split('?variant')[0]
end
@doc = Nokogiri::XML(open(url+".xml", 'User-Agent' => "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.854.0 Safari/535.2"))
@doc.xpath('//option1').each do |size|
size = size.text.to_s
sizearr << size
end
@doc.xpath('//inventory-quantity').each do |stock|
stock = stock.text.to_s
stockarr << stock
end
sizearr.zip(stockarr).each do |size, stock|
event.channel.send_embed() do |embed|
embed.colour = 0x808080
embed.add_field(name: "Size/Variant", value: size,inline: true)
embed.add_field(name: "Stock", value: stock, inline: true)
end
end
return
end
bot.command :proxy do |event|
response = Faraday.get "https://gimmeproxy.com/api/getProxy?country=US&maxCheckPeriod=1000"
proxyjson = JSON.parse(response.body)
event.user.pm("#{proxyjson['ipPort']}")
end
bot.command(:releases) do |event,searchmonth, searchday|
@doc = Nokogiri::HTML(open('http://www.solelinks.com/'))
datearr,solelinkarr,imgarr = [],[],[]
@doc.css('.srp-linked-content').each do |date|
date = date.text.to_s
datearr << date.downcase
end
@doc.css('.srp-post-thumbnail').each do |img|
img = img['src']
imgarr << img
end
@doc.css('.postmoreinfolink').each do |href|
solelink = href['href']
solelinkarr << solelink
end
datearr.zip(solelinkarr,imgarr).uniq.each do |date,solelink,img|
searchdate = searchmonth+" "+searchday
if date == searchdate
itemname = solelink.split('.com/')[1].tr("-"," ").split('/')[0]
event.channel.send_embed() do |embed|
embed.colour = 0x808080
embed.image = Discordrb::Webhooks::EmbedImage.new(url: img)
embed.add_field(name: "Sneaker", value: itemname)
embed.add_field(name: "Link", value: solelink)
end
end
end
end
bot.command(:goodwill) do |event, shoeurl|
@doc = Nokogiri::HTML(open(shoeurl))
form = @doc.xpath('//@action')
event.channel.send_embed() do |embed|
embed.colour = 0x808080
embed.title = "ATC Form"
embed.description = form[0]
end
attributearr,sizearr = [],[]
@doc.css('.attribute-item').each do |attri|
attributearr << attri['data-value']
sizearr << attri.text
end
attributearr.zip(sizearr).each do |attri, size|
event.channel.send_embed() do |embed|
embed.colour = 0x808080
embed.add_field(name: "Size", value: size, inline: true)
embed.add_field(name: "Attribute", value: attri, inline:true)
end
end
return
end
bot.command(:usage) do |event|
event.channel.send_embed do |embed|
embed.title = "Source"
embed.colour = 0x808080
embed.description = "[Bot repository](https://github.com/threebarber)"
embed.author = Discordrb::Webhooks::EmbedAuthor.new(name: "threebarber", url: "https://github.com/threebarber", icon_url: "https://avatars0.githubusercontent.com/u/19513830?v=4&s=460")
embed.add_field(name: "Commands", value: "!checkstock <shopify item url>\n Retrieves stock for each size\n\n !proxy\n DM's the user a (usually) working proxy\n\n !releases <date>\nReturns a name/image of shoes matching user-supplied release date (ie aug 05)\n\n!goodwill <shoe url>\n Returns item size with corresponding data value for backdooring")
embed.add_field(name: "Commands (Cont.)", value: "!monitortgwo - monitor thegoodwillout !stoptgwo - stop monitoring thegoodwillout\n!monitordsm - start monitoring dsm - !stopdsm - stop monitoring dsm\n!monitoreflash - monitor dsm eflash - !stopeflash - stop monitoring eflash\n!monitorkith - monitor KITH - !stopkith - stop monitoring KITH")
end
end
bot.command(:monitortgwo) do |event|
monitorTGWO(event)
end
bot.command(:monitordsm) do |event|
monitorDSM(event)
end
bot.command(:stopdsm) do |event|
@dsm = false
event.channel.send_embed do |embed|
embed.title = "Stopping dsm monitor"
embed.colour = 0x808080
end
end
bot.command(:stoptgwo) do |event|
@tgwo = false
event.channel.send_embed do |embed|
embed.title = "Stopping thegoodwillout monitor"
embed.colour = 0x808080
end
end
bot.command(:monitoreflash) do |event|
monitorEFLASH(event)
end
bot.command(:stopeflash) do |event|
@eflash = false
event.channel.send_embed do |embed|
embed.title = "Stopping eflash monitor..."
embed.colour = 0x808080
end
end
bot.command(:monitorkith) do |event|
monitorKITH(event)
end
bot.command(:stopkith) do |event|
@kith = false
event.channel.send_embed do |embed|
embed.title = "Stopping KITH monitor..."
embed.colour = 0x808080
end
end
def monitorTGWO(event)
event.channel.send_embed do |embed|
embed.title = "Starting TGWO Monitor..."
embed.colour = 0x808080
end
@tgwo = true
linklist,newlinklist = [],[]
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.854.0 Safari/535.2"
doc = Nokogiri::XML(open("https://www.thegoodwillout.com/media/sitemap/en/sitemap.xml",'User-Agent' => user_agent))
doc.css("url loc").each do |loc|
link = loc.text
linklist << link
end
while true
break if @tgwo == false
doc = Nokogiri::XML(open("https://www.thegoodwillout.com/media/sitemap/en/sitemap.xml",'User-Agent' => user_agent))
doc.css("url loc").each do |loc|
newlink = loc.text
newlinklist << newlink
end
newlinklist.each do |link|
if linklist.include? link
else
puts "new link: "+link
linklist << link
event.channel.send_embed do |embed|
embed.title = "TGWO"
embed.colour = 0x808080
embed.description = "NEW ITEM"
embed.add_field(name: "Link", value: link)
end
end
end
end
end
def monitorDSM(event)
event.channel.send_embed do |embed|
embed.title = "Starting DSM Monitor..."
embed.colour = 0x808080
end
@dsm = true
linklist,newlinklist = [],[]
doc = Nokogiri::XML(open("http://shop.doverstreetmarket.com/us/sitemap.xml",'User-Agent' => @user_agent))
doc.css("url loc").each do |loc|
link = loc.text
linklist << link
end
while true
break if @dsm == false
doc = Nokogiri::XML(open("http://shop.doverstreetmarket.com/us/sitemap.xml",'User-Agent' => @user_agent))
doc.css("url loc").each do |loc|
newlink = loc.text
newlinklist << newlink
end
newlinklist.each do |link|
if linklist.include? link
else
puts "new link: "+link
linklist << link
event.channel.send_embed do |embed|
embed.title = "DSM"
embed.colour = 0x808080
embed.description = "NEW ITEM"
embed.add_field(name: "Link", value: link)
end
end
end
end
end
def monitorEFLASH(event)
event.channel.send_embed do |embed|
embed.title = "Starting EFLASH Monitor..."
embed.colour = 0x808080
end
@eflash = true
linklist,newlinklist = [],[]
doc = Nokogiri::XML(open("https://eflash.doverstreetmarket.com/sitemap_products_1.xml",'User-Agent' => @user_agent))
doc.css("url loc").each do |loc|
link = loc.text
linklist << link
end
while true
sleep(30)
break if @eflash == false
doc = Nokogiri::XML(open("https://eflash.doverstreetmarket.com/sitemap_products_1.xml",'User-Agent' => @user_agent))
doc.css("url loc").each do |loc|
newlink = loc.text
newlinklist << newlink
end
newlinklist.each do |link|
if linklist.include? link
else
puts "new link: "+link
linklist << link
event.channel.send_embed do |embed|
embed.title = "DSM E-FLASH"
embed.colour = 0x808080
embed.description = "NEW ITEM"
embed.add_field(name: "Link", value: link)
end
end
end
end
end
def monitorKITH(event)
event.channel.send_embed do |embed|
embed.title = "Starting KITH Monitor..."
embed.colour = 0x808080
end
@kith = true
linklist,newlinklist = [],[]
doc = Nokogiri::XML(open("https://kith.com/sitemap_products_1.xml",'User-Agent' => @user_agent))
doc.css("url loc").each do |loc|
link = loc.text
linklist << link
end
while true
break if @kith == false
sleep(30)
doc = Nokogiri::XML(open("https://kith.com/sitemap_products_1.xml",'User-Agent' => @user_agent))
doc.css("url loc").each do |loc|
newlink = loc.text
newlinklist << newlink
end
newlinklist.each do |link|
if linklist.include? link
else
puts "new link: "+link
linklist << link
event.channel.send_embed do |embed|
embed.title = "DSM E-FLASH"
embed.colour = 0x808080
embed.description = "NEW ITEM"
embed.add_field(name: "Link", value: link)
end
end
end
end
end
bot.run