Trade Chat Answer


#1

Due to each server changing random parts of their answer you may need to modify the script to make it work.

from phBot import *
import phBotChat

import re
import struct
from time import sleep

def process_chat(data):
    if data[0] == 7:
        msg_len = struct.unpack_from('H', data, 1)[0]
        msg = struct.unpack_from(str(msg_len) + 's', data, 1 + 2)[0].decode('latin1')

        m = re.findall(r'(\d+)', msg)
        if m and len(m) >= 2:
            if msg.find('+') != -1:
                result = int(m[0]) + int(m[1])
            else:
                   result = int(m[0]) * int(m[1])

            sleep(1.0)

            log('Sending result %s' % str(result))
            if msg.find('/answer') != -1:
                phBotChat.All('/answer ' + str(result))
            else:
                phBotChat.All(str(result))
    elif data[0] == 2:
        name_len = struct.unpack_from('H', data, 1)[0]
        name = struct.unpack_from(str(name_len) + 's', data, 1 + 2)[0].decode('latin1')

        if name == 'RemoLogger' or name == 'Bot' or name == 'BotCheck':
            msg_len = struct.unpack_from('H', data, 1 + 2 + name_len)[0]
            msg = struct.unpack_from(str(msg_len) + 's', data, 1 + 2 + name_len + 2)[0].decode('latin1')

            m = re.findall(r'(\d+)', msg)
            if m:
                if len(m) == 1:

                    sleep(1.0)

                    log('Sending result %s' % str(m[0]))
                    phBotChat.Private(name, str(m[0]))

                elif len(m) >= 2:

                    if msg.find('+') != -1:
                        result = int(m[0]) + int(m[1])
                    else:
                        result = int(m[0]) * int(m[1])

                    sleep(1.0)

                    log('Sending result %s' % str(result))
                    phBotChat.Private(name, str(result))
            elif msg.lower().find('kervankey') != -1:
                sleep(1.0)
                phBotChat.Private(player, 'Kervankey')

def handle_joymax(opcode, data):
    if opcode == 0x3026 and get_locale() == 22:
        process_chat(data)
    return True

log('[%s] Loaded' % __name__)

Improved for 21.4.8. The old version above will still work. This just uses an easier API.

from phBot import *
import phBotChat

import re
from time import sleep

def handle_chat(t, player, msg):
	if len(player) == 0:
		m = re.findall(r'(\d+)', msg)
		if m and len(m) >= 2:

			if msg.find('+') != -1 or msg.find(' x ') != -1:
				result = int(m[0]) + int(m[1])
			else:
				result = int(m[0]) * int(m[1])

			sleep(1.0)

			log('Sending result %s' % str(result))
			if msg.find('/answer') != -1:
				phBotChat.All('/answer ' + str(result))
			else:
				phBotChat.All(str(result))
	elif player == 'RemoLogger' or player == 'Bot' or player == 'BotCheck':
		m = re.findall(r'(\d+)', msg)
		if m:
			if len(m) == 1:

				sleep(1.0)

				log('Sending result %s' % str(m[0]))
				phBotChat.Private(player, str(m[0]))

			elif len(m) >= 2:

				if msg.find('+') != -1 or msg.find(' x ') != -1:
					result = int(m[0]) + int(m[1])
				else:
					result = int(m[0]) * int(m[1])

				sleep(1.0)

				log('Sending result %s' % str(result))
				phBotChat.Private(player, str(result))
		elif msg.lower().find('kervankey') != -1:
			sleep(1.0)
			phBotChat.Private(player, 'Kervankey')
	elif player.find('JobSecure') != -1 and msg.find('Job experience') != -1:
		sleep(1.0)
		phBotChat.Private(player, str(get_character_data()['job_current_exp']))

log('[%s] Loaded' % __name__)

"NF SRO" Trader questions
Trade Auto Answer Plugins
Kervan key
Question - About script commands
pinned #2

#3

Is this plugin answers the question if the question sended by a character by pm?


#4

Depends on the name of the player that sent the message.


#5

The character is Server (not [Server], just Server which sends the message. But there is a problem. The answer-check system is quite different.

At first you have to write a pm to Server character to this message: key , then this Server character randomly sends 7 number code to you and wants you to reply this code to it(Server character).

I hope you get what is system like. What do you prefer to solve this check method or is there any plugin which can work for that one?


#6

This may work. In your script add the command request_key where you want to send System the key message.

from phBot import *
import phBotChat

import re
from time import sleep

def request_key(args):
	phBotChat.Private('System', 'key')
	return 5

def handle_chat(t, player, msg):
	if len(player) == 0:
		m = re.findall(r'(\d+)', msg)
		if m and len(m) >= 2:

			if msg.find('+') != -1 or msg.find(' x ') != -1:
				result = int(m[0]) + int(m[1])
			else:
				result = int(m[0]) * int(m[1])

			sleep(1.0)

			log('Sending result %s' % str(result))
			if msg.find('/answer') != -1:
				phBotChat.All('/answer ' + str(result))
			else:
				phBotChat.All(str(result))
	elif player == 'RemoLogger' or player == 'Bot' or player == 'BotCheck' or player == 'System':
		m = re.findall(r'(\d+)', msg)
		if m:
			if len(m) == 1:

				sleep(1.0)

				log('Sending result %s' % str(m[0]))
				phBotChat.Private(player, str(m[0]))

			elif len(m) >= 2:

				if msg.find('+') != -1 or msg.find(' x ') != -1:
					result = int(m[0]) + int(m[1])
				else:
					result = int(m[0]) * int(m[1])

				sleep(1.0)

				log('Sending result %s' % str(result))
				phBotChat.Private(player, str(result))
		elif msg.lower().find('kervankey') != -1:
			sleep(1.0)
			phBotChat.Private(player, 'Kervankey')
	elif player.find('JobSecure') != -1:
		sleep(1.0)
		phBotChat.Private(player, str(get_character_data['job_current_exp']))

log('[%s] Loaded' % __name__)

#7

@Ryan BotCheck 1-999 Auto Answer
How can we do this?

The Mixed Number Between Pm is Coming.


#8

Post a screenshot of the message it sends.


#9

Ads%C4%B1z


#10

There are already like 10 posts about this. Get Some String data from web site


#11

@Ryan what exactly is that solutions


#12

There isn’t one at the moment.


#13

@Ryan Can’t you help?