Auto-Dismantle in Town

You can try to use this plugin which adds dismantle command as script.

Be carefull, it will destroy everything on inventory if you have enough destroyer rondo.

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

pName = 'xScriptHelper'
pVersion = '1.0.1'
#pUrl = 'https://raw.githubusercontent.com/JellyBitz/phBot-xPlugins/master/xScriptHelper.py'

# ______________________________ Initializing ______________________________ #

DISMANTLE_MAX_ATTEMPTS = 3

DismantlingCurrentSlot = 0
DismantlingAttempts = 0
DismantlingBlacklisted = []
DismantlingErrorCode = 0

# ______________________________ Methods ______________________________ #

def Inject_DismantleItem(itemSlot):
	p = b'\x01' + struct.pack('B',itemSlot)
	inject_joymax(0x7157,p,False)

# Dismantle items if some item is found
def DismantleItem(ItemName=None):
	global DismantlingErrorCode
	if DismantlingErrorCode:
		if DismantlingErrorCode == 22536:
			log("Plugin: Not enough inventory space to continue dismantling!")
		elif DismantlingErrorCode == 22535:
			log("Plugin: Not enough Destroyer Rondo's to continue dismantling!")
		else:
			log("Plugin: Error code ("+str(DismantlingErrorCode)+") to continue dismantling!")
		DismantlingErrorCode = 0
		start_bot()
		return
	inventory = get_inventory()
	items = inventory['items']
	itemFound = False
	# Checkk items from inventory
	for slot, item in enumerate(items):
		if item and slot > 12:
			itemData = get_item(item['model'])
			# Make sure item is equipable
			if itemData['tid1'] != 1:
				continue
			# Make sure item is not an avatar or job item
			if itemData['tid2'] == 7 or itemData['tid2'] == 13:
				continue
			# Check if it's dismantling by name 
			if ItemName and ItemName != item['name']:
				continue

			# if at least one item has been found, stop bot!
			itemFound = True
			stop_bot()
			# Check if this slot cannot be dismantled
			if slot in DismantlingBlacklisted:
				continue
			# Check dismantling attempts
			global DismantlingCurrentSlot
			global DismantlingAttempts
			if slot == DismantlingCurrentSlot:
				DismantlingAttempts+=1
			else:
				DismantlingAttempts=0
			if DismantlingAttempts == DISMANTLE_MAX_ATTEMPTS:
				log('Plugin: Skiping "'+item['name']+'", too many dismantling attempts!')
				DismantlingBlacklisted.append(slot)
				continue
			# Try dismantle it
			DismantlingCurrentSlot = slot
			log('Plugin: Trying to dismantle "'+item['name']+'"...')
			Inject_DismantleItem(slot)
			# waits a little bit for item to be dismantled
			Timer(3,DismantleItem,[ItemName]).start()
			break
	# restart bot if nothing can be found
	if not itemFound:
		log("Plugin: Dismantling finished!")
		start_bot()

# ______________________________ Events ______________________________ #

# Try to dismantle items on inventory
def dismantle(args):
	# reset some vars
	DismantlingBlacklisted.clear()
	# check params
	if len(args) > 1 and args[1]:
		# dismantle by item name
		DismantleItem(args[1])
	else:
		# dismantle all
		DismantleItem()
	# All done
	return 0

# 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 == 0xB157:
		# check failure
		if data[0] != 1:
			global DismantlingErrorCode
			DismantlingErrorCode = struct.unpack_from('<H',data,1)[0]
	return True

# Plugin loaded
log('Plugin: '+pName+' v'+pVersion+' succesfully loaded')