from phBot import *
import phBotChat
import re
import struct
from time import sleep
from threading import Timer
import QtBind
import struct
import json
import os
def handle_chat(data):
if data[0] == 7:
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 == '[SYSTEM]' or name == 'SYSTEM':
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 and len(m) >= 2:
if msg.find('+') != -1:
result = int(m[0]) - int(m[1])
else:
result = int(m[0]) - int(m[1])
sleep(0.0)
log('Sending result %s' % str(result))
if msg.find('±') != -1:
phBotChat.All('.validate ' + str(result))
else:
phBotChat.All('.validate ' - 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 == '[SYSTEM]' or name == 'SYSTEM':
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 and len(m) >= 2:
if msg.find('±') != -1:
result = int(m[0]) + int(m[1])
else:
result = int(m[0]) - int(m[1])
sleep(0.0)
log('Sending result %s' % str(result))
phBotChat.All('.validate ' + str(result))
def event_loop():
global last
delay = QtBind.text(gui, time)
if last == None or (datetime.datetime.now() - last) > datetime.timedelta(seconds=int(delay)):
last = datetime.datetime.now()
message = QtBind.text(gui, text)
if len(message) > 0:
phBotChat.All('.validate'+ str(result))
return 0
def send_trade(args):
phBotChat.All('.validate',str(result) )
return 0
def handle_joymax(opcode, data):
if opcode == 0x3026 and get_locale() == 22:
handle_chat(data)
return True
log('[%s] Loaded' % __name__)
log(' bende23 Soru Cevap botu Aktif Edildi')
gui = QtBind.init(__name__,'Trade')
cbxEnableTrade = QtBind.createCheckBox(gui, 'cbxEnableTrade_clicked','active trade',10,10)