def postprocess(command, config, bot_config): if command["message"] in config["matches"]: if bot_config["nick"] == "buttbot": bot.say(command["host"], command["channel"], "Butt Roll Call") else: bot.say(command["host"], command["channel"], "What are you playing at?")
def postprocess(command, config, bot_config): if not config["activated"]: return try: if command["user"] == bot_config["user"]: return except KeyError: pass words = command["message"].split(' ') sentence = "" if len(words) < 3: return for i in range(0, len(words)): if random.random() < config["chance"]: word = re.findall(r"[\w']+|[.,!?;]", words[i]) if len(word) > 0: if word[0].isupper(): word[0] = config["replace"].upper() else: word[0] = config["replace"] words[i] = "".join(word) sentence = " ".join(words) if sentence != command["message"]: bot.say(command["host"], command["channel"], sentence)
def dota(command, config, bot_config): try: match = command["options"]["args"][0] except IndexError: return url = "https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/V001/?key???&match_id=" + match response = requests.get(url) if (response.ok): data = json.loads(response.content) data = data["result"] radiant_score = [0, 0, 0] dire_score = [0, 0, 0] for player in data["players"]: if player["player_slot"] > 100: dire_score[0] += player["kills"] dire_score[1] += player["deaths"] dire_score[2] += player["assists"] else: radiant_score[0] += player["kills"] radiant_score[1] += player["deaths"] radiant_score[2] += player["assists"] #say data to channel if data["radiant_win"]: sentence = "Radiant" else: sentence = "Dire" sentence += " victory! " sentence += str(radiant_score[0]) + "/" + str( radiant_score[1]) + "/" + str(radiant_score[2]) sentence += " " + str(dire_score[0]) + "/" + str( dire_score[1]) + "/" + str(dire_score[2]) bot.say(command["host"], command["channel"], sentence) else: response.raise_for_status() pass
def dota(command, config, bot_config): try: match = command["options"]["args"][0] except IndexError: return url = "https://api.steampowered.com/IDOTA2Match_570/GetMatchDetails/V001/?key???&match_id=" + match response = requests.get(url) if(response.ok): data = json.loads(response.content) data = data["result"] radiant_score = [0, 0, 0] dire_score = [0, 0, 0] for player in data["players"]: if player["player_slot"] > 100: dire_score[0] += player["kills"] dire_score[1] += player["deaths"] dire_score[2] += player["assists"] else: radiant_score[0] += player["kills"] radiant_score[1] += player["deaths"] radiant_score[2] += player["assists"] #say data to channel if data["radiant_win"]: sentence = "Radiant" else: sentence = "Dire" sentence += " victory! " sentence += str(radiant_score[0]) + "/" + str(radiant_score[1]) + "/" + str(radiant_score[2]) sentence += " " + str(dire_score[0]) + "/" + str(dire_score[1]) + "/" + str(dire_score[2]) bot.say(command["host"], command["channel"], sentence) else: response.raise_for_status() pass
def error(command): bot.say(command["host"], command["channel"], "Invalid use. Example: '!perm add whitelist rose'")
def not_auth(command): bot.say(command["host"], command["channel"], "Invalid permissions.")
def say(command, config, bot_config): if len(command["options"]["args"]) > 0: bot.say(command["host"], command["channel"], " ".join(command["options"]["args"]))