Guest User

NudePhotos

a guest
Mar 11th, 2017
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.03 KB | None | 0 0
  1. # IRCbot v1.03 by laz (Don't know who this guy is)
  2.  
  3. #--- IRC Settings ---
  4. server = "irc.d2jsp.org" # Probably won't change
  5. port = 6667 # Server Port, won't change
  6. username = "AccountName" # D2jsp username
  7. password = "4344af63333y64ef0606d3b" # Auth key, NOT YOUR ACTUAL PASSWORD
  8.  
  9. #--- Job Settings ---
  10. acceptJobsFrom = ["escl"] #escnl wscl wscnl Realm/ladder to accept jobs from. You need to have a profile/char capable of grushing on that realm
  11. rushPrice = 35 # Price of a grush in fg
  12. VIP1 = [""] # list of users that get VIP1 pricing
  13. VIP1price = 10 # Price of a grush in fg for VIP1 users
  14. VIP2 = ["Friend1", "Friend2", "Friend3", "Friend4"] # list of users that get VIP2 pricing
  15. VIP2price = 1 # Price of a grush in fg for VIP2 users
  16. path = "C:\Users\imgre\Desktop\kolton-master\d2bs\kolbot\jobs.txt" # Path to jobs file
  17.  
  18. # No touchy! ################################################
  19.  
  20. # lpData
  21. sender = "SenderProfile"
  22. task = "start"
  23. target = "TargetProfile"
  24. msg = '{"profile":"%s","func":"%s","args":["%s"]}' % (sender, task, target)
  25.  
  26. import socket, sys, threading, time, Tkinter
  27. import win32gui
  28. import win32con
  29. import win32api
  30. from ctypes import *
  31. import ctypes
  32. ctypes.windll.kernel32.SetConsoleTitleA("D2jsp IRCbot v1.03");
  33.  
  34. # Struct
  35. class COPYDATASTRUCT(Structure):
  36. _fields_ = [
  37. ("dwData", c_void_p), # Always 0
  38. ("cbData", c_ulong), # length of data
  39. ("lpData", c_char_p) # data
  40. ]
  41.  
  42. # Log thread
  43. filename = "log.txt"
  44. logLines = []
  45. def log():
  46. "Log chat to file"
  47. while True:
  48. time.sleep(3)
  49. if len(logLines) > 0:
  50. write = "\n".join(logLines)
  51. del logLines[:]
  52. f = open(filename, "a")
  53. f.write(write + "\n")
  54. f.close()
  55.  
  56. def fixString(s):
  57. s = s.replace("&","&")
  58. s = s.replace("\","\\")
  59. s = s.replace(""",'"')
  60. s = s.replace("'","'")
  61. s = s.replace("&#60;","<")
  62. s = s.replace("&#62;",">")
  63. s = s.replace("&#33;","!")
  64. return s
  65.  
  66. # WM_copydata
  67. def sendCopyData():
  68. print "\n[SCRIPT] Sender : " + sender
  69. print "[SCRIPT] Task : " + task
  70. print "[SCRIPT] Target : " + target
  71. hwnd = win32gui.FindWindow(None, "D2Bot #")
  72. if hwnd == 0:
  73. print "[SCRIPT] D2Bot # not running!\n"
  74. return
  75. else:
  76. print "[SCRIPT] Window handle : " + str(hwnd)
  77.  
  78. data = COPYDATASTRUCT(0, len(msg), msg)
  79. win32api.SendMessage(hwnd, win32con.WM_COPYDATA, 0, data)
  80. print "[SCRIPT] Sent WM_copydata...\n"
  81. logLines.append("[COPYDATA] WM_copydata message sent to D2Bot# with sender='%s', task='%s' and arg='%s'." % (sender, task, target))
  82.  
  83. # Start
  84. logThread = threading.Thread(target=log)
  85. logThread.daemon = True
  86. logThread.start()
  87. logLines.append("\n--- Engine startup ---\n")
  88.  
  89. print "--- D2jsp IRC bot by laz ---\n"
  90.  
  91. def connectIRC():
  92. irc = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  93. print "[IRC] Connecting to : " + server
  94.  
  95. irc.connect((server, port))
  96. print "[IRC] Connected..."
  97.  
  98. irc.send("NICK %s\r\n" % username)
  99. print "[IRC] Sent nick : " + username
  100.  
  101. irc.send("USER %s w * :%s\r\n" % (username, username))
  102. print "[IRC] Sent user : " + username
  103.  
  104. irc.send("HAUTH %s\r\n" % password)
  105. print "[IRC] Authenticated..."
  106.  
  107. return irc
  108.  
  109. irc = connectIRC()
  110. while True:
  111. try:
  112. text = irc.recv(2040)
  113. except:
  114. print "\nLost connection... Reconnecting\n"
  115. time.sleep(20)
  116. try:
  117. irc = connectIRC()
  118. except:
  119. print "..."
  120. continue
  121. if len(text) == 0:
  122. print "\nLost connection... Reconnecting\n"
  123. time.sleep(20)
  124. try:
  125. irc = connectIRC()
  126. except:
  127. print "..."
  128. continue
  129.  
  130. if text.endswith("\n"): # Remove newline
  131. text = text[:-1]
  132.  
  133. if text.startswith("PING :irc.d2jsp.org"):
  134. irc.send("PONG " + text.split() [1] + "\r\n")
  135. else:
  136. logLines.append(text) # Don't log ping/pong
  137.  
  138. if ":irc.d2jsp.org 650 " + username in text:
  139. print "\n[IRC] Bot is running!\n"
  140. Tkinter.Tk().bell()
  141.  
  142. elif text.startswith(":irc.d2jsp.org 651 " + username): # private message
  143. string = text.split(":")
  144. who = string[1].split(" ")[4]
  145. comment = string[2]
  146. print "[IRC] Received PM from '" + who + "' with subject '" + comment + "'"
  147.  
  148. elif text.startswith(":irc.d2jsp.org 652 " + username): # gold received
  149. string = text.split(":", 2)
  150. gold = string[1].split(" ")[6]
  151. who = string[1].split(" ")[4]
  152. comment = fixString(string[2].lower())
  153. print "[IRC] Received " + gold + " FG from '" + who + "' with comment '" + comment + "'"
  154.  
  155. # --- Jobs ---
  156.  
  157. # Grush
  158. if comment.startswith("grush/"):
  159. if who in VIP1:
  160. price = VIP1price
  161. elif who in VIP2:
  162. price = VIP2price
  163. else:
  164. price = rushPrice
  165. if float(gold) >= price:
  166. infos = comment.split("/")
  167. if len(infos) == 5:
  168. if infos[1].lower() in acceptJobsFrom:
  169. j = open(path, "a")
  170. j.write(comment.lower() + "\n")
  171. j.close()
  172. print "[SCRIPT] Job added : '" + comment + "'"
  173. logLines.append("[SCRIPT] Wrote job to file : " + comment + "\n")
  174. else:
  175. print "[SCRIPT] Not taking jobs from : '" + infos[1] + "'"
  176. else:
  177. print "[SCRIPT] Job infos missing or incorrect"
  178. else:
  179. print "[SCRIPT] Gold insufficient"
Add Comment
Please, Sign In to add comment