cgrunwald

Untitled

Jul 11th, 2010
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *  @author Juntalis
  3.  */
  4. var Parser =
  5. {
  6.     Data : {
  7.         Events:
  8.         [
  9.             {
  10.                 Name : "Bot.Loaded",
  11.                 Alias : "bot.start",
  12.                 ArgCount :  0,
  13.                 ArgValues : [],
  14.                 RegexCatch : /^TORIBASH\ 30$/m,
  15.                 RaiseEvent : function(event){}
  16.             },
  17.             {
  18.                 Name : "Bot.Ended",
  19.                 Alias : "bot.end",
  20.                 ArgCount :  0,
  21.                 ArgValues : [],
  22.                 RegexCatch : null,
  23.                 RaiseEvent : function(event){}
  24.             },
  25.             {
  26.                 Name : "Server.Message",
  27.                 Alias : "server.msg",
  28.                 ArgCount : 1,
  29.                 ArgValues :
  30.                 [
  31.                     {
  32.                         type : "String",
  33.                         alias : "msg"
  34.                     }
  35.                 ],
  36.                 RegexCatch : /^SAY\ 0;(.*?)$/m,
  37.                 RaiseEvent : function(event){}
  38.             },
  39.             {
  40.                 Name : "User.Join",
  41.                 Alias : "user.join",
  42.                 ArgCount :  1,
  43.                 ArgValues :
  44.                 [
  45.                     {
  46.                         type : "User",
  47.                         alias : "user"
  48.                     }
  49.                 ],
  50.                 RegexCatch : null,
  51.                 RaiseEvent : function(event){}
  52.             },
  53.             {
  54.                 Name : "User.Leave",
  55.                 Alias : "user.leave",
  56.                 ArgCount :  2,
  57.                 ArgValues :
  58.                 [
  59.                     {
  60.                         type : "User",
  61.                         alias : "user"
  62.                     },
  63.                     {
  64.                         type : "String",
  65.                         alias : "reason"
  66.                     }
  67.                 ],
  68.                 RegexCatch : /^DISCONNECT ([0-9]*?);(.*?) disconnected\.(.*?)$/m,
  69.                 RaiseEvent : function(event){}
  70.             },
  71.             {
  72.                 Name : "User.Say",
  73.                 Alias : "user.say",
  74.                 ArgCount :  2,
  75.                 ArgValues :
  76.                 [
  77.                     {
  78.                         type : "User",
  79.                         alias : "user"
  80.                     },
  81.                     {
  82.                         type : "String",
  83.                         alias : "msg"
  84.                     }
  85.                 ],
  86.                 RegexCatch :  /^SAY\ ([0-9]*?);(.*?):\ (.*?)$/m,
  87.                 RaiseEvent : function(event){}
  88.             },
  89.             {
  90.                 Name : "User.Whisper",
  91.                 Alias : "user.whisper",
  92.                 ArgCount :  2,
  93.                 ArgValues :
  94.                 [
  95.                     {
  96.                         type : "User",
  97.                         alias : "user"
  98.                     },
  99.                     {
  100.                         type : "String",
  101.                         alias : "msg"
  102.                     }
  103.                 ],
  104.                 RegexCatch : /^WHISPER\ 0;\*(.*?):\ (.*?)$/m,
  105.                 RaiseEvent : function(event){}
  106.             }
  107.         ],
  108.         Comparisons :
  109.         [
  110.             {
  111.                 Name : "Equals",
  112.                 Alias : "==",
  113.                 ArgumentTypes: "Any",
  114.                 Action : function(A,B) {
  115.                     return (A==B) ? true : false;  
  116.                 },
  117.                 FlagsPossible : [ "RX", "IC" ]
  118.             },
  119.             {
  120.                 Name : "Not Equal",
  121.                 Alias : "!=",
  122.                 ArgumentTypes: "Any",
  123.                 Action : function(A,B) {
  124.                     return (A!=B) ? true : false;  
  125.                 },
  126.                 FlagsPossible : [ "RX", "IC" ]
  127.             },
  128.             {
  129.                 Name : "Includes Anywhere",
  130.                 Alias : "*=",
  131.                 ArgumentTypes: "String",
  132.                 Action : function(A,B) {
  133.                     return (A.match(B) != null) ? true : false;
  134.                 },
  135.                 FlagsPossible : [ "IC", "RX", "SM"]
  136.             },
  137.             {
  138.                 Name : "Does Not Include Anywhere",
  139.                 Alias : "!*=",
  140.                 ArgumentTypes: "String",
  141.                 Action : function(A,B) {
  142.                     return (A.match(B) == null) ? true : false;
  143.                 },
  144.                 FlagsPossible : [ "IC", "RX"]
  145.             },
  146.             {
  147.                 Name : "Starts With",
  148.                 Alias : "^=",
  149.                 ArgumentTypes: "String",
  150.                 Action : function(A,B) {
  151.                     if (B.length > A.length) return false;
  152.                     return (A.substr(0,B.length) == B) ? true : false; 
  153.                 },
  154.                 FlagsPossible : [ "IC", "RX"]
  155.             },
  156.             {
  157.                 Name : "Does Not Starts With",
  158.                 Alias : "!^=",
  159.                 ArgumentTypes: "String",
  160.                 Action : function(A,B) {
  161.                     if (B.length > A.length) return true;
  162.                     return (A.substr(0,B.length) != B) ? true : false; 
  163.                 },
  164.                 FlagsPossible : [ "IC", "RX"]
  165.             },
  166.             {
  167.                 Name : "Ends With",
  168.                 Alias : "$=",
  169.                 ArgumentTypes: "String",
  170.                 Action : function(A,B) {
  171.                     if (B.length > A.length) return false;
  172.                     return (A.substr((B.length*(-1)),B.length) == B) ? true : false;
  173.                 },
  174.                 FlagsPossible : [ "IC", "RX"]
  175.             },
  176.             {
  177.                 Name : "Ends With",
  178.                 Alias : "!$=",
  179.                 ArgumentTypes: "String",
  180.                 Action : function(A,B) {
  181.                     if (B.length > A.length) return true;
  182.                     return (A.substr((B.length*(-1)),B.length) != B) ? true : false;
  183.                 },
  184.                 FlagsPossible : [ "IC", "RX"]
  185.             },
  186.             {
  187.                 Name : "Is Bigger Than",
  188.                 Alias : "!$=",
  189.                 ArgumentTypes: "Integer",
  190.                 Action : function(A,B) {
  191.                     return (A>B) ? true : false;
  192.                 },
  193.                 FlagsPossible : []
  194.             },
  195.             {
  196.                 Name : "Is Smaller Than",
  197.                 Alias : "!$=",
  198.                 ArgumentTypes: "Integer",
  199.                 Action : function(A,B) {
  200.                     return (A<B) ? true : false;
  201.                 },
  202.                 FlagsPossible : []
  203.             }
  204.         ],
  205.         Flags :
  206.         [
  207.             {
  208.                 Name : "Ignore Case",
  209.                 Alias : "IC"
  210.             },
  211.             {
  212.                 Name : "Regular Expression",
  213.                 Alias : "RX"
  214.             },
  215.             {
  216.                 Name : "Single Match",
  217.                 Alias : "SM"
  218.             }
  219.         ],
  220.         Methods :
  221.         [
  222.             {
  223.                 Name : "Say",
  224.                 Alias : "bot.say",
  225.                 ArgCount : 1,
  226.                 Arguments :
  227.                 [
  228.                     {
  229.                         name : "msg",
  230.                         type : "String"
  231.                     }
  232.                 ],
  233.                 Returns : null,
  234.                 Action : function(args){}
  235.             },
  236.             {
  237.                 Name : "Whisper User",
  238.                 Alias : "bot.whisper",
  239.                 ArgCount : 2,
  240.                 Arguments :
  241.                 [
  242.                     {
  243.                         name : "name",
  244.                         type : "String"
  245.                     },
  246.                     {
  247.                         name : "msg",
  248.                         type : "String"
  249.                     }
  250.                 ],
  251.                 Returns : null,
  252.                 Action : function(args){}
  253.             },
  254.             {
  255.                 Name : "Op User",
  256.                 Alias : "bot.op",
  257.                 ArgCount : 1,
  258.                 Arguments :
  259.                 [
  260.                     {
  261.                         name : "name",
  262.                         type : "String"
  263.                     }
  264.                 ],
  265.                 Returns : null,
  266.                 Action : function(args){}
  267.             },
  268.             {
  269.                 Name : "DeOp User",
  270.                 Alias : "bot.deop",
  271.                 ArgCount : 1,
  272.                 Arguments :
  273.                 [
  274.                     {
  275.                         name : "name",
  276.                         type : "String"
  277.                     }
  278.                 ],
  279.                 Returns : null,
  280.                 Action : function(args){}
  281.             },
  282.             {
  283.                 Name : "Kick User",
  284.                 Alias : "bot.kick",
  285.                 ArgCount : 1,
  286.                 Arguments :
  287.                 [
  288.                     {
  289.                         name : "name",
  290.                         type : "String"
  291.                     }
  292.                 ],
  293.                 Returns : null,
  294.                 Action : function(args){}
  295.             },
  296.             {
  297.                 Name : "Ban User",
  298.                 Alias : "bot.ban",
  299.                 ArgCount : 1,
  300.                 Arguments :
  301.                 [
  302.                     {
  303.                         name : "name",
  304.                         type : "String"
  305.                     }
  306.                 ],
  307.                 Returns : null,
  308.                 Action : function(args){}
  309.             },
  310.             {
  311.                 Name : "Centerprint",
  312.                 Alias : "bot.centerprint",
  313.                 ArgCount : 1,
  314.                 Arguments :
  315.                 [
  316.                     {
  317.                         name : "msg",
  318.                         type : "String"
  319.                     }
  320.                 ],
  321.                 Returns : null,
  322.                 Action : function(args){}
  323.             },
  324.             {
  325.                 Name : "HTTP Get",
  326.                 Alias : "http.get",
  327.                 ArgCount : 1,
  328.                 Arguments :
  329.                 [
  330.                     {
  331.                         name : "url",
  332.                         type : "String"
  333.                     }
  334.                 ],
  335.                 Returns : "String",
  336.                 Action : function(args){}
  337.             },
  338.             {
  339.                 Name : "HTTP Post",
  340.                 Alias : "http.post",
  341.                 ArgCount : 2,
  342.                 Arguments :
  343.                 [
  344.                     {
  345.                         name : "url",
  346.                         type : "String"
  347.                     },
  348.                     {
  349.                         name : "body",
  350.                         type : "String"
  351.                     }
  352.                 ],
  353.                 Returns : "String",
  354.                 Action : function(args){}
  355.             },
  356.             {
  357.                 Name : "Get MD5 Hash",
  358.                 Alias : "encode.md5",
  359.                 ArgCount : 1,
  360.                 Arguments :
  361.                 [
  362.                     {
  363.                         name : "str",
  364.                         type : "String"
  365.                     }
  366.                 ],
  367.                 Returns : "String",
  368.                 Action : function(args){}
  369.             },
  370.             {
  371.                 Name : "Base64 Encode",
  372.                 Alias : "encode.b64encode",
  373.                 ArgCount : 1,
  374.                 Arguments :
  375.                 [
  376.                     {
  377.                         name : "str",
  378.                         type : "String"
  379.                     }
  380.                 ],
  381.                 Returns : "String",
  382.                 Action : function(args){}
  383.             },
  384.             {
  385.                 Name : "Base64 Decode",
  386.                 Alias : "encode.b64decode",
  387.                 ArgCount : 1,
  388.                 Arguments :
  389.                 [
  390.                     {
  391.                         name : "str",
  392.                         type : "String"
  393.                     }
  394.                 ],
  395.                 Returns : "String",
  396.                 Action : function(args){}
  397.             },
  398.         ]
  399.     },
  400.     FormEvents : function()
  401.     {
  402.         $.each(Parser.Data.Events,
  403.             function(index, value) {
  404.                 var tmpEvent = value.Name + ": ";
  405.                 tmpEvent += "function(objEvent)";
  406.                 console.log(tmpEvent);
  407.                 tmpEvent = "objEvent = { Integer ArgCount, ";
  408.                 if (value.ArgCount > 0) {
  409.                     for(i=0; i <= value.ArgCount - 1; i++ ) {
  410.                         tmpEvent += value.ArgValues[i].type;
  411.                         tmpEvent += " ";
  412.                         tmpEvent += value.ArgValues[i].alias;
  413.                         tmpEvent += ", ";
  414.                     }              
  415.                 }
  416.                 tmpEvent += "String ReceivedLine}";
  417.                 console.log(tmpEvent);
  418.             }
  419.         );
  420.     }
  421. };
Add Comment
Please, Sign In to add comment