def DeepArt(message, options, text='', style='', images=[]): if IsEmpty(style): style = text if IsEmpty(style): style = 'custom' imageLen = len(images) if style == 'custom': if imageLen < 2: return CommandResult.ExpectImage(askImage=imagesStr[imageLen]) return DeepArtCustom(message, images) else: if imageLen == 0: return CommandResult.ExpectImage(askImage=imagesStr[1]) return DeepArtBuiltin(message, style, images)
def Meme(message, options='', text='', name=None, top=' ', bot=' ', font='impact', img=None, desc=None, images=None, admin=False, mode=None, params=None, activate=None, deactivate=None, new=None): if params is None: params = {} if text == 'templates': return SendTemplateList(message.chatroom, message.sender) a, b, c = text.partition(' ') if not IsEmpty(c): x = None if a == 'new': x = 'n' elif a == 'activate': x = 'a' elif a == 'deactivate': x = 'd' if x: options = options + x params['options'] = options text = c.strip() if activate: name = activate options = options + 'a' params['options'] = options if deactivate: name = deactivate options = options + 'd' params['options'] = options if new: name = new options = options + 'n' params['options'] = options if 'n' in options or 'a' in options or 'd' in options: if IsEmpty(name): name = text if IsEmpty(name): message.ReplyText("[Command(Meme):New] Name can't be empty") return CommandResult.Done() if 'n' in options: if name in invalidNames: message.ReplyText("[Command(Meme):New] Name can't be '%s'" % name) return CommandResult.Done() return NewMeme(message, options, name, desc, mode, admin, images, params) if 'a' in options: return Activate(message, options, name, admin=admin) return Activate(message, options, name, admin=admin, activate=False) if name is None: if IsEmpty(text) or not IsEmpty2(top) or not IsEmpty2( bot) or not IsEmpty(options): name = 'random' else: name = text.split(' ')[0] if IsEmpty(name): chatroom.SendText("[Command(Meme)] Name can't be empty.") return CommandResult.Done() if name == 'custom': if IsEmpty2(top) and IsEmpty2(bot): message.ReplyText( "[Command(Meme)] Just send the image yourself wtf") return CommandResult.Done() if IsEmpty(img): if images is None or len(images) == 0: return CommandResult.ExpectImage() img = images[0].imgurUrl if IsEmpty(img): message.ReplyText("Failed to reupload image.") return CommandResult.ExpectImage() return Send(message.chatroom, message.sender, name, top, bot, font, img)
def NewMeme(message, options, name, desc=None, mode=None, admin=False, images=None, params=None): if mode is None: if admin: mode = 10 else: mode = 0 if 'r' in options: mode = 1 elif 's' in options: mode = 2 if params: params['mode'] = mode if not IsEmpty(images): return RegisterMeme(message, options, name, desc, mode, images, params) if 'f' not in options: cur = message.client.GetCursor() if mode == 10: cur.Execute('SELECT TRUE FROM CustomMemes WHERE name=%s', (name, )) if cur.rowCount > 0: message.ReplyText( "[Command(Meme)] Global template named '%s' already exists. If you want to replace, please also provide the 'f' (force) option" % name) return CommandResult.Done() roomMemeExists = False if mode == 0 or mode == 1: cur.Execute( 'SELECT TRUE FROM RoomCustomMemes WHERE name=%s AND rId=%s', (name, message.chatroom._2id)) if cur.rowCount > 0: if mode == 0: roomMemeExists = True else: message.ReplyText( "[Command(Meme)] Room template named '%s' already exists. If you want to replace, please also provide the 'f' (force) option" % name) return CommandResult.Done() userMemeExists = 0 if not message.sender: userMemeExists = 2 elif mode == 0 or mode == 2: cur.Execute( 'SELECT TRUE FROM UserCustomMemes WHERE name=%s AND uId=%s', (name, message.sender._2id)) if cur.rowCount > 0: if mode == 0: userMemeExists = 1 else: message.ReplyText( "[Command(Meme)] User template named '%s' already exists. If you want to replace, please also provide the 'f' (force) option" % name) return CommandResult.Done() if mode == 0: if roomMemeExists: if userMemeExists == 2: message.ReplyText( "[Command(Meme)] Room template named '%s' already exists. We can't identify you so user template is also not possible. If you want to replace, please also provide the 'f' (force) option" % name) return CommandResult.Done() elif userMemeExists == 1: message.ReplyText( "[Command(Meme)] Room template and user template named '%s' already exists. If you want to replace, please also provide the 'f' (force) option" % name) return CommandResult.Done() elif userMemeExists == 0: message.ReplyText( "[Command(Meme)] Room template named '%s' already exists. This way, only user template will be registered. If you want to replace the room template too, please also provide the 'f' (force) option" % name) mode = 2 else: if userMemeExists == 2: message.ReplyText( "[Command(Meme)] We can't identify you so user template is not possible. This way, only user template will be registered." ) mode = 1 elif userMemeExists == 1: message.ReplyText( "[Command(Meme)] User template named '%s' already exists. This way, only the room template will be registered. If you want to replace, please also provide the 'f' (force) option" % name) mode = 1 if params: params['mode'] = mode return CommandResult.ExpectImage()