-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcog_nsfw.py
146 lines (133 loc) · 6.63 KB
/
cog_nsfw.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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import json
import random
import urllib
import discord
import requests
from bs4 import BeautifulSoup
from discord.ext import commands
from utils import *
class NSFW():
def __init__(self, bot):
self.bot = bot
def choose(self, l):
pic = random.choice(l)
toSend = pic['src']
return toSend
@commands.group(pass_context=True)
async def nsfw(self, ctx):
if ctx.invoked_subcommand is None:
embed = discord.Embed(title="Tag sub-commands", color=ctx.message.author.color)
embed.add_field(name=getPrefix(ctx.message.server.id) + "nsfw channel (mention channel name)",
value="Create a new tag!", inline=False)
embed.add_field(name=getPrefix(ctx.message.server.id) + "nsfw everyone (True of False)",
value="Set if everyone can use nsfw commands or not!", inline=False)
embed.add_field(name=getPrefix(ctx.message.server.id) + "ass", value="View some ass? lol", inline=False)
embed.add_field(name=getPrefix(ctx.message.server.id) + "tits", value="View some tits, why not?",
inline=False)
embed.add_field(name=getPrefix(ctx.message.server.id) + "nsfw view", value="View sour channel's settings.",
inline=False)
await self.bot.say(embed=embed)
@nsfw.command(pass_context=True)
async def channel(self, ctx):
if ctx.message.author.server_permissions.manage_server == True or ctx.message.author.id == '156517655669374977':
if len(ctx.message.channel_mentions) == 0:
await self.bot.say("You must mention a channel!")
else:
name = ctx.message.channel_mentions[0].name
connectnsfw()
if checkIfChangedNSFW(ctx.message.server.id):
conn = sqlite3.connect("nsfw.db")
cur = conn.cursor()
cur.execute("UPDATE nsfw SET guildid=?, channel=?",
(ctx.message.server.id, ctx.message.channel_mentions[0].name))
conn.commit()
conn.close()
await self.bot.say("Updated NSFW settings.")
else:
conn = sqlite3.connect("nsfw.db")
cur = conn.cursor()
cur.execute("INSERT INTO nsfw VALUES(?, ?)",
(ctx.message.server.id, ctx.message.channel_mentions[0].name))
conn.commit()
conn.close()
await self.bot.say("Updated NSFW settings.")
else:
await self.bot.say("You must have server manage permissions to use this command!")
@nsfw.command(pass_context=True)
async def view(self, ctx):
await self.bot.say("Your channel to receive NSFW commands is " + getNSFWchan(ctx.message.server.id))
if getNSFWeo(ctx.message.server.id):
toSend = "Everyone can use NSFW commands!"
else:
toSend = "No one can use NSFW commands!"
await self.bot.say(toSend)
@nsfw.command(pass_context=True)
async def everyone(self, ctx, bool=None):
if ctx.message.author.server_permissions.manage_server == True or ctx.message.author.id == '156517655669374977':
if bool is None:
await self.bot.say("You must enter True or False!")
else:
connectnsfweo()
if bool.lower() == "true" or bool.lower() == "false":
if checkIfChangedNSFWEO(ctx.message.server.id):
conn = sqlite3.connect("nsfw.db")
cur = conn.cursor()
cur.execute("UPDATE nsfweo SET guildid=?, everyone=?", (ctx.message.server.id, bool.lower()))
conn.commit()
conn.close()
await self.bot.say("Updated NSFW settings.")
else:
conn = sqlite3.connect("nsfw.db")
cur = conn.cursor()
cur.execute("INSERT INTO nsfweo VALUES(?, ?)", (ctx.message.server.id, bool.lower()))
conn.commit()
conn.close()
await self.bot.say("Updated NSFW settings.")
else:
await self.bot.say("You must enter either true or false")
else:
await self.bot.say("You must have server manage permissions to use this command!")
@commands.command(pass_context=True)
async def ass(self, ctx):
if getNSFWchan(ctx.message.server.id) == ctx.message.channel.name:
if getNSFWeo(ctx.message.server.id) == True:
try:
sent = False
while sent is False:
url = "http://thechive.com/2017/04/11/im-in-the-business-of-booty-scoops-and-business-is-a-boomin-33-photos/"
response = requests.get(url)
soup = BeautifulSoup(response.content, 'html.parser')
pics = list(soup.find_all('img'))
pic = random.choice(pics)
toSend = pic['src']
if 'thechive' in toSend:
sent = True
else:
sent = False
await self.bot.say(toSend)
except:
await self.bot.say(toSend(pics))
else:
await self.bot.say("Not everyone can use this command in your server!")
else:
await self.bot.say("You can not use NSFW commands in this channel!")
@commands.command(pass_context=True)
async def tits(self, ctx):
if getNSFWchan(ctx.message.server.id) == ctx.message.channel.name:
if getNSFWeo(ctx.message.server.id) == True:
try:
url = 'http://api.oboobs.ru/boobs/0/1/random'
response = urllib.request.urlopen(url)
encoding = response.info().get_content_charset('utf8')
data = json.loads(response.read().decode(encoding))
toSend = data[0]['preview']
toSendFile = "http://media.oboobs.ru/" + toSend
await self.bot.say(toSendFile)
except Exception as e:
print(str(e))
else:
await self.bot.say("Not everyone can use this command in your server!")
else:
await self.bot.say("You can not use NSFW commands in this channel!")
def setup(bot):
bot.add_cog(NSFW(bot))