bone282

bone282

Joined
Mar 01, 2009

Activity Stream

bone282 commented on a Page, Switch Statement in msl  -  Mar 11, 2011

looks like someone has already made it.

http://www.mircscripts.org/showdoc.php?type=code&id=4491

its a great looking script btw, nice compact use of COM too.

 Respond  
bone282 commented on a Page, Switch Statement in msl  -  Mar 07, 2011

i think it has many practical uses. many site offer a JSON web service
even google offers a multitude:
youtube
dictionary
web search
translate
to name a few
And as for parsing, you could use a COM call to MSScriptControl.ScriptControl
but anyway, it seems im alone in thinking there is a practical use for this in mirc. ah well

 Respond  
bone282 commented on a Page, Switch Statement in msl  -  Mar 02, 2011

i dont use mIRC anymore. but, having a switch alias not too dissimilar in its use from the switch() function found in many languages. i like it. +rate +like.

love to see a json_decode alias next though ;]

 Respond  
bone282 commented on a Page, Truncation  -  Feb 26, 2011

yeah true, i was tired when i replied.
but who would pass an integer through that function. i suppose you could by getTrunc((string) $integer, 2);

but anyway, all i wanted to do was pass on the little - if (!isset($string{$count})){ - i like it and tbh it's pretty new to me :)

 Respond  
bone282 commented on a Page, Truncation  -  Feb 26, 2011

the braces would be before the explode() array, have a look :)

 Respond  
bone282 commented on a Page, Youtube Link Information --WORKING--  -  Feb 25, 2011

jethro, 99% of all youtube snippets on here are obselete, im well aware how easy scraping html is... have you checked a youtube page source lately? half of the data you want is nested in lengthy functions
did you even check the google youtube api jethro?

 Respond  
bone282 commented on a Page, Youtube Link Information --WORKING--  -  Feb 25, 2011

i know youtube is changing its html all the time, and parsing it is becoming harder.
One alternative to get youtube info cleanly, from a more stable source is googles own youtube api
http://code.google.com/apis/youtube/2.0/developers_guide_protocol.html

but the real challenge lies in someone making their own json_decode alias. but hell, you could just regex match the json string instead.
heres an example url for one result. and the query = the youtube url
http://gdata.youtube.com/feeds/api/videos?q=http://www.youtube.com/watch?v=Nrm8-vnSEfc&start-index=1&max-results=1&v=2&alt=json

ps: json services are very fast indeed
have phun.

 Respond  
bone282 commented on a Page, Truncation  -  Feb 24, 2011

One little tweek to make it a little faster is to use isset() instead of strlen(). This is because isset() is a language construct and not a function.

if ($l >= strlen($n)) return $n;
to:
if (!isset($n{$l})) return $n;

note using $string{$length} counts from zero.

 Respond  
bone282 commented on a Page, Truncation  -  Feb 09, 2011

looks quick n dirty, i like it

+like

 Respond  
bone282 commented on a Page, Random Image   -  Mar 27, 2010

i added the $fileType array

function dir2array($targetDir, &$fileType){
   $filesArray = array();
   if ($handle = opendir($targetDir)){
      while (false !== ($file = readdir($handle))){
         if(in_array(end(explode(".", $file)), $fileType)){
            $filesArray[] = $file;
            }
         }
         closedir($handle);
      }
   if (count($filesArray) > 0) {
      return $filesArray;
   } else {
      return FALSE;
      }
   }

// Usage Examples:

$arrayName = dir2array("path/to/directory", $arr = array("jpg", "png", "gif")); 
$randfile = $arrayName[array_rand($arrayName)];

if(FALSE !== ($arrayName = dir2array("path/to/directory", $arr = array("jpg", "png", "gif")))){ $randfile = $arrayName[array_rand($arrayName)]; }
 Respond  
bone282 commented on a Page, Random Image   -  Mar 26, 2010

this should meet what's required
and can be quickly edited to handle a $fileType array

// Put all files of a directory of A selected filetype into an array.

function dir2array($targetDir, $fileType){
    $filesArray = array();
    if ($handle = opendir($targetDir)){
        while (false !== ($file = readdir($handle))){
            if(end(explode(".", $file)) == $fileType){
                $filesArray[] = $file;
                }
            }
            closedir($handle);
        }
    if (count($filesArray) > 0) {
        return $filesArray;
    } else {
        return FALSE;
        }
    }

// Usage examples:

$arrayName = dir2array("path/to/directory", "jpg");
$randfile = $arrayName[array_rand($arrayName)];

if(FALSE !== ($arrayName = dir2array("path/to/directory", "png"))){ $randfile = $arrayName[array_rand($arrayName)]; }
 Respond  
bone282 commented on a Page, New Style of Bot Commander Final Release  -  May 22, 2009

you know what.. i think a regex manual snippet that echos to status or active might be a very handy tool indeed

 Respond  
bone282 commented on a Page, New Style of Bot Commander Final Release  -  May 19, 2009

sure you can keep the regex.
change \w+ to \S+ :P

an uppercase \S matches any none-whitespace character.
where as the \s matches a whitespace character.

 Respond  
bone282 commented on a Page, File Size using Binary Prefixes  -  May 16, 2009

yes

$file = 'yourfile.txt';
echo count(file($file));

or

$file = file('yourfile.txt');
echo count($file);

or

echo count(file('youfile.txt'));

 Respond  
bone282 commented on a Page, File Size using Binary Prefixes  -  May 16, 2009

a clever use of math there.

 Respond  
bone282 commented on a Page, Random Text  -  May 16, 2009

array_rand is handy for getting random values:

print($random_text[array_rand($random_text)]);


from a file:

$file = file("randomquotes.txt");
print(trim($file[array_rand($file)]));

 Respond  
bone282 commented on a Page, Metal Gear Solid (1-4) Memorable Quotes  -  May 07, 2009

is there no \r \n in mirc regex?

 Respond  
bone282 commented on a Page, Channel Regex Tester  -  May 06, 2009

i like it as as well. and thanks for the comment on the php bot i made.

 Respond  
bone282 commented on a Page, /explode - Split text  -  May 03, 2009

lol

 Respond  
bone282 commented on a Page, /explode - Split text  -  May 03, 2009

of course, it's the main other language i use, even though i hardly do it these days.
I used to code mIRC a long time ago. but, i really don't see the point in applying all that time and effort into a language thats of no use outside of mIRCLAND. Thats just my opinion though. Not trying to get on anyones tits. :P

 Respond  
bone282 commented on a Page, Basic PHP IRC Bot  -  May 03, 2009

by closing the socket. try using socket_ functions in php. example here http://www.hawkee.com/snippet/6076/

by the way killwithme, if you launch the script with a .bat file it uses cmd.exe as the bot window.

 Respond  
bone282 commented on a Page, /explode - Split text  -  May 02, 2009

nice to see someones still thinking about php

 Respond  
bone282 commented on a Page, Basic PHP IRC Bot  -  May 02, 2009

if you are getting "connection reset by peer". try running it NOT from your brower. just drop it in the same dir as php.exe and run from there. or add:

/ Prevent Script Stopping. /
ignore_user_abort(true);
set_time_limit(0);

 Respond  
bone282 commented on a Page, $php  -  May 02, 2009

you might want to add 'system' & 'shell_exec' as a disallowed function aswell

 Respond  
bone282 commented on a Page, Slots  -  Apr 28, 2009

tbh php is far less confusing than mirc. and a bad ass if you compare mirc sockets against php's diverse get functions esp cURL <3. if you want Mr. Aucun50.. i can give you a lil irc php bot package to play about with editing n what not

 Respond  
bone282 commented on a Page, Artificial Intelligence  -  Apr 24, 2009

The site seems to time out a lot, its not the bot doing it is it? Maybe its the timer?
It's the site.

 Respond  
bone282 commented on a Page, PHP IRC Bot v2  -  Apr 20, 2009

so you didn't like the array_shift idea then? I think its so much easier for users to add stuff if a switch already is made.

$message = explode(" ", $message);
$trigger = array_shift($message);
$message = implode(" ", $message);

switch(strtolower($trigger)){
case "!blah":
do blah blah;
break;

 Respond  
bone282 commented on a Page, PHP IRC Bot v2  -  Apr 20, 2009

Its for user events only. Like i said use the "$ex ARRAY" for other events.

Can you give an example of how to implement triggers?

 Respond  
bone282 commented on a Page, PHP IRC Bot v2  -  Apr 19, 2009

I also noticed a problem with mIRC colours in unicode. If a sentence starts with a number, the first number of that sentence is incorporated in the unicode. thus, resulting in a normal coloured sentence with the first char missing.

But after some exploring i discovered "chr(3) is the mIRC equivalent on CTRL+K".
Just prefix any mIRC colour with a value < 10 with a zero to prevent the same crap happening
chr(3).'08,04hello'; <-- yellow foreground and red background.
chr(3).'14blah blah'; <-- gray text..

Hope it helps someone.

 Respond  
bone282 commented on a Page, PHP IRC Bot v2  -  Apr 19, 2009

you could try this it may be slower than explode but you're only talking milliseconds..

/ Create An Infinite Loop.
while(1) {
    while($data = fgets($socket)) {

        /* Seperate All Data */
        preg_match("/^:(.*?)!(.*?)@(.*?)[\s](.*?)[\s](.*?)[\s]:(.*?)$/",$data, $rawdata);
        $nick = $rawdata[1];
        $ident = $rawdata[2];
        $host = $rawdata[3];
        $msg_type = $rawdata[4];
        $channel = $rawdata[5]; 
        $message = rtrim($rawdata[6]);
        $ex = explode(' ', $data);

        /* Create the Commands Trigger */
        $message = explode(" ", trim($message));
        $trigger = array_shift($message);
        $message = implode(" ", $message);

        /* Send PONG Back To The Server. */
        if($ex[0] == "PING"){ fputs($socket, "PONG ".$ex[1]."\n"); }
        ...
        ...

But keep using the $ex array for IRC events other than user events.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.