-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
116 lines (94 loc) · 3.32 KB
/
main.py
File metadata and controls
116 lines (94 loc) · 3.32 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
import os
import re
import ast
import discord
from discord.ext import commands
from discord.ext.commands import Bot
from cogs.music import Music
from cogs.moop import Moop
from util.soy import soy
from util.now import now
# TODO build custom print method that returns to both the terminal and to a
# specific 'terminal' channel on discord
# TODO add proper logging
# TODO fix jpeg rotation issue
# TODO finish overlay command
def main():
prefix = ','
bot = commands.Bot(command_prefix=prefix)
shitmoop = 811211114699292672
# TODO slim this down, a lot of these don't need to be private
# import constant values, using environ.json if local or os.environ in repl.it
try:
sunday = os.environ['SUNDAYID']
uuupah = os.environ['UUUPAHID']
token = os.environ['TOKEN']
# moop250 = os.environ['250MOOP'] #TODO remove from environ
# id = os.environ['CLIENTID'] #TODO remove from environ
except:
try:
file = open("environ.json", "r")
contents = file.read()
environ = ast.literal_eval(contents)
file.close()
sunday = environ['sunday']
uuupah = environ['uuupah']
token = environ['token']
# moop250 = environ['moop250']
# id = environ['id'] # as above
except:
print(
f'$$ A problem has occurred during constant variable loading {now()}'
)
# startup message
@bot.event
async def on_ready():
print(f'$$ logged in as {bot.user} {now()}')
await bot.wait_until_ready()
dad = await bot.fetch_user(int(uuupah))
await dad.send(
f'hello father, i have returned from the void of nonexistence {now()}')
await bot.change_presence(activity=discord.Game(f'{prefix}help'))
# TODO actual error handling
# handle all functionality that is not a command
@bot.event
async def on_message(msg):
await bot.process_commands(msg)
# ignore messages sent by bot
if msg.author == bot.user:
return
# print messages for terminal viewing
print(msg.author)
print(f' > {msg.content}')
# sunday botherer
if msg.author.id == int(sunday) and msg.content.lower() == 'me':
await msg.add_reaction(f'<:moop:{shitmoop}>')
return
# react to moops
if re.search(r'moo+p', msg.content, flags=re.IGNORECASE):
await msg.add_reaction(f'<:moop:{shitmoop}>')
return
# watch for messages that ping the bot
# TODO keep animation on gifs and apngs
bot_id = bot.user.id
if f'<@!{bot_id}>' in msg.content or f'<@{bot_id}>' in msg.content:
# if a style has been specified
if len(msg.content.lstrip().split()) > 1:
await soy(msg, style=msg.content.lstrip().split()[1])
else:
await soy(msg, style='soy')
bot.add_cog(Music(bot))
bot.add_cog(Moop(bot, uuupah))
bot.run(token)
if __name__ == "__main__":
main()
# naughty code jail
###
# if msg.author.id == int(uuupah):
# await msg.add_reaction(f'<:moop:{moop250}>')
# await msg.channel.send(f'<:moop:{moop250}>')
# return
# if msg.author.id == int(sunday):
# await message.add_reaction('\N{AUBERGINE}')
# return
###