Skip to content

Commit bf5703a

Browse files
authored
(❁´◡`❁)
1 parent bb962d1 commit bf5703a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

bot.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import discord
2+
import requests
3+
import re
4+
5+
client = discord.Client(intents=discord.Intents.all())
6+
CHANNEL_ID =
7+
8+
def get_geo_info(ip):
9+
response = requests.get(f"https://ipapi.co/{ip}/json/")
10+
data = response.json()
11+
return data
12+
@client.event
13+
async def on_ready():
14+
print('=> Logged in as {0.user}'.format(client))
15+
# Set the bot status
16+
activity = discord.Game(name="Made With 🤍 By IDA")
17+
await client.change_presence(activity=activity)
18+
19+
@client.event
20+
async def on_message(message):
21+
if message.channel.id == CHANNEL_ID:
22+
match = re.match(r"^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$", message.content)
23+
if match:
24+
ip = match.group()
25+
geo_info = get_geo_info(ip)
26+
embed = discord.Embed(title="Geo Info", color=0x00ff00)
27+
embed.add_field(name="IP Address", value=ip)
28+
embed.add_field(name="Country", value=geo_info["country_name"])
29+
embed.add_field(name="Region", value=geo_info["region"])
30+
embed.add_field(name="City", value=geo_info["city"])
31+
embed.add_field(name="Latitude", value=geo_info["latitude"])
32+
embed.add_field(name="Longitude", value=geo_info["longitude"])
33+
embed.add_field(name="Org", value=geo_info["org"])
34+
embed.add_field(name="Requested By", value=f"{message.author.name}#{message.author.discriminator}")
35+
await message.channel.send(embed=embed)
36+
await message.delete()
37+
38+
client.run("")

0 commit comments

Comments
 (0)