-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
52 lines (43 loc) · 1.79 KB
/
main.py
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
import discord
import requests
from discord.ext import commands, tasks
# Setup the bot
intents = discord.Intents.default()
intents.members = True
intents.presences = True
bot = commands.Bot(command_prefix='$', intents=intents, case_insensitive=True)
bot.remove_command('help')
@bot.event
async def on_ready():
f = open("past.log", "w")
print(f"╔═══════════════════════════════════════════════════")
print(f"╠Bot is ready")
print(f"╠IP Watcher")
print(f"╠By BoredManCodes")
print(f"╠Discord API Version: {discord.__version__}")
print(f"╚═══════════════════════════════════════════════════")
url = "https://ip4.seeip.org"
page = requests.get(url)
embed = discord.Embed(
title=f"The IP address has changed!",
description=f"The current IP address is {page.text}:25565",
colour=discord.Colour.blue()
)
await bot.get_channel(CHANNEL ID).send(embed=embed) # put your channel ID here
@tasks.loop(minutes=15) # every 15 minutes check if the IP changed
async def check():
url = "https://ip4.seeip.org"
page = requests.get(url)
with open("past.log", "r") as f:
data = f.read()
if not data == page.text: # if the old IP does not equal the current one
with open("past.log", "w") as f:
f.write(page.text)
embed = discord.Embed(
title=f"The IP address has changed!",
description=f"The current IP address is {page.text}:25565",
colour=discord.Colour.blue()
)
await bot.get_channel(786017749523628082).send(embed=embed)
check.start()
bot.run("TOKEN")