Advertisement
kolton

Untitled

May 8th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.32 KB | None | 0 0
  1. var D2Bot = {
  2. handle: 0,
  3.  
  4. init: function () {
  5. var handle = DataFile.getStats().handle;
  6.  
  7. if (handle) {
  8. this.handle = handle;
  9. }
  10.  
  11. return this.handle;
  12. },
  13.  
  14. sendMessage: function (handle, mode, msg) {
  15. sendCopyData(null, handle, mode, msg);
  16. },
  17.  
  18. printToConsole: function (msg, color, tooltip, trigger) {
  19. var printObj = {
  20. msg: msg,
  21. color: color || 0,
  22. tooltip: tooltip || "",
  23. trigger: trigger || ""
  24. },
  25.  
  26. obj = {
  27. profile: me.profile,
  28. func: "printToConsole",
  29. args: [JSON.stringify(printObj)]
  30. };
  31.  
  32. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  33. },
  34.  
  35. printToItemLog: function (itemObj) {
  36. var obj = {
  37. profile: me.profile,
  38. func: "printToItemLog",
  39. args: [JSON.stringify(itemObj)]
  40. };
  41.  
  42. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  43. },
  44.  
  45. writeToFile: function (filename, msg) {
  46. var obj = {
  47. profile: me.profile,
  48. func: "writeToFile",
  49. args: [filename, msg]
  50. };
  51.  
  52. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  53. },
  54.  
  55. postToIRC: function (ircProfile, recepient, msg) {
  56. var obj = {
  57. profile: me.profile,
  58. func: "postToIRC",
  59. args: [ircProfile, recepient, msg]
  60. };
  61.  
  62. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  63. },
  64.  
  65. ircEvent: function (mode) {
  66. var obj = {
  67. profile: me.profile,
  68. func: "ircEvent",
  69. args: [mode ? "true" : "false"]
  70. };
  71.  
  72. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  73. },
  74.  
  75. notify: function (msg) {
  76. var obj = {
  77. profile: me.profile,
  78. func: "notify",
  79. args: [msg]
  80. };
  81.  
  82. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  83. },
  84.  
  85. saveItem: function (itemObj) {
  86. var obj = {
  87. profile: me.profile,
  88. func: "saveItem",
  89. args: [JSON.stringify(itemObj)]
  90. };
  91.  
  92. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  93. },
  94.  
  95. updateStatus: function (msg) {
  96. var obj = {
  97. profile: me.profile,
  98. func: "updateStatus",
  99. args: [msg]
  100. };
  101.  
  102. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  103. },
  104.  
  105. updateRuns: function () {
  106. var obj = {
  107. profile: me.profile,
  108. func: "updateRuns",
  109. args: []
  110. };
  111.  
  112. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  113. },
  114.  
  115. updateChickens: function () {
  116. var obj = {
  117. profile: me.profile,
  118. func: "updateChickens",
  119. args: []
  120. };
  121.  
  122. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  123. },
  124.  
  125. updateDeaths: function () {
  126. var obj = {
  127. profile: me.profile,
  128. func: "updateDeaths",
  129. args: []
  130. };
  131.  
  132. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  133. },
  134.  
  135. requestGameInfo: function () {
  136. var obj = {
  137. profile: me.profile,
  138. func: "requestGameInfo",
  139. args: []
  140. };
  141.  
  142. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  143. },
  144.  
  145. restart: function (keySwap) {
  146. var obj = {
  147. profile: me.profile,
  148. func: "restartProfile",
  149. args: arguments.length > 0 ? [me.profile, keySwap] : [me.profile]
  150. };
  151.  
  152. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  153. },
  154.  
  155. CDKeyInUse: function () {
  156. var obj = {
  157. profile: me.profile,
  158. func: "CDKeyInUse",
  159. args: []
  160. };
  161.  
  162. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  163. },
  164.  
  165. CDKeyDisabled: function () {
  166. var obj = {
  167. profile: me.profile,
  168. func: "CDKeyDisabled",
  169. args: []
  170. };
  171.  
  172. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  173. },
  174.  
  175. CDKeyRD: function () {
  176. var obj = {
  177. profile: me.profile,
  178. func: "CDKeyRD",
  179. args: []
  180. };
  181.  
  182. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  183. },
  184.  
  185. stop: function (profile) {
  186. if (!profile) {
  187. profile = me.profile;
  188. }
  189.  
  190. var obj = {
  191. profile: me.profile,
  192. func: "stop",
  193. args: [profile]
  194. };
  195.  
  196. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  197. },
  198.  
  199. start: function (profile) {
  200. var obj = {
  201. profile: me.profile,
  202. func: "start",
  203. args: [profile]
  204. };
  205.  
  206. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  207. },
  208.  
  209. startSchedule: function (profile) {
  210. var obj = {
  211. profile: me.profile,
  212. func: "startSchedule",
  213. args: [profile]
  214. };
  215.  
  216. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  217. },
  218.  
  219. stopSchedule: function (profile) {
  220. var obj = {
  221. profile: me.profile,
  222. func: "stopSchedule",
  223. args: [profile]
  224. };
  225.  
  226. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  227. },
  228.  
  229. updateCount: function () {
  230. var obj = {
  231. profile: me.profile,
  232. func: "updateCount",
  233. args: ["1"]
  234. };
  235.  
  236. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  237. },
  238.  
  239. shoutGlobal: function (msg, mode) {
  240. var obj = {
  241. profile: me.profile,
  242. func: "shoutGlobal",
  243. args: [msg, mode]
  244. };
  245.  
  246. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  247. },
  248.  
  249. heartBeat: function () {
  250. var obj = {
  251. profile: me.profile,
  252. func: "heartBeat",
  253. args: []
  254. };
  255.  
  256. //print("ΓΏc1Heart beat " + this.handle);
  257. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  258. },
  259.  
  260. sendWinMsg: function (wparam, lparam) {
  261. var obj = {
  262. profile: me.profile,
  263. func: "winmsg",
  264. args: [wparam, lparam]
  265. };
  266.  
  267. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  268. },
  269.  
  270. ingame: function () {
  271. this.sendWinMsg(0x0086, 0x0000);
  272. this.sendWinMsg(0x0006, 0x0002);
  273. this.sendWinMsg(0x001c, 0x0000);
  274. },
  275.  
  276. // Profile to profile communication
  277. joinMe: function (profile, gameName, gameCount, gamePass, isUp) {
  278. var obj = {
  279. gameName: gameName + gameCount,
  280. gamePass: gamePass,
  281. inGame: isUp === "yes"
  282. };
  283.  
  284. sendCopyData(null, profile, 1, JSON.stringify(obj));
  285. },
  286.  
  287. requestGame: function (profile) {
  288. var obj = {
  289. profile: me.profile
  290. };
  291.  
  292. sendCopyData(null, profile, 3, JSON.stringify(obj));
  293. },
  294.  
  295. // Store info in d2bot# cache
  296. store: function (info) {
  297. this.remove();
  298.  
  299. var obj = {
  300. profile: me.profile,
  301. func: "store",
  302. args: [me.profile, info]
  303. };
  304.  
  305. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  306. },
  307.  
  308. // Get info from d2bot# cache
  309. retrieve: function () {
  310. var obj = {
  311. profile: me.profile,
  312. func: "retrieve",
  313. args: [me.profile]
  314. };
  315.  
  316. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  317. },
  318.  
  319. // Delete info from d2bot# cache
  320. remove: function () {
  321. var obj = {
  322. profile: me.profile,
  323. func: "delete",
  324. args: [me.profile]
  325. };
  326.  
  327. sendCopyData(null, this.handle, 0, JSON.stringify(obj));
  328. }
  329. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement