Ph bot answer

Hey bro ı need help
Sample:
Question:K[Guard]'a Cevap Olarak 5lk69ka Yazınız.
Reply: 5lk69ka

5lk69ka this section is constantly changing.
How do we edit these codes?
Or can you code it?
Thx <3

from phBot import *
import phBotChat
import struct
import json
import os
import time

def handle_joymax(opcode, data):

if opcode == 0x3026: # Chat Message
    # Packet index
    index = 0
    # Message type: All or Party or Private
    if data[index] == 0x01 or data[index] == 0x02 or data[index] == 0x04:
        # Parse nick of character
        Character = "[KGuard]"
        if data[index] != 0x01:
            index += 1
            CharacterLength = struct.unpack_from('<H', data, index)[0]
            index += 2
            Character = struct.unpack_from('<' + str(CharacterLength) + 's', data, index)[0].decode('cp1252')
            index += CharacterLength
        if Character == "[KGuard]":
             # Load and search command message
             MessageLength = struct.unpack_from('<H', data, index)[0]
             index += 2
             Message = struct.unpack_from('<' + str(MessageLength * (2 if get_encoding() == 'utf-16le' else 1)) + 's', data, index)[0].decode(get_encoding())
             if "K[Guard]'a Cevap Olarak" in Message: # soru geliyor
             
                cevap = ""
             
                for c in reversed(Message):
                    if c != "k":
                        cevap += c
                    else:
                        break
                
                cevap = cevap[::-1].replace("", "")
                #log(cevap)
                
                qeqo = "" + cevap.strip()
                phBotChat.Private(Character,qeqo)
                
                time.sleep(0)
                
                Packet = bytearray()
                Packet.append(0x01)
                Packet.append(0x00)
                Packet = Packet + struct.pack('<H', len(qeqo))
                Packet = Packet + qeqo.encode('ascii')
                
                inject_joymax(0x7025, Packet, False)
            
return True

log(‘NfSRO Soru Cevap Aktif Edildi’)

1 Like

try this, or edit to your necessities!

from phBot import *
import phBotChat
from time import sleep
import re

log("Plugin: KGuard successfully loaded.")

def handle_chat(t, player, msg):
	if len(player) > 0:
		if player == "[KGuard]":
			# using regular expression
			if re.search('Cevap Olarak [a-zA-Z0-9]* Yazınız',msg):
				# extracting answer
				reply = re.search('Cevap Olarak ([a-zA-Z0-9]*) Yazınız',msg)[1]
				# reply the answer
				sleep(1.0)
				phBotChat.Private(player,reply)

From KGuard to [KGuard]. You can edit that, c’mon! ._.
Fixed anyways.

1 Like

[13:24:41] Plugin: KGuard successfully loaded. But , He doesn’t answer the question.Can’t edit it with the codes I scored above??