def on_ready(): ### Set up modules yield from wildmagic.loadEffects() yield from deckofmanythings.loadEffects() yield from raid.loadEffects() yield from markov.loadEffects() yield from chromaticorc.loadEffects() global startTime startTime = datetime.datetime.now() util.log('Stormbird', 'Client ready.') yield from change_playing()
def loadEffects(): try: # Get raw text as string. with open(FILE_NAME_CORPUS) as file: text = file.read() # Build the model. global text_model text_model = markovify.Text(text) file.close() except Exception as e: util.log(DEBUG, "Error when loading lines: " + e) return
def loadEffects(): try: global wordDict wordDict = [[] for i in range(LEN_LIMIT)] file = open(FILE_NAME_DICT, 'r') words = [x.strip('\n') for x in file.readlines()] for word in words: if len(word) > LEN_LIMIT: continue wordDict[len(word)].append(word) file.close() except Exception as e: util.log("Orc", "Error when loading dict: " + e) return
def loadEffects(): try: global flavorList file = open(FILE_NAME_EFFECTS, 'r') effects = [x.strip('\n') for x in file.readlines()] for effectPair in effects: name, effect = effectPair.split(':') effectsTable[name] = effect[1:] file.close() file = open(FILE_NAME_FLAVOR, 'r') flavorList = [x.strip('\n') for x in file.readlines()] file.close() except Exception as e: util.log(DEBUG, "Error when loading effects: " + e) return
def loadEffects(): try: file = open(FILE_NAME_LINES, 'r') lines = [x.strip('\n') for x in file.readlines()] group = [] for line in lines: if line == "": storyLines.append(group) group = [] else: group.append(line) storyLines.append(group) file.close() except Exception as e: util.log(DEBUG, "Error when loading lines: " + e) return
def loadEffects(): try: file = open(FILE_NAME_EFFECTS, 'r') effects = [x.strip('\n') for x in file.readlines()] for effect in effects: die0 = effect[0:2] die1 = effect[3:5] die0 = die0.lstrip('0') if die0 != "00" else 0 die1 = die1.lstrip('0') if die1 != "00" else 0 effectsTable[int(die0)] = effect[6:] effectsTable[int(die1)] = effect[6:] file.close() file = codecs.open(FILE_NAME_REACT, 'r', 'utf-8') reactions = [x.strip('\n') for x in file.readlines()] file.close() for reaction in reactions: k, v = reaction.split() effectsEmoji[k] = v except Exception as e: util.log(DEBUG, "Error when loading effects: " + e) return
def checkOngoingEffect(bot: Bot, message): name = message.author.display_name superUser = util.isSuperUser(message.author) if superUser: if util.getArg(message.content, 1) == 'clear': # remove all statuses and cooldowns userStatus.clear() return if name not in userStatus or userStatus[name][1] is None: return True cd = getCd(name) if cd <= 0: userStatus[name][1] = None return True effectName = userStatus[name][1] if effectName in effectsEmoji: yield from bot.add_reaction(message, effectsEmoji[effectName]) if effectName == 'mute': yield from bot.send_message(message.channel, "💕 Pink bubbles float out of " + name + "'s mouth! 💕 " + "(" + str(cd) + "s)") try: yield from bot.delete_message(message) except Exception as e: util.log(DEBUG, "Couldn't delete a message.") return False elif effectName == 'maxDamageSpell': userStatus[name][1] = None elif effectName == 'allCaps': if not message.content.isupper(): yield from bot.send_message(message.channel, name + " must shout when they speak! " + "(" + str(cd) + "s)") try: yield from bot.delete_message(message) except Exception as e: util.log(DEBUG, "Couldn't delete a message.") return False return True
hits += 1 elif roll == 1: glitches += 1 earr = [ 360257354694000641, 360257354765434892, 360257354853253121, 360257355142922240, 360257355134402560, 360257355138727946 ] emoji = Emoji(id=earr[roll - 1], server=stormbird.get_server(112471696346255360)) result += str(emoji) glitch = '' if glitches > int(rolls / 2): if hits == 0: glitch = ' - ‼️***Critical Glitch*** ‼' else: glitch = ' - ❗ ***Glitch*** ❗' yield from stormbird.send_message( message.channel, '🎲 **' + str(hits) + '** ' + util.pl('hit', hits) + glitch + '\n' + result) """ Read the key and run the bot. """ try: f = open(FILE_NAME_KEY, 'r') key = f.readline().strip('\n') f.close() stormbird.run(key) except Exception as e: util.log("Main", "Key read error: " + e)