async def subscribe(client, message, command=None): t = cog_config.read('Notifications',message.author.id) if len(command) == 1: if t: t = int(t) if not t or t == 0: print('{} has no notifications enabled.'.format(message.author.name)) await client.send_message(message.channel, "{} has no notifications enabled.\nAvaliable subscriptions:\n```\n{}\n```".format(message.author.name,'\n'.join(sublist))) return nlist = subscribed_to(t) print('{} subscribed to:\n{}'.format(message.author.name,'\n'.join(nlist))) await client.send_message(message.channel, "{} subscribed to:\n```\n{}\n```\nAvaliable subscriptions:\n```\n{}\n```".format(message.author.name,'\n'.join(nlist),'\n'.join(sublist))) return a = command[1].split(',') if t: t = int(t) else: t = 0 nlist = [] for i in a: if i.strip() == 'banned words': t |= 0b1 nlist.append('banned words') if i.strip() == 'oversized images': t |= 0b10 nlist.append('oversized images') if i.strip() == 'raid alert': t |= 0b100 nlist.append('raid alert') if i.strip() == 'fourth one': t |= 0b1000 nlist.append('fourth one') print('{} subscribed to:\n{}'.format(message.author.name,'\n'.join(nlist))) cog_config.write('Notifications',message.author.id, t) await client.send_message(message.channel, "{} just subscribed to:\n```\n{}\n```".format(message.author.name,'\n'.join(nlist)))
async def names(client, message, command=None): if len(command) == 1: userinfo_command = message.author.id else: userinfo_command = command[1] print('({1.hour:02d}:{1.minute:02d}){0.author.name} used `names command'. format(message, datetime.now())) if userinfo_command.isdecimal(): user = message.server.get_member(userinfo_command) elif (userinfo_command.strip('<>@!')).isdecimal(): user = message.server.get_member(userinfo_command.strip('<>@!')) else: user = message.server.get_member_named(userinfo_command) if not user: await client.send_message( message.channel, 'User not found.\nUse \`names <id/mention/name> to get recorded names of user.' ) return if user.avatar_url: user_avatar_url = user.avatar_url else: user_avatar_url = user.default_avatar_url em = discord.Embed(title=':information_source: User info', colour=user.colour) em.set_author( name='User: @{0.name}#{0.discriminator} - {0.id}'.format(user)) em.set_thumbnail(url=user_avatar_url) em.add_field(name='User:'******'{0} at UTC/GMT+0'.format(datetime.utcnow())) names = ', '.join(reversed(cog_config.read('Names', user.id).split('\n'))) nicks = ', '.join(reversed(cog_config.read('Nicks', user.id).split('\n'))) if not names: names = 'None has been recorded' if not nicks: nicks = 'None has been recorded' em.add_field(name='Names:', value="```\n{}\n```".format(nobigcode(names)), inline=False) em.add_field(name='Nicks:', value="```\n{}\n```".format(nobigcode(nicks)), inline=False) await client.send_message(message.channel, embed=em)
def get_subscribers(mode): keys = cog_config.read_keys('Notifications') out = [] if mode == 'banned words': for uid in keys: if int(cog_config.read('Notifications',uid)) & 0b1: out.append(uid) elif mode == 'oversized images': for uid in keys: if int(cog_config.read('Notifications',uid)) & 0b10: out.append(uid) elif mode == 'raid alert': for uid in keys: if int(cog_config.read('Notifications',uid)) & 0b100: out.append(uid) elif mode == 'fourth one': for uid in keys: if int(cog_config.read('Notifications',uid)) & 0b1000: out.append(uid) else: return None return out
from derpibooru import Search, sort import urbandictionary as ud import random import time import asyncio import re import cog_logger import cog_raidalert import cog_config import cog_commands import cog_banning import cog_notifications cog_config.init() TOKEN = str(cog_config.read('CONFIG','token')) if not TOKEN or TOKEN == 'put_token_here': print('Please put your token in config file') exit(0) BOT = bool(cog_config.read('CONFIG','bot')) client = discord.Client() COMMAND_PREFIX = '`' #prefix used in `commands DERPI_GENERAL_FILTER = "157099" #SFW NoMeme filter DERPI_GENERAL_ARTIST_FILTER = "157101" #SFW NoMeme filter with lowered gte score DERPI_MEME_FILTER = "157100" #SFW Meme only filter #Global variables