Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.11 KB | None | 0 0
  1. Var
  2. conName:string;
  3. tutorialhtml:string;
  4. codeWord:string;
  5. correctAnswer:String;
  6. parsedText:string;
  7. lastParse:string;
  8. Answers:TStringList;
  9. options:Tstringlist;
  10. links:Tstringlist;
  11. optionsCount:integer;
  12. parsedCount:integer;
  13. timerAnswer:TTimer;
  14. Items:TStringList;
  15. Names:TStringList;
  16. imgoptions:TStringList;
  17.  
  18. procedure Init;
  19. begin
  20. timerAnswer:=TTimer.Create(nil);
  21. timerAnswer.OnTimer:=@SendAnswer;
  22. timerAnswer.Enabled:=False;
  23. timerAnswer.Interval:=5000;
  24.  
  25. Answers:=TStringList.Create;
  26. options:=TStringList.Create;
  27. Items:=TStringList.Create;
  28. Names:=TStringList.Create;
  29. links:=TStringList.Create;
  30. imgoptions:=TStringList.Create;
  31.  
  32. Items.LoadFromFile('items.txt');
  33. Names.LoadFromFile('names.txt');
  34.  
  35. optionsCount:=0;
  36. parsedcount:=0;
  37. end;
  38.  
  39. procedure Free;
  40. begin
  41. timerAnswer.Free;
  42. Answers.Clear;
  43. options.clear;
  44. imgoptions.clear;
  45. links.clear;
  46. end;
  47.  
  48. function ViewHex(hstr:string):string;
  49. var
  50. idx:integer = 1;
  51. begin
  52. result:='';
  53. while (idx<=length(hstr)) do begin
  54. result:=result+format('%.2x ',[ord(hstr[idx])]);
  55. inc(idx);
  56. end;
  57. end;
  58.  
  59. procedure getoptions;
  60. var
  61. text:string=tutorialHTML;
  62. i,j,k:integer;
  63.  
  64. begin
  65. i:=pos('button value=',text);
  66. j:=1;
  67. while i<>0 do
  68. begin
  69. text:=copy(text,i+14,length(text));
  70. k:=pos('"',text);
  71. options.add(copy(text,0,k-1));
  72. j:=j+1;
  73. i:=pos('button value=',text);
  74. end;
  75. optionsCount:=j-1;
  76. end;
  77.  
  78. procedure getimgoptions;
  79. var
  80. i:integer;
  81. begin
  82. for i:=0 to optionsCount-1 do begin
  83. imgoptions.add(items[names.indexof(options[i])]);
  84. end;
  85. end;
  86.  
  87. function getImganswer():string;
  88. var
  89. i:integer;
  90. text:string=tutorialHTML;
  91. begin
  92. text:=copy(tutorialHTML,pos('Antibot',text),length(text));
  93. for i:=0 to optionsCount-1 do begin
  94. if pos(imgoptions[i],text)<>0 then
  95. result:=links[i];
  96. end;
  97. end;
  98.  
  99. function gettxtanswer():string;
  100. var
  101. i:integer;
  102. begin
  103. for i:=0 to optionsCount-1 do begin
  104. if options[i]=lastParse then
  105. result:=links[i];
  106. end;
  107. end;
  108.  
  109. procedure getlinks;
  110. var
  111. text:string=tutorialHTML;
  112. i,j,k:integer;
  113.  
  114. begin
  115. i:=pos('="link ',text);
  116. j:=1;
  117. while i<>0 do
  118. begin
  119. text:=copy(text,i+7,length(text));
  120. k:=pos('"',text);
  121. links.add(copy(text,0,k-1));
  122. j:=j+1;
  123. i:=pos('="link ',text);
  124. end;
  125.  
  126. end;
  127.  
  128. function parse(text:string):string;
  129. var
  130. parsedText:string;
  131. temp:string=text;
  132. i,j:integer;
  133. interbracket:string;
  134. begin
  135. i:=pos('>',temp);
  136. while i<>0 do
  137. begin
  138. if (copy(temp,i+1,1)<>'<') and (i+1<length(temp)) then
  139. begin
  140. j:=pos('<',copy(temp,i+1,length(temp)));
  141. interbracket:=copy(temp,i+1,j-1);
  142. parsedText:=parsedText+'//'+interbracket;
  143. lastParse:=interbracket;
  144. parsedcount:=parsedcount+1;
  145. end;
  146.  
  147. temp:=copy(temp,i+1,length(temp));
  148. i:=pos('>',temp);
  149.  
  150. end;
  151. result:=parsedText;
  152. end;
  153.  
  154.  
  155. procedure SendAnswer;
  156. var
  157. answer:string;
  158. begin
  159. buf:=Answers[1];
  160. Sendmsg(Answers[0]+' : '+ViewHex(buf));
  161. SendToServerEx(Answers[0]);
  162. Answers.Delete(0);
  163. Answers.Delete(0);
  164.  
  165. options.clear;
  166. imgoptions.clear;
  167. links.clear;
  168.  
  169. If Answers.Count=0 then timerAnswer.Enabled:=False;
  170. end;
  171. //main
  172. begin
  173. if fromserver then begin
  174. Case pck[1] of
  175. #$A0:begin
  176. conName:=ConnectName;
  177. tutorialHtml:=ReadS(2);
  178. if pos('Antibot',tutorialHtml)<>0 then
  179.  
  180. begin
  181. //tutorialhtml:='<html><body><center><img src=l2warland.fb_box_new height=110 width=120><br1><table><tr><td><img src=icon.weapon_imperial_staff_i00 height=32 width=32></td><td><img src=icon.weapon_heavens_divider_i00 height=32 width=32></td><td><img src=icon.weapon_demon_splinter_i00 height=32 width=32></td><td><img src=icon.weapon_basalt_battlehammer_i00 height=32 width=32></td><td><img src=icon.weapon_angel_slayer_i00 height=32 width=32></td></tr></table><font color="LEVEL">Antibot Protection</font><br>Check Code:<font color="LEVEL"><td><img src=icon.armor_t90_g_i00 width=32 height=32></td></font><br><button value="Blessed Scroll: Enchant Armor (Grade C)" action="link 100001" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="Blessed Scroll: Enchant Armor (Grade S)" action="link 100002" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="Blue Wolf Leather Armor" action="link 100003" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="Blue Wolf Tunic" action="link 100004" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="Major Arcana Gloves" action="link 100005" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"></center></body></html>';
  182.  
  183. //tutorialhtml:='<html><body><center><img src=l2warland.fb_box_new height=110 width=120><br1><table><tr><td><img src=icon.weapon_imperial_staff_i00 height=32 width=32></td><td><img src=icon.weapon_heavens_divider_i00 height=32 width=32></td><td><img src=icon.weapon_demon_splinter_i00 height=32 width=32></td><td><img src=icon.weapon_basalt_battlehammer_i00 height=32 width=32></td><td><img src=icon.weapon_angel_slayer_i00 height=32 width=32></td></tr></table><font color="LEVEL">Antibot Protection</font><br>Check Code:<font color="LEVEL"><td>Adonis</td></font><br><button value="soonni" action="link 100001" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="ossdoo" action="link 100002" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="isondA" action="link 100003" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="noiAid" action="link 100004" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"><button value="Adonis" action="link 100005" width=256 height=40 back="sm_icon.buttonon" fore="sm_icon.buttonoff"></center></body></html>';
  184. parsedText:= parse(tutorialHtml);
  185. sendmsg(parsedText);
  186. sendmsg(lastParse);
  187. getoptions;
  188. getlinks;
  189.  
  190.  
  191. sendmsg(options[0]+ ' '+options[1]+' '+options[2]+' '+options[3]+' '+options[4]);
  192. sendmsg(links[0]+ ' '+links[1]+' '+links[2]+' '+links[3]+' '+links[4]);
  193.  
  194.  
  195. if parsedcount=3 then
  196. begin //word
  197. sendmsg('it is a baby WORD');
  198. correctAnswer:=gettxtanswer();
  199.  
  200. end
  201. else
  202. begin //image
  203. sendmsg('it is a baby IMG');
  204. getimgoptions;
  205. sendmsg(imgoptions[0]+ ' '+imgoptions[1]+' '+imgoptions[2]+' '+imgoptions[3]+' '+imgoptions[4]);
  206. correctAnswer:=getimganswer();
  207.  
  208.  
  209. end;
  210.  
  211.  
  212. sendMsg(correctAnswer);
  213. sendMsg(conName);
  214.  
  215. buf:=hstr('7B');
  216. WriteS(correctAnswer);
  217. Answers.Add(conName);
  218. Answers.Add(buf);
  219. If Not(timerAnswer.enabled) then timerAnswer.enabled:=true;
  220. end;
  221.  
  222. end;
  223. end;
  224. end;
  225. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement