forked from primitt/duino-stats-mini
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
802 lines (723 loc) · 32.7 KB
/
main.py
File metadata and controls
802 lines (723 loc) · 32.7 KB
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
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
# python3 -m pip install requirments.txt
import socketserver
import http.server
from PIL import Image, ImageDraw, ImageFont
import os
from dotenv import load_dotenv
import discord
import requests
import random
import json
from datetime import datetime
import aiohttp
import asyncio
import traceback
from time import sleep
from io import BytesIO
from datetime import datetime
import base64
load_dotenv()
client = discord.Client()
EM_TRUE = "<:true:877164045248102471>"
EM_FALSE = "<:false:877164045176819782>"
TOKEN = os.getenv('TOKEN')
PREFIX = "+"
REPLIES_URI = 'utils/replies.json'
USER_API = "https://server.duinocoin.com/users/"
PRICE_API = "https://server.duinocoin.com/api.json"
NODES = {
":floppy_disk: Master Server": {
"ip": "51.15.127.80",
"port": 2812,
"status": ":question: Unknown"
},
":heartpulse: PulsePool": {
"ip": "149.91.88.18",
"port": 1224,
"status": ":question: Unknown"
},
":star: StarPool": {
"ip": "51.158.182.90",
"port": 6006,
"status": ":question: Unknown"
},
":snowflake: BeyondPool": {
"ip": "beyondpool.io",
"port": 6000,
"status": ":question: Unknown"
},
":broken_heart: SvkoPool": {
"ip": "5.230.69.132",
"port": 6000,
"status": ":question: Unknown"
},
":heavy_plus_sign: NullPool": {
"ip": "5.230.70.190",
"port": 6000,
"status": ":question: Unknown"
}
}
headers = {
"Authorization": "Client-ID " + os.getenv('IMGUR_TOKEN'),
}
with open(REPLIES_URI, "r") as replies_file:
duino_stats_replies = json.load(replies_file)
duino_stats_pings = [
"hey",
"stop ignoring me",
"plz respond :(",
"hi",
"!!!!",
"task for you"
]
cards = [
"utils/card_1.png",
"utils/card_2.png"
]
def generate_card(nick: str, duco: float, discord_nick: str):
try:
image = Image.open(random.choice(cards))
draw = ImageDraw.Draw(image)
font = ImageFont.truetype('utils/Lato-Black.ttf', size=26)
font2 = ImageFont.truetype('utils/Lato-Regular.ttf', size=20)
font3 = ImageFont.truetype('utils/Lato-Regular.ttf', size=18)
color = "#0a0a0a"
nick = str(nick)+"'s balance"
draw.text((155, 84), str(nick), fill=color, font=font2)
duco_str = str(round(duco, 3)) + " DUCO"
draw.text((155, 106), duco_str, fill=color, font=font)
duco_str = str(round(duco, 3)) + " DUCO"
draw.text((155, 138), str(discord_nick), fill=color, font=font3)
# image.save('utils/out.png')
buffered = BytesIO()
image.save(buffered, format="PNG")
img_str = base64.b64encode(buffered.getvalue())
now = datetime.now()
data = {'image': img_str, 'title': f"{nick}'s balance {now}"}
r = requests.post("https://api.imgur.com/3/image", data=data, headers=headers).json()["data"]
print(r["link"])
return r["link"]
except Exception as e:
print(e)
return None
def prefix(symbol: str, value: float, accuracy=2):
"""
Input: symbol to add, value
Output rounded value with scientific prefix as string
"""
if value >= 900000000:
prefix = " G"
value = value / 1000000000
elif value >= 900000:
prefix = " M"
value = value / 1000000
elif value >= 900:
prefix = " k"
value = value / 1000
else:
prefix = " "
return (
str(round(value, accuracy))
+ str(prefix)
+ str(symbol))
@client.event
async def on_ready():
print("Logged in as {0.user}".format(client))
await client.change_presence(
activity=discord.Game(
name="with your duinos - " + PREFIX + "help"))
@client.event
async def on_message(message):
mention = f'<@!{client.user.id}>'
help_embed = discord.Embed(
title="List of available commands",
color=discord.Color.gold(),
timestamp=datetime.utcnow())
help_embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
help_embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
help_embed.set_thumbnail(
url=client.user.avatar_url)
help_embed.add_field(
name="General",
value="""\
`{p}balance <DUCO username>` - Get user balance
`{p}price` - Show current DUCO prices
`{p}help` - Show this help message
`{p}mcip` - Show DuinoCraft IP
`{p}mc-survival` - Shows online people in the Survival mc server
`{p}mc-skyblock` - Shows online people in the SkyBlock mc server
`{p}profile` - Show info about your profile
`{p}server` - Show mining nodes status
`{p}invite` - Invite Duino Stats Mini to your server
`{p}about` - Show info about the bot
`{p}statistics` - Show network stats
""".replace("{p}", PREFIX),
inline=False
)
help_embed.add_field(
name="Admin",
value="""\
`{p}say <tosay>` - Make the bot say something
""".replace("{p}", PREFIX),
inline=False)
if message.guild.id == 677615191793467402:
if random.randint(0, 500) == 77:
with message.channel.typing():
rand_ping = random.choice(duino_stats_pings)
await message.channel.send(
"<@!691404890290913280> "
+ rand_ping)
if message.author == client.user:
return
if mention in message.content:
with message.channel.typing():
response = random.choice(duino_stats_replies)
await message.channel.send(
message.author.mention
+ ", "
+ response)
if message.content.startswith(PREFIX):
command = message.content.strip(PREFIX).split(" ")
# adding the people printing
# Planification
"""
It needs 4 phases:
- contact w the api (retrieve the json w requests)
- test req status (test if it reached the API)
- parse the json (inside players index)
- show the info w an embed
"""
if command[0] == "mc-survival":
with message.channel.typing():
survival_url = "https://api.mcsrvstat.us/2/survival.duinocraft.com"
request = requests.get(survival_url)
status = request.status_code
if status == 200:
print("Status: "+str(status))
else:
raise Exception("Request to API with status: " + status)
# parse json
data = request.text
json_data = json.loads(data)
online_people = json_data['players']
online_amount = online_people["online"]
if online_amount > 0:
players = online_people["list"]
counter = 1
embed = discord.Embed(
title="Online people in Survival Server.",
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
embed.add_field(
name="Online players amount",
value=str(online_amount),
inline=False)
for player in players:
embed.add_field(
name="Players List",
value=str(str(counter)
+ ": "
+ player),
inline=False)
counter += 1
await message.channel.send(embed=embed)
else:
embed = discord.Embed(
title="Online people in Survival Server.",
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
embed.add_field(
name="There are no players online",
value="Players: " + str(online_amount),
inline=False)
await message.channel.send(embed=embed)
if command[0] == "mc-skyblock":
with message.channel.typing():
skyblock_url = "https://api.mcsrvstat.us/2/skyblock.duinocraft.com"
request = requests.get(skyblock_url)
status = request.status_code
if status == 200:
print("Status: "+str(status))
else:
raise Exception("Request to API with status: " + status)
# parse json
data = request.text
json_data = json.loads(data)
online_people = json_data['players']
online_amount = online_people["online"]
if online_amount > 0:
players = online_people["list"]
counter = 1
embed = discord.Embed(
title="Online people in SkyBlock Server.",
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
embed.add_field(
name="Online players amount",
value=str(online_amount),
inline=False)
for player in players:
embed.add_field(
name="Players List",
value=str(str(counter)
+ ": "
+ player),
inline=False)
counter += 1
await message.channel.send(embed=embed)
else:
embed = discord.Embed(
title="Online people in Survival Server.",
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
embed.add_field(
name="There are no players online",
value="Players: " + str(online_amount),
inline=False)
await message.channel.send(embed=embed)
if command[0] == "say":
with message.channel.typing():
if message.author.guild_permissions.administrator:
command[0] = ""
await message.delete()
await message.channel.send(" ".join(command))
else:
await message.channel.send(
":no_entry: You dont't have the permission to do that!")
if (command[0] == "balance"
or command[0] == "bal"
or command[0] == "b"):
with message.channel.typing():
try:
_ = command[1]
try:
async with aiohttp.ClientSession() as session:
async with session.get(USER_API
+ command[1]) as resp:
response = json.loads(await resp.text())
if not response["success"]:
await message.channel.send("This user doesn't exist")
else:
balance = float(
response["result"]["balance"]["balance"])
miners_a = response["result"]["miners"]
verified = response["result"]["balance"]["verified"]
created = response["result"]["balance"]["created"]
import traceback
try:
miners = {}
for miner in miners_a:
miner_wid = miner["wd"]
if not miner_wid:
miner_wid = random.randint(0, 2811)
miner_h = miner["hashrate"]
miner_r = miner["rejected"]
miner_a = miner["accepted"]
if not miner_wid in miners:
miners[miner_wid] = miner
miners[miner_wid]["threads"] = 1
continue
elif miner_wid in miners:
miners[miner_wid]["hashrate"] += miner_h
miners[miner_wid]["rejected"] += miner_r
miners[miner_wid]["accepted"] += miner_a
miners[miner_wid]["threads"] += 1
continue
except Exception:
print(traceback.format_exc())
try:
async with aiohttp.ClientSession() as session:
async with session.get(PRICE_API) as resp:
response_price = json.loads(
await resp.text())
price = response_price["Duco price"]
balance_in_usd = price * balance
embed = discord.Embed(
title=str(command[1]+"'s Duino-Coin account"),
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
embed.add_field(
name="<:duco:876588980630618152> Balance",
value=str(balance)
+ " DUCO"
+ " ($"
+ str(round(balance_in_usd, 4))
+ ")",
inline=False)
embed.add_field(
name=":question: Verified account",
value=str(verified).capitalize(),
inline=True)
embed.add_field(
name=":calendar: Created",
value=str(created).capitalize(),
inline=True)
total_hashrate = 0
if not miners:
miner_str = "No miners running on this account"
else:
miner_str = ""
i = 0
for miner in miners:
total_hashrate += miners[miner]["hashrate"]
if miners[miner]["identifier"] != "None":
miner_str += (
f"**{miners[miner]['identifier']}**"
+ f" ({miners[miner]['software']})")
else:
miner_str += miners[miner]["software"]
miner_str += (
" - **"
+ str(int(miners[miner]["accepted"]))
+ "/"
+ str(int(miners[miner]["accepted"]) +
int(miners[miner]["rejected"]))
+ "** acc. shares, **"
+ str(prefix("H/s", int(miners[miner]["hashrate"])))
+ "**")
if miners[miner]["threads"] > 1:
miner_str += f" ({miners[miner]['threads']} threads)"
miner_str += "\n"
i += 1
if i >= 10:
miner_str += ("and "
+ str(len(miners)-i)
+ " more miners...")
break
embed.add_field(
name=":pick: Miners ("
+ str(len(miners))
+ ") - "
+ str(prefix("H/s", total_hashrate))
+ " total",
value=miner_str,
inline=False)
try:
embed.set_image(
url=generate_card(command[1], balance, message.author.display_name))
except:
pass
await message.channel.send(embed=embed)
except Exception as e:
await message.channel.send(
"`ERROR` Can't fetch user data: "
+ str(traceback.format_exc()))
except Exception as e:
await message.channel.send(
"`ERROR` Can't fetch the balances: "
+ str(e))
except IndexError:
await message.channel.send(
"Provide a username first (e.g. {}bal revox)"
.format(PREFIX))
if command[0] == "price":
with message.channel.typing():
async with aiohttp.ClientSession() as session:
async with session.get(PRICE_API) as resp:
response_price = json.loads(
await resp.text())
price_xmg = float(response_price["Duco price"])
price_bch = float(response_price["Duco price BCH"])
price_trx = float(response_price["Duco price TRX"])
price_nano = float(response_price["Duco price NANO"])
price_xrp = float(response_price["Duco price XRP"])
price_dgb = float(response_price["Duco price DGB"])
price_fjc = float(response_price["Duco price FJC"])
price_justswap = float(response_price["Duco JustSwap price"])
price_pancake = float(response_price["Duco PancakeSwap price"])
price_nodes = float(response_price["Duco Node-S price"])
embed = discord.Embed(
description=("Please keep in mind that price "
+ "on the chart is updated every 1 day"),
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
embed.add_field(
name="<:magi:876963168218394644> DUCO Exchange (XMG)",
value="$"+str(round(price_xmg, 6)),
inline=True)
embed.add_field(
name="<:bitcoincash:876963784491671622> DUCO Exchange (BCH)",
value="$"+str(round(price_bch, 6)),
inline=True)
embed.add_field(
name="<:tron:876962726000349204> DUCO Exchange (TRX)",
value="$"+str(round(price_trx, 6)),
inline=True)
embed.add_field(
name="<:nano:876962697730752552> DUCO Exchange (NANO)",
value="$"+str(round(price_nano, 6)),
inline=True)
embed.add_field(
name="<:digibyte:876962596270510120> DUCO Exchange (DGB)",
value="$"+str(round(price_dgb, 6)),
inline=True)
embed.add_field(
name="<:ripple:876962797882327110> DUCO Exchange (XRP)",
value="$"+str(round(price_xrp, 6)),
inline=True)
embed.add_field(
name="<:fuji:876962642370134097> DUCO Exchange (FJC)",
value="$"+str(round(price_fjc, 6)),
inline=True)
embed.add_field(
name=":currency_exchange: Node-S Exchange",
value="$"+str(round(price_nodes, 6)),
inline=True)
embed.add_field(
name=":white_flower: JustSwap",
value="$"+str(round(price_justswap, 6)),
inline=True)
embed.add_field(
name=":pancakes: PancakeSwap",
value="$"+str(round(price_pancake, 6)),
inline=True)
embed.add_field(
name=":person_standing: otc-trading",
value="[Duino-Coin Discord](https://discord.gg/duinocoin)",
inline=True)
embed.set_image(url="https://server.duinocoin.com/prices.png")
await message.channel.send(embed=embed)
if (command[0] == "stats"
or command[0] == "statistics"):
with message.channel.typing():
async with aiohttp.ClientSession() as session:
async with session.get(PRICE_API) as resp:
response = json.loads(
await resp.text())
total_hashrate = response["Pool hashrate"]
users = str(response["Registered users"])
net_wattage = response["Net energy usage"]
difficulty = str(response["Current difficulty"])
circulation = str(round(response["All-time mined DUCO"]))
duco_price = "$" + str(response["Duco price"])
market_cap = "$" + str(
round(response["Duco price"] *
response["All-time mined DUCO"], 2))
embed = discord.Embed(
title="Duino-Coin Statistics",
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
embed.add_field(
name=":pick: Net hashrate",
value=total_hashrate,
inline=True)
embed.add_field(
name=":evergreen_tree: Net energy usage",
value=net_wattage,
inline=True)
embed.add_field(
name=":people_holding_hands: Registered users",
value=users,
inline=True)
embed.add_field(
name=":gear: Net difficulty",
value=difficulty,
inline=True)
embed.add_field(
name=":coin: All mined DUCO",
value=circulation,
inline=True)
embed.add_field(
name=":moneybag: DUCO market cap",
value=market_cap,
inline=True)
embed.add_field(
name="<:duco:876588980630618152> DUCO price",
value=duco_price,
inline=True)
embed.add_field(
name="More stats",
value="[Duino-Coin Explorer](https://explorer.duinocoin.com/)",
inline=True)
await message.channel.send(embed=embed)
if command[0] == "help":
with message.channel.typing():
await message.channel.send(embed=help_embed)
if command[0] == "p":
with message.channel.typing():
created = message.author.created_at
if message.author.guild_permissions.administrator:
admin = "Yes"
else:
admin = "No"
embed = discord.Embed(
title=message.author.display_name+"'s profile",
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
embed.set_thumbnail(
url=message.author.avatar_url)
embed.add_field(
name="User",
value=message.author,
inline=False)
embed.add_field(
name="ID",
value=message.author.id,
inline=False)
embed.add_field(
name="Admin",
value=admin,
inline=False)
embed.add_field(
name="Account creation date",
value=str(created)[:-7],
inline=False)
await message.channel.send(embed=embed)
if command[0] == "mcip":
with message.channel.typing():
embed = discord.Embed(
title="DuinoCraft",
description=("Server version: **Minecraft 1.16-1.17.1**\n"
+ "Survival: **survival.duinocraft.com** \n"
+ "Skyblock: **skyblock.duinocraft.com** \n"
+ "Earn Duino-Coin just by playing!"),
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
await message.channel.send(embed=embed)
if command[0] == "invite":
with message.channel.typing():
embed = discord.Embed(
title="Invite Duino Stats Mini",
description=(
"[Click this text to add this bot to your server]"
+ "(https://discord.com/api/oauth2/authorize?client_id="
+ "876506340112076801&permissions=257701570624&scope=bot)"),
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
await message.channel.send(embed=embed)
if command[0] == "about":
with message.channel.typing():
in_servers = str(len(client.guilds))
embed = discord.Embed(
title="Duino Stats Mini",
description=(
"An official, public, stripped down version of"
+ " [**Duino Stats**]"
+ "(https://github.com/Bilaboz/duino-stats)"
+ " found on the [**Official Duino-Coin Discord**]"
+ "(https://discord.gg/duinocoin).\n\n"
+ "Created by [**primitt**](https://github.com/primitt)"
+ " and [**revox**](https://github.com/revoxhere)"
+ " from the **Duino** team\n"
+ "Hosted on a **Raspberry Pi 4**\n"
+ "Serving **" + in_servers + " servers**\n"
+ "This bot is open-source. You can improve it [here]"
+ "(https://github.com/primitt/duino-stats-mini/)"),
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
await message.channel.send(embed=embed)
if (command[0] == "server"
or command[0] == "servers"
or command[0] == "nodes"):
with message.channel.typing():
embed = discord.Embed(
title="Please wait",
description=("Pinging **Duino-Coin** services..."),
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
msg = await message.channel.send(embed=embed)
embed = discord.Embed(
title="Ping results",
color=discord.Color.gold(),
timestamp=datetime.utcnow())
embed.set_author(
name=message.author.display_name,
icon_url=message.author.avatar_url)
embed.set_footer(
text=client.user.name,
icon_url=client.user.avatar_url)
for node in NODES:
from socket import socket
s = socket()
try:
s.settimeout(1)
s.connect((NODES[node]["ip"], NODES[node]["port"]))
ver = s.recv(3)
if float(ver):
NODES[node]["status"] = EM_TRUE + " Operational"
else:
NODES[node]["status"] = EM_TRUE + " Offline"
except Exception:
NODES[node]["status"] = EM_FALSE + " Timeout"
embed.add_field(
name=node,
value=NODES[node]["status"],
inline=True)
await msg.edit(embed=embed)
client.run(TOKEN)