async def rep(self): """Automate farming Sushii rep with a configured recipient and interval""" if self.client.shared["logging"]: utils.log("Sushii rep farming enabled") recipients = utils.list_generator(self.config["reprecipients"]) channel = self.client.get_channel(self.config["channel"]) while not self.client.is_closed(): # Get a random recipient from one of the configured ones random_recipient = next(recipients) # Human typing delay delay = self.rand.randint(1, 3) # Give the random recipient rep outbound = outbound_message.Outbound_Message( f"-rep <@{random_recipient}>", channel, delay) await outbound.send() if self.client.shared["logging"]: utils.log(f"Gave sushii rep to {random_recipient}") # Delay the loop if configured await asyncio.sleep( utils.get_delay(self.config["repdelay"], self.rand))
async def fishy(self): """Send messages to add fishies to the configured person at a configured interval""" if self.client.shared["logging"]: utils.log("Sushii fishy farming enabled") recipients = utils.list_generator(self.config["fishyrecipients"]) channel = self.client.get_channel(self.config["channel"]) while not self.client.is_closed(): # Get a random recipient from one of the configured ones random_recipient = next(recipients) # Human typing delay delay = self.rand.randint(1, 3) # Give the random recipient fishies outbound = outbound_message.Outbound_Message( f"-fishy <@{random_recipient}>", channel, delay) await outbound.send() if self.client.shared["logging"]: utils.log(f"Gave sushii fishies to {random_recipient}") # Delay the loop if configured await asyncio.sleep( utils.get_delay(self.config["fishydelay"], self.rand))
async def rep(self): """Send messages to add rep to the configured person at a configured interval""" await self.client.wait_until_ready() # If disabled in configuration, don"t proceed if not self.config["repfarming"]: return if self.client.shared["logging"]: utils.log("Sushii rep farming enabled") recipients = utils.list_generator(self.config["reprecipients"]) while not self.client.is_closed(): channel = self.client.get_channel(self.config["channel"]) # Get a random recipient from one of the configured ones random_recipient = next(recipients) # Human typing delay delay = self.rand.randint(1, 3) # Give the random recipient rep outbound = outbound_message.Outbound_Message( f"-rep <@{random_recipient}>", channel, delay) await outbound.send() if self.client.shared["logging"]: utils.log(f"Gave sushii rep to {random_recipient}") # Delay the loop if configured await asyncio.sleep( utils.get_delay(self.config["repdelay"], self.rand))
async def mrelease(self, context): prefixes = self.pokecord.config["prefixes"] # Calculate a human typing delay delay = self.pokecord.rand.randint(1, 3) outbound = outbound_message.Outbound_Message( f"{prefixes[context.channel.id]}pokemon", context.channel, delay) await outbound.send() reply = await self.client.wait_for("message", check=self.pokecord.pokecord_check) if len(reply.embeds) != 1: if self.shared_config["logging"]: utils.log( "Something went wrong attempting to mass release pokemon (No embed)" ) return False embed = reply.embeds[0] if embed.title != "Your pokémon:": if self.shared_config["logging"]: utils.log( "Something went wrong attempting to mass release pokemon (Incorrect embed)" ) return False print(f"\n\n{embed.description}\n\n")
async def work(self): """Send messages to add work to the configured person at a configured interval""" await self.client.wait_until_ready() # If disabled in configuration, don"t proceed if not self.config["enabled"] or not self.config["workfarming"]: return if self.client.shared["logging"]: utils.log("Sidneybot work farming enabled") while not self.client.is_closed(): channel = self.client.get_channel(self.config["channel"]) # Human typing delay delay = self.rand.randint(1, 3) # Farm work outbound = outbound_message.Outbound_Message("sid work", channel, delay) await outbound.send() if self.client.shared["logging"]: utils.log(f"Farmed Sidneybot work in {channel.id}") # Work farming delay delay = utils.get_delay(self.config["delay"], self.rand) # Delay the loop if configured await asyncio.sleep(utils.get_delay(self.config["delay"], self.rand))
async def release(self, prefix): """Release that garbage pokeman :param prefix: Prefix for the channel you caught that pokeman in """ # Get the pokecord reply with our pokeboi info reply = await self.client.wait_for("message", check=self.pokecord_check) # If the message doesn't have an embed, ignore if len(reply.embeds) != 1: if self.client.shared["logging"]: utils.log("Failed to autorelease (no embeds)") return False # Get the embed where all the info is embed = reply.embeds[0] # Get the Total IV of the new pokeboi IV = utils.get_IV(embed) if float(IV) > self.config["minimumiv"]: return False pokeman_number = utils.get_pokeman_number(embed) # Wait for a minute so that we don't get c**k blocked by pokecord cooldowns delay = utils.get_delay(self.config["autocatchdelay"], self.rand) # Release that garbage pokeman outbound = outbound_message.Outbound_Message( f"{prefix}release {pokeman_number}", reply.channel, delay) await outbound.send() # More cooldowns delay = utils.get_delay(self.config["autocatchdelay"], self.rand) # Confirm you have standards outbound = outbound_message.Outbound_Message(f"{prefix}confirm", reply.channel, delay) await outbound.send() return True
async def farm(self): """Send messages according to yaml config specifying frequency, channel, etc""" await self.client.wait_until_ready() # Don"t proceed if no channels are configured or configured to if not self.config["enabled"] or len(self.config["channels"]) == 0: return if self.client.shared["logging"]: utils.log("Message farming enabled") messages = utils.list_generator(self.config["messages"]) while not self.client.is_closed(): channels = self.config["channels"] # If configured, shuffle the channels to randomize the order we farm them if self.config["randomchannels"]: self.rand.shuffle(channels) for schannel in channels: # Create a channel object of the configured channel id channel = self.client.get_channel(schannel) # Get a random message from one of the configured ones random_message = next(messages) # Generate a human delay before sending the message delay = self.rand.randint(1, 3) # If configured, get the delay before deleting the message silent_delay = utils.get_delay(self.config["silent"], self.rand) # Send a random message in the configured channel outbound = outbound_message.Outbound_Message(random_message, channel, delay, silent_delay) await outbound.send() if self.client.shared["logging"]: utils.log(f"Sent \"{random_message}\" to {schannel}") # Delay the loop if configured await asyncio.sleep(utils.get_delay(self.config["delay"], self.rand))
async def bond(self): """Automate bonding with your Kohaipp pet with a configured channel""" if self.client.shared["logging"]: utils.log("Kohaiipp pet bonding enabled") channel = self.client.get_channel(self.config["bondchannel"]) while not self.client.is_closed(): # Human typing delay delay = self.rand.randint(1, 2) # Bond! outbound = outbound_message.Outbound_Message("pp!petb", channel, delay) await outbound.send() if self.client.shared["logging"]: utils.log(f"Kohaipp - Bonded in {channel.id}") # Delay the loop if configured await asyncio.sleep(utils.get_delay(self.config["bonddelay"], self.rand))
async def mine(self): """Automate mining for Kohaipp with a configured channel""" if self.client.shared["logging"]: utils.log("Kohaiipp mining enabled") channel = self.client.get_channel(self.config["minechannel"]) while not self.client.is_closed(): # Human typing delay delay = self.rand.randint(1, 2) # Mine! outbound = outbound_message.Outbound_Message("pp!m", channel, delay) await outbound.send() if self.client.shared["logging"]: utils.log(f"Kohaipp - Mined in {channel.id}") # Delay the loop if configured await asyncio.sleep(utils.get_delay(self.config["minedelay"], self.rand))
async def work(self): """Automate working for Sidneybot with a configured interval""" if self.client.shared["logging"]: utils.log("Sidneybot work farming enabled") channel = self.client.get_channel(self.config["channel"]) while not self.client.is_closed(): # Human typing delay typing_delay = self.rand.randint(1, 3) # Farm work outbound = outbound_message.Outbound_Message("sid work", channel, typing_delay) await outbound.send() if self.client.shared["logging"]: utils.log(f"Farmed Sidneybot work in {channel.id}") # Delay the loop if configured await asyncio.sleep(utils.get_delay(self.config["delay"], self.rand))
async def farm(self): """Automate sending messages with a configured frequency, channel, etc""" if self.client.shared["logging"]: utils.log("Message farming enabled") messages = utils.list_generator(self.config["messages"]) channels = self.config["channels"] while not self.client.is_closed(): # If configured, shuffle the channels to randomize the order we farm them if self.config["randomchannels"]: self.rand.shuffle(channels) for channel_id in channels: # Create a channel object of the configured channel id channel = self.client.get_channel(channel_id) # Get a random message from one of the configured ones random_message = next(messages) # Generate a human delay before sending the message delay = self.rand.randint(1, 3) # If configured, get the delay before deleting the message silent_delay = utils.get_delay(self.config["silent"], self.rand) # Send a random message in the configured channel outbound = outbound_message.Outbound_Message( random_message, channel, delay, silent_delay) await outbound.send() if self.client.shared["logging"]: utils.log(f"Sent \"{random_message}\" to {channel_id}") # Delay the loop if configured await asyncio.sleep( utils.get_delay(self.config["delay"], self.rand))
async def handle_message(self, message): """Check if each incoming message is a command or something to be operated on :param message: """ # Check if message is a new pokemon and if so catch it # If enabled of course if self.pokecord.config["enabled"] and self.pokecord.config[ "autocatch"]: if self.pokecord.pokecord_check(message): await self.pokecord.find_pokemon(message) return # Check if message is a command owners = self.shared_config["owners"] if message.author.id not in owners and message.author.id != self.client.user.id: return if message.content.startswith("|"): to_repeat = message.content[1:] # Generate human delay delay = self.pokecord.rand.randint(1, 3) # Generate and send message (repeated) outbound = outbound_message.Outbound_Message( to_repeat, message.channel, delay) await outbound.send() if self.shared_config["logging"]: utils.log(f"Repeated {to_repeat}") return await self.client.process_commands( message ) # https://discordpy.readthedocs.io/en/latest/faq.html#id18
async def catch(self, channel, png): """Catch that pokeman and release it if it's garbage :param channel: Channel to catch the pokemon in :param png: Image to identify """ # Create a perceptual difference hash of the image # A hash is just an identifier # Perceptual is how the image looks # Difference is a type of algorithm # Altogether: An identifier for how the image looks hash = str(imagehash.dhash(png, 16)) # Search through the list of hashes we already have for a match # The dictionary has keys of hashes and values of names # So we pass the hash and get the name of the Pokemon pokemon = self.hashes[hash] # We use the uppercase verison of the pokemon a lot # So we will just create a variable for it here pupper = pokemon.upper() # Record latest pokemon that appeared in this channel self.pokebois[channel.id] = pupper # If whitelist is enabled, check if the pokemon we are trying to catch is whitelisted # If not, we're going to abort and not catch the pokemon if self.config["enablewhitelist"]: if pupper not in self.whitelist: if self.client.shared["logging"]: utils.log( f"{pokemon} ignored, not whitelisted. Channel: {channel.id}" ) return # If blacklist is enabled, check if the pokemon we are trying to catch is blacklisted # If it is, we're going to abort and not catch the pokemon if self.config["enableblacklist"]: if pupper in self.blacklist: if self.client.shared["logging"]: utils.log( f"{pokemon} ignored, blacklisted. Channel: {channel.id}" ) return # If configured, make pokemon name lowercase when we claim it # The idea is that it might look more human since we are presumably typing fast if self.config["lowercasepokemon"]: pokemon = pokemon.lower() # Get the prefix for this channel prefixes = self.config["prefixes"] prefix = prefixes[channel.id] async with channel.typing(): # Wait for any configured delays before catching the pokemon await asyncio.sleep( utils.get_delay(self.config["autocatchdelay"], self.rand)) # Check if the latest pokemon is still the one we are trying to catch # If not, this means someone has already caught it or a new one appeared # In which case we need to abort if self.pokebois[channel.id] != pupper: if self.client.shared["logging"]: utils.log(f"{pokemon} was caught/replaced in {channel.id}") return await channel.send(f"{prefix}catch {pokemon}") # Next message should be a success message from Pokecord catch_or_fail = await self.client.wait_for("message", check=self.pokecord_check) caught = self.check_catch(catch_or_fail) if not caught: if self.client.shared["logging"]: utils.log(f"Failed to catch {pokemon} in {channel.id}") return if self.client.shared["logging"]: utils.log(f"Caught {pokemon} in {channel.id}") # If configured, determine whether this pokeboi is worthy of keeping or not if self.config["autorelease"]: # Wait for a minute so that we don't get c**k blocked by pokecord cooldowns delay = utils.get_delay(self.config["autocatchdelay"], self.rand) # Get info on the pokeboi we just caught outbound = outbound_message.Outbound_Message( f"{prefix}info latest", channel, delay) await outbound.send() # Process the pokecord reply if await self.release(prefix): if self.client.shared["logging"]: utils.log(f"Released {pokemon} in {channel.id}")