def wiki_me(query, _slack_event): """ query - query str slack_event - A dict of slack event information(unused for this function) Returns a link to wiki page found by search """ return request.wikipedia_search(query)
def run_command(command, query, message_user): """ runs the passed in command and query :command what to run (image me, gif me etc) :query what to search for :message_user the user who sent the request :Returns the result of the bot command """ text = '' if not command: text = 'Did you need something?' if command in ["anime", 'manga']: text = request.anime_news_network_search(command, query) elif command in ["image", "img"]: text = fetch_image(query) elif command == 'reverse': text = query[::-1] elif command == 'youtube': text = request.youtube_search(query) elif command in ['wiki', 'wikipedia']: text = request.wikipedia_search(query) elif command in ['gif', 'sticker']: text = request.gify_search(command, query) elif command == 'tableflip': text = random.choice(["(ノಥ益ಥ)ノ ┻━┻ ", "┻━┻ ︵ヽ(`Д´)ノ︵ ┻━┻ ", "(ノಠ益ಠ)ノ彡┻━┻ ", "ヽ(`Д´)ノ┻━┻", " (ノ≥∇))ノ┻━┻ ", "(╯°□°)╯︵ ┻━┻ "]) elif command == 'putitback': text = random.choice(["┬─┬ノ( º _ ºノ)", r"┬──┬ ¯\_(ツ)"]) elif command == 'flipcoin': text = f":coin: :coin: {random.choice(['HEADS', 'TAILS'])} :coin: :coin:" elif command == 'decide': text = f"I'm gonna go with: {random.choice(query.split(' '))}" elif command == 'callthecops': text = 'You called? ' + fetch_image('anime cops from bing') elif command == 'call' and query == 'the cops': text = 'You called? ' + fetch_image('anime cops from bing') elif command == 'kill': text = request.gify_search('gif', 'kill me') elif command == 'shame': user = query.strip().upper() text = random.choice([ 'Shame on you! ' + user + 'You should know better!', user + ' ಠ_ಠ', user + ' You have made a mockery of yourself. Turn in your weeabo credentials!', user + ' :blobdisapproval:', user + ' :disappoint:', user + ' you did bad and you should feel bad', user + ' :smh:', ]) elif command == 'help': # get users direct message channel id dm_id = json.loads(request.submit_slack_request({'user': message_user}, 'im.open'))['channel']['id'] data = { 'channel': dm_id, 'text': """ Known Commands: reverse me - reverse text entered after command image me (alias img me) - use text after command to search for an image (use suffix "from [google|bing]" if you want to specify a search engine) youtube me - use text after command to query youtube for a video anime me - use text after command to query anime news network for anime info manga me - use text after command to query anime news network for manga info wiki me - use text after command to query wikipedia for an article gif me - use text after command to query giphey for gif sticker me - use text after command to query giphey for sticker tableflip - responds with a tableflip emoji putitback - responds with a reversetableflip emoji flipcoin - responds with either head or tails decide - responds randomly with one of the words after this command callthecops (alias call the cops) - responds with an image of anime cops with the caption "You Called" kill me - responds with a gif with kill me as a search shame - shame user (You must @USER_NAME) """ } # Post list of commands to user in direct message request.submit_slack_request(data, 'chat.postMessage') # Tell user to check their direct messages text = f"<@{message_user}>" + ' check your Direct Messages for the list of my known commands.' else: text = "Sorry I don't know that command. To see all my commands use `help`" if not text: text = "Sorry no results found" return text