This repository has been archived by the owner on May 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main
executable file
·57 lines (49 loc) · 1.54 KB
/
main
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
#!/usr/bin/python3
import discord
import asyncio
import os
import polybot
## Initialize interfaces
client=polybot.Bot()
## Define event triggers
@client.event
async def on_ready():
client.logger.info("Logged in as:\n\t%s\n\t%s"%(client.user.name,client.user.id))
@client.event
async def on_member_join(member):
server = member.server
fmt = 'Welcome {0.mention} to {1.name}!'
await client.send_message(server, fmt.format(member,server))
@client.event
async def on_message(message):
await client.message_handler(message)
## Define background task
async def check_amadeus_down():
await client.wait_until_ready()
AmadeusHome=None
BirchUser=None
for server in client.servers: # find shruggiechat server
if server.name.startswith("¯\\_(") and server.name.endswith(")_/¯"):
AmadeusHome=server
break
if not AmadeusHome is None: # if found, grab users from member list
BirchUser=AmadeusHome.get_member_named("Nullspeaker#3390")
AmadeusUser=AmadeusHome.get_member_named("Amadeus#7338")
adj=0
while not client.is_closed: # loop and check if amadeus bot is ded
if(str(AmadeusUser.status)=="offline"):
await client.send_message(BirchUser,"bot is kil plz fix")
# if messaged, wait longer to avoid spam.
adj=adj+3600
if adj>10800:
adj=10800
else:
adj=0
await asyncio.sleep(600+adj)
if __name__=="__main__":
mydir=os.path.dirname(os.path.realpath(__file__))
with open(mydir+"/.token","r") as f:
t=f.read()[:-1]
print("Token ending in: \"%s\""%(t[-8:]))
client.loop.create_task(check_amadeus_down())
client.run(t)