Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

Commit

Permalink
Merge branch '1.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondIceNS committed Jul 20, 2018
2 parents e797414 + 0b086be commit 63d37d9
Show file tree
Hide file tree
Showing 28 changed files with 3,163 additions and 1,573 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ A template utility bot based on [Alastair](Make-Alastair-Great-Again) and [Pinki

Currently supports [Pixelcanvas.io](http://pixelcanvas.io/), [Pixelz.io](http://pixelz.io/), [Pixelzone.io](http://pixelzone.io/), and [Pxls.space](http://pxls.space/).

**Invite:** `https://discordapp.com/oauth2/authorize?&client_id=405480380930588682&scope=bot&permissions=101376`
**Invite:** `https://discordapp.com/oauth2/authorize?&client_id=405480380930588682&scope=bot&permissions=109569`

#### Requires:
- [Python 3.6](https://www.python.org/downloads/release/python-365/)
- [Discord.py rewrite](https://github.com/Rapptz/discord.py/tree/rewrite)
- [Pillow](https://pillow.readthedocs.io/en/latest/installation.html) 5.1.0
- [aiohttp](https://aiohttp.readthedocs.io/en/stable/) 3.2.0
- [numpy](https://www.scipy.org/scipylib/download.html) 1.14.4
- [websockets](https://pypi.org/project/websockets/) 4.0.1
- [lz4](https://github.com/python-lz4/python-lz4) 1.1.0
- [cloudflare-scrape async](https://github.com/lucasgadams/cloudflare-scrape@cf_async)
Expand All @@ -27,24 +28,24 @@ Currently supports [Pixelcanvas.io](http://pixelcanvas.io/), [Pixelz.io](http://
- Automatic live canvas preview
- Automatic live template checking
- Template storage for easy access to templates you care about most
- Faction creation, to share your templates with other guilds
- Color quantization of templates to canvas palette
- Gridifyer to create gridded, human-readable templates
- Dithering sample charts for assisting color selection when you are making a template
- Configurable roles
- [Animotes](https://github.com/ev1l0rd/animotes) support, just because
- Cross-guild emoji through Animotes (must opt-in)
- Full language localization

For a more in-depth walkthrough of Glimmer's core functions, see [the wiki page](https://github.com/DiamondIceNS/StarlightGlimmer/wiki).

#### Languages:
- English (US)
- Portuguese (BR)
- Portuguese (BR) - Special thanks to Ataribr / ✠ /#6703

If you happen to know a language that is not listed and would be willing to translate, please translate the strings in `lang/en_US.py` and submit a pull request.
(Currently looking for: French, Turkish)

#### Help:
If you need assistance with the bot, have a problem, or would like to recommend a feature to me directly, you can contact me [on my support server](https://discord.gg/UtyJx2x). You can also DM me if you see me around -- I am `Fawfulcopter#3234` on Discord.
If you need assistance with the bot, have a problem, or would like to recommend a feature to me directly, you can contact me [on my support server](https://discord.gg/UtyJx2x). You can also DM me if you see me around -- I am `Fawfulcopter#3432` on Discord.

[avatar]: avatar.jpg
86 changes: 16 additions & 70 deletions commands/animotes.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import re

import discord
from discord.ext import commands

from utils import checks, sqlite as sql
from utils import sqlite as sql
from objects.channel_logger import ChannelLogger
from objects.logger import Log

Expand Down Expand Up @@ -31,91 +32,36 @@ def __init__(self, bot):
self.ch_log = ChannelLogger(bot)
self.log = Log(__name__)

async def on_message(self, message):
if not message.author.bot and sql.animotes_users_is_registered(message.author.id):
channel = message.channel
content = emote_corrector(self, message)
if content:
await message.delete()
await channel.send(content=content)

@commands.command()
async def register(self, ctx):
sql.animotes_users_add(ctx.author.id)
await ctx.send(ctx.get_str("animotes.member_opt_in"))
await ctx.send(ctx.s("animotes.opt_in"))

@commands.command()
async def unregister(self, ctx):
sql.animotes_users_delete(ctx.author.id)
await ctx.send(ctx.get_str("animotes.member_opt_out"))
await ctx.send(ctx.s("animotes.opt_out"))

@checks.admin_only()
@commands.guild_only()
@commands.command()
async def registerguild(self, ctx):
sql.guild_update(ctx.guild.id, emojishare=1)
await self.ch_log.log("Guild **{0.name}** (ID: `{0.id}`) has opted in to emoji sharing.".format(ctx.guild))
await ctx.send(ctx.get_str("animotes.guild_opt_in"))
@staticmethod
async def on_message(message):
if not message.author.bot and sql.animotes_users_is_registered(message.author.id):
channel = message.channel
content = emote_corrector(message)
if content:
await message.delete()
await channel.send(content=content)

@checks.admin_only()
@commands.guild_only()
@commands.command()
async def unregisterguild(self, ctx):
sql.guild_update(ctx.guild.id, emojishare=0)
await self.ch_log.log("Guild **{0.name}** (ID: `{0.id}`) has opted out of emoji sharing.".format(ctx.guild))
await ctx.send(ctx.get_str("animotes.guild_opt_out"))

@commands.guild_only()
@commands.command()
async def listemotes(self, ctx):
# TODO: WHY IS THIS NEVER CONSISTENT???
guilds = []
blacklist = []
whitelist = []
opted_in = sql.guild_is_emojishare(ctx.guild.id)
whitelist.append(ctx.guild.id) # Emoji from this server are allowed automatically
for e in self.bot.emojis:
if e.animated:
# No emoji from blacklisted servers
if e.guild_id in blacklist:
continue
# Do not list cross-server emoji if this server has not opted in
if e.guild_id != ctx.guild.id and not opted_in:
continue
# Blacklist servers that have not themselves opted in
if not (e.guild_id in whitelist or sql.guild_is_emojishare(e.guild_id)):
blacklist.append(e.guild_id)
continue
# If passed all checks, ensure this server is whitelisted so we can skip future opt-in checks
if e.guild_id not in whitelist:
whitelist.append(e.guild_id)
if not any(x['id'] for x in guilds if x['id'] == e.guild_id):
guild = next(x for x in self.bot.guilds if x.id == e.guild_id)
guilds.append({'id': e.guild_id, 'name': guild.name, 'animojis': []})
pos = next(i for i, x in enumerate(guilds) if x['id'] == e.guild_id)
guilds[pos]['animojis'].append(str(e))

for g in guilds:
msg = "**{0}**:".format(g['name'])
msg += "\n"
for e in g['animojis']:
msg += e
await ctx.send(msg)


def emote_corrector(self, message):
# noinspection PyTypeChecker
def emote_corrector(message):
r = re.compile(r'(?<![a<]):[\w~]+:')
found = r.findall(message.content)
emotes = []
for em in found:
temp = discord.utils.get(self.bot.emojis, name=em[1:-1])
temp = discord.utils.get(message.guild.emojis, name=em[1:-1])
try:
if temp.animated:
if temp.guild_id == message.guild.id:
emotes.append((em, str(temp)))
elif sql.guild_is_emojishare(message.guild.id) \
and sql.guild_is_emojishare(temp.guild_id):
emotes.append((em, str(temp)))
emotes.append((em, str(temp)))
except AttributeError:
pass # We only care about catching this, not doing anything with it

Expand Down
Loading

0 comments on commit 63d37d9

Please sign in to comment.