Skip to content
This repository has been archived by the owner on Oct 23, 2022. It is now read-only.

Commit

Permalink
youtube fix and swear now in beta
Browse files Browse the repository at this point in the history
  • Loading branch information
djetelina committed May 21, 2016
1 parent 08bf59b commit 7856730
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cogs/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ async def facebook(self):

@commands.command(description=desc.youtube, brief=desc.youtube)
async def youtube(self):
connector = aiohttp.TCPConnector(verify_ssl=False)

with aiohttp.ClientSession() as session:
with aiohttp.ClientSession(connector=connector) as session:
async with session.get('https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UC0YagOInbZx'
'j10gaWwb1Nag&maxResults=1&order=date&key={}'.format(t.yt_key)) as resp:
data = await resp.json()
Expand All @@ -105,7 +106,6 @@ async def youtube(self):

await s.destructmsg(title + "\n" + uploaded + "\n\n"+channel, 30, self.bot)

await s.destructmsg("https://www.youtube.com/c/idiotechgaming", 30, self.bot)

@commands.command(description=desc.rules, brief=desc.rules)
async def rules(self):
Expand Down
32 changes: 28 additions & 4 deletions cogs/swear.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import asyncio
import simplify as s
import random
import channels as chan
from discord.ext import commands
import checks

"""
DRAFT VERSION
Expand All @@ -15,13 +18,18 @@ def __init__(self, user, bot):
self.user = user
self.bot = bot
self.points = 0
self.warnings = ["Please don't swear!", "Don't swear, thanks!"]
self.warnings = ["Please don't swear!", "Don't swear, thanks!", 'Is there a need for suo much bad language?',
"That's it, I'm reporting you to the authorities!", "I'm a child, watch your language.",
"Did you know you already have at least 3 penalty points for swearing? Please stop",
"I'm no GLaDOS, but I like science too. Your swears are not science.",
"You know that you can express things without swears?", "Was that word necessary?"]
watchlist.update({self.user: self})
self.new()

def new(self):
self.points += 1
self.point_check()
if self.point_check():
loop.create_task(self.warn_user())
loop.create_task(self.decay())

async def decay(self):
Expand All @@ -39,13 +47,18 @@ async def decay(self):

def point_check(self):
if self.points >= 3:
loop.create_task(self.warn_user())
return True

elif self.points == 0:
if self.points == 0:
del watchlist[self.user]


async def warn_user(self):
await s.whisper(self.user, random.choice(self.warnings), self.bot)
await self.bot.send_message(
self.bot.get_channel(chan.channels['admin']),
"User {} seems to be swearing a lot. He now has {} penalty points".format(
self.user.mention, self.points))


class Swear:
Expand Down Expand Up @@ -79,6 +92,17 @@ def trigger(self, message):
else:
Warns(message.author, self.bot)

@commands.command(hidden=True)
@checks.mod_or_permissions(manage_messages=True)
async def points(self, *, who: str):
for user, instance in watchlist.items():
if who.lower() in user.name.lower():
print("found")
await self.bot.say("{} has {} warning points.".format(instance.user.mention, instance.points))
return
else:
await self.bot.say("User {} not found in watchlist".format(who))


def setup(bot):
bot.add_cog(Swear(bot))
16 changes: 8 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
from datetime import datetime

bot = commands.Bot(command_prefix='!', description=desc.main, pm_help=True)
extensions = ['cogs.giveaway', 'cogs.general', 'cogs.restricted', 'cogs.stats', 'cogs.weather', ]

fb = t.fb_key
yt = t.yt_key
dt = t.token # discord token
if fb == "": print("MISSING FACEBOOK KEY")
if yt == "": print("MISSING YOUTUBE KEY")
if dt == "": print("MISSING DISCORD TOKEN")
extensions = [
'cogs.giveaway',
'cogs.general',
'cogs.restricted',
'cogs.stats',
'cogs.weather',
'cogs.swear',
]


@bot.event
Expand Down

0 comments on commit 7856730

Please sign in to comment.