[Plugin] Clock of Reincarnation

from phBot import *
from threading import Timer
from time import sleep
import struct

# Search an item by name or servername through lambda expression and return his information
def GetItemByExpression(_lambda,start=0,end=0):
	inventory = get_inventory()
	items = inventory['items']
	if end == 0:
		end = inventory['size']
	# check items between intervals
	for slot, item in enumerate(items):
		if start <= slot and slot <= end:
			if item:
				# Search by lambda
				if _lambda(item['name'],item['servername'],item['model']):
					# Save slot location
					item['slot'] = slot
					return item
	return None

# Check and use all clocks on inventory
def CheckClocks():
	while True:
		# Find clock
		itemClock = GetItemByExpression(lambda n,s,m: n.startswith('Clock of Reincarnation'),13) 
		if itemClock:
			itemPetPick = GetItemByExpression(lambda n,s,m: '_COS_P_' in s and get_item(m)['tid3'] == 2,13)
			if itemPetPick:
				# Build packet
				p = struct.pack('B',itemClock['slot'])
				p+= b'\xED\x66' # usage type
				p+= b'\x6C' # Pick pet slot set to last slot of page 3
				# Inject it
				log('Plugin: Using "'+itemClock['name']+'" on "'+itemPetPick['name']+'"...')
				# Some delay before trying to look another one
				log('Plugin: Pet not found on inventory to use clock!')
# All packets received from game server will be passed to this function
# Returning True will keep the packet and False will not forward it to the game client
def handle_joymax(opcode,data):
	if opcode == 0xB04B:
		if data[0] == 1:
	return True

log('Plugin: Clock of Reincarnation is operational.')

NOTE 5555 days is the limit for pick pet time after that u will be getting disconnected everytime once plugin uses clock on pet

Plugins is not mine just something that was passed to me ages ago