Skip to content

Commit a57f952

Browse files
committed
Add ability to check home IP address using bot
1 parent bb762a8 commit a57f952

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

misc/SerialCord/main.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SerialCord, serialize serial port from qemu into discord I/O
2+
import aiohttp
23
import pexpect
34
import discord
45
import sys
@@ -14,7 +15,7 @@ def __init__(self, **options):
1415
self.no_category = 'General'
1516

1617

17-
desc = 'SerialCord 2024'
18+
desc = 'SerialCord 2026'
1819
intents = discord.Intents.default()
1920
intents.message_content = True
2021
activity = discord.Game('KenOS Pre-Alpha')
@@ -39,6 +40,32 @@ async def on_ready():
3940
await tree.sync()
4041

4142

43+
@tree.command(description='Pokaż publiczny adres IP (tylko właściciel)')
44+
async def get_home_ip(interaction):
45+
if config.get('bot_owner_id') and interaction.user.id != config.get('bot_owner_id'):
46+
return await interaction.response.send_message(
47+
'❌ Ta komenda jest tylko dla właściciela bota.',
48+
ephemeral=True,
49+
)
50+
51+
try:
52+
async with aiohttp.ClientSession() as session:
53+
async with session.get('https://api.ipify.org') as r:
54+
public_ip = await r.text()
55+
except Exception as e:
56+
return await interaction.followup.send(
57+
f'❌ Nie udało się pobrać IP: {e}',
58+
ephemeral=True,
59+
)
60+
61+
try:
62+
await interaction.user.send(f"Publiczny adres piwnicy w Gutkowie to {public_ip}")
63+
except Exception as e:
64+
await interaction.followup.send(
65+
f'❌ Nie mogłem wysłać DM: {e}',
66+
ephemeral=True,
67+
)
68+
4269
@tree.command(description='Kenify input to SerialCord')
4370
async def kenify(interaction, msg: str):
4471
kenOS.sendline(msg[:8])

misc/SerialCord/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
discord.py==2.6.4
1+
discord.py==2.6.5
22
pexpect==4.9.0
3+
aiohttp==3.13.2

0 commit comments

Comments
 (0)