-
Notifications
You must be signed in to change notification settings - Fork 0
/
oppey.py
48 lines (40 loc) · 1.53 KB
/
oppey.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
import os
import aiohttp
import discord
from dotenv import load_dotenv
load_dotenv()
async def fetch(session, url):
async with session.get(url) as response:
return await response.text()
class MyClient(discord.Client):
async def on_ready(self):
# print(.get(name="Oppey"))
self.oppey = discord.utils.get(self.guilds[0].members,name='Oppey')
print('Logged on as {0}!'.format(self.user))
print('Oppey bot is {0}'.format(self.oppey))
async def on_message(self, message):
if self.oppey:
is_oppey = (message.author.id == self.oppey.id)
else:
is_oppey = True
is_self = (message.author.id == self.user.id)
is_bot_channel = (message.channel.name == "dev-oppey-bot")
print('Is Oppey? {1} {0.author}: {0.content}'.format(message, is_oppey or is_self))
#
async with aiohttp.ClientSession() as self.httpClient:
# print('OppeyML: {0}'.format(response))
if is_oppey or is_self:
return
if is_bot_channel:
async with self.httpClient.get() as response:
return await response.text()
# print("author: {0}".format(message.author.id))
# print("self: {0}".format(self.user.id))
# print("is_oppey: {0}".format(is_oppey))
# print("is_self: {0}".format(is_self))
# print("is_bot_channel: {0}".format(is_bot_channel))
# if is_bot_channel:
# else:
# print('Possible: {0}'.format(response))
client = MyClient()
client.run(os.environ.get('OPPEY_ML_TOKEN'))