Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # IRCbot v1.03 by laz (Don't know who this guy is)
- #--- IRC Settings ---
- server = "irc.d2jsp.org" # Probably won't change
- port = 6667 # Server Port, won't change
- username = "AccountName" # D2jsp username
- password = "4344af63333y64ef0606d3b" # Auth key, NOT YOUR ACTUAL PASSWORD
- #--- Job Settings ---
- acceptJobsFrom = ["escl"] #escnl wscl wscnl Realm/ladder to accept jobs from. You need to have a profile/char capable of grushing on that realm
- rushPrice = 35 # Price of a grush in fg
- VIP1 = [""] # list of users that get VIP1 pricing
- VIP1price = 10 # Price of a grush in fg for VIP1 users
- VIP2 = ["Friend1", "Friend2", "Friend3", "Friend4"] # list of users that get VIP2 pricing
- VIP2price = 1 # Price of a grush in fg for VIP2 users
- path = "C:\Users\imgre\Desktop\kolton-master\d2bs\kolbot\jobs.txt" # Path to jobs file
- # No touchy! ################################################
- # lpData
- sender = "SenderProfile"
- task = "start"
- target = "TargetProfile"
- msg = '{"profile":"%s","func":"%s","args":["%s"]}' % (sender, task, target)
- import socket, sys, threading, time, Tkinter
- import win32gui
- import win32con
- import win32api
- from ctypes import *
- import ctypes
- ctypes.windll.kernel32.SetConsoleTitleA("D2jsp IRCbot v1.03");
- # Struct
- class COPYDATASTRUCT(Structure):
- _fields_ = [
- ("dwData", c_void_p), # Always 0
- ("cbData", c_ulong), # length of data
- ("lpData", c_char_p) # data
- ]
- # Log thread
- filename = "log.txt"
- logLines = []
- def log():
- "Log chat to file"
- while True:
- time.sleep(3)
- if len(logLines) > 0:
- write = "\n".join(logLines)
- del logLines[:]
- f = open(filename, "a")
- f.write(write + "\n")
- f.close()
- def fixString(s):
- s = s.replace("&","&")
- s = s.replace("\","\\")
- s = s.replace(""",'"')
- s = s.replace("'","'")
- s = s.replace("<","<")
- s = s.replace(">",">")
- s = s.replace("!","!")
- return s
- # WM_copydata
- def sendCopyData():
- print "\n[SCRIPT] Sender : " + sender
- print "[SCRIPT] Task : " + task
- print "[SCRIPT] Target : " + target
- hwnd = win32gui.FindWindow(None, "D2Bot #")
- if hwnd == 0:
- print "[SCRIPT] D2Bot # not running!\n"
- return
- else:
- print "[SCRIPT] Window handle : " + str(hwnd)
- data = COPYDATASTRUCT(0, len(msg), msg)
- win32api.SendMessage(hwnd, win32con.WM_COPYDATA, 0, data)
- print "[SCRIPT] Sent WM_copydata...\n"
- logLines.append("[COPYDATA] WM_copydata message sent to D2Bot# with sender='%s', task='%s' and arg='%s'." % (sender, task, target))
- # Start
- logThread = threading.Thread(target=log)
- logThread.daemon = True
- logThread.start()
- logLines.append("\n--- Engine startup ---\n")
- print "--- D2jsp IRC bot by laz ---\n"
- def connectIRC():
- irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- print "[IRC] Connecting to : " + server
- irc.connect((server, port))
- print "[IRC] Connected..."
- irc.send("NICK %s\r\n" % username)
- print "[IRC] Sent nick : " + username
- irc.send("USER %s w * :%s\r\n" % (username, username))
- print "[IRC] Sent user : " + username
- irc.send("HAUTH %s\r\n" % password)
- print "[IRC] Authenticated..."
- return irc
- irc = connectIRC()
- while True:
- try:
- text = irc.recv(2040)
- except:
- print "\nLost connection... Reconnecting\n"
- time.sleep(20)
- try:
- irc = connectIRC()
- except:
- print "..."
- continue
- if len(text) == 0:
- print "\nLost connection... Reconnecting\n"
- time.sleep(20)
- try:
- irc = connectIRC()
- except:
- print "..."
- continue
- if text.endswith("\n"): # Remove newline
- text = text[:-1]
- if text.startswith("PING :irc.d2jsp.org"):
- irc.send("PONG " + text.split() [1] + "\r\n")
- else:
- logLines.append(text) # Don't log ping/pong
- if ":irc.d2jsp.org 650 " + username in text:
- print "\n[IRC] Bot is running!\n"
- Tkinter.Tk().bell()
- elif text.startswith(":irc.d2jsp.org 651 " + username): # private message
- string = text.split(":")
- who = string[1].split(" ")[4]
- comment = string[2]
- print "[IRC] Received PM from '" + who + "' with subject '" + comment + "'"
- elif text.startswith(":irc.d2jsp.org 652 " + username): # gold received
- string = text.split(":", 2)
- gold = string[1].split(" ")[6]
- who = string[1].split(" ")[4]
- comment = fixString(string[2].lower())
- print "[IRC] Received " + gold + " FG from '" + who + "' with comment '" + comment + "'"
- # --- Jobs ---
- # Grush
- if comment.startswith("grush/"):
- if who in VIP1:
- price = VIP1price
- elif who in VIP2:
- price = VIP2price
- else:
- price = rushPrice
- if float(gold) >= price:
- infos = comment.split("/")
- if len(infos) == 5:
- if infos[1].lower() in acceptJobsFrom:
- j = open(path, "a")
- j.write(comment.lower() + "\n")
- j.close()
- print "[SCRIPT] Job added : '" + comment + "'"
- logLines.append("[SCRIPT] Wrote job to file : " + comment + "\n")
- else:
- print "[SCRIPT] Not taking jobs from : '" + infos[1] + "'"
- else:
- print "[SCRIPT] Job infos missing or incorrect"
- else:
- print "[SCRIPT] Gold insufficient"
Add Comment
Please, Sign In to add comment