Results 1 to 10 of 10

Thread: SRL-6 Messaging System

  1. #1
    Join Date
    Dec 2011
    Posts
    2,135
    Mentioned
    218 Post(s)
    Quoted
    1064 Post(s)

    Default SRL-6 Messaging System

    SRL-6 RS Messaging System

    Version 1.0

    This utility include file, when set up properly, will allow you to receive and respond to in-game PMs while your scripts are running via smartphone. You can also speak in public chat, remotely shut down your script, or log out. I am also working on screenshots of SMART being sent to your phone.

    Example in action:




    Supported Commands:
    !reply [Username] Message
    !reply [Public] Message
    !logout
    !terminate


    More commands will be added soon

    Setup Instructions:
    You will need to have a web server with mySQL and PHP support. If you do not have this, I am happy to provide a mySQL table for you from my own!

    These scripts assume a mySQL table (titled "Communicator") layout like so:



    Here are the PHP scripts I used. I'm a PHP novice, so I'm sure there are better/more optimal ways of doing this, but it worked for me so I was satisfied. I welcome any feedback.

    PHP Script - GroupMe Handler

    PHP Code:
    <?php

    # Based on a script by Sha1Sum, modified by Clarity

    class GroupMeBot {

        public 
    $group$id$user_id$group_id;
        
        public function 
    __construct($id) {
            
    $this->id $id;
        }
        
        public function 
    post($message) {
            
    $post_text utf8_encode($message);
            
            
    $ch curl_init();
            
    $post_contents = array(
                
    'bot_id' => $this->id,
                
    'text' => $post_text,
            );
            
            
    $post json_encode($post_contents);
            
            
    $arr = array();
            
    array_push($arr'Content-Type: application/json; charset=utf-8');
            
    curl_setopt($chCURLOPT_HTTPHEADER$arr);
            
    curl_setopt($chCURLOPT_URL'https://api.groupme.com/v3/bots/post');
            
    curl_setopt($chCURLOPT_POSTtrue);
            
    curl_setopt($chCURLOPT_POSTFIELDS$post);
            
    curl_exec($ch);
            
    curl_close($ch);
        }
    }

    $bot = new GroupMeBot('Your GroupMe Bot ID Here');

    $msg_json file_get_contents('php://input');
    $msg json_decode($msg_json);
    $user_id $msg->user_id;
    $group_id $msg->group_id;
    $inquirer_name $msg->name;
    $from $msg->name;
    $text $msg->text;

    if (!
    substr($text01) == '!')
        exit();

    $available_keywords = array(
        
    'reply',
        
    'logout',
        
    'terminate'
    );

    $no_trigger strtolower(substr($text1));
    $unstripped_keywords explode(' '$no_trigger);
    $keywords = array();
    foreach (
    $unstripped_keywords as $keyword) {
        
    $keywords[] = trim($keyword' ,');
    }

    if (
    in_array('reply'$keywords) || in_array('logout'$keywords) || in_array('terminate'$keywords)) {
        
        
    $username "mySQL username";  
        
    $password "mySQL password";  
        
    $database "mySQL database";
        
    $server "mySQL server address";      
        
    $db_handle mysql_connect($server$username$password); 
        
    $db_found mysql_select_db($database$db_handle);  

        if (
    $db_found) { 
            
    $SQL "SELECT * FROM Communicator WHERE ID = 1";
            
    $result mysql_query($SQL);
                if(
    $result){ 
                    
    $SQL "UPDATE `Communicator` SET `Reply` = '".$text."' WHERE `ID` = 1";
                    
    $result mysql_query($SQL); 
                    if(
    $result
                                print 
    "Success - command added."
                            else 
                                print 
    "Failure - command was not added.";
                }          
            } 
    }

    ?>


    PHP Script - Reply

    PHP Code:
    <?php
        $username 
    "mySQL username";  
        
    $password "mySQL password";  
        
    $database "mySQL database";
        
    $server "mySQL server address";      
        
    $db_handle mysql_connect($server$username$password); 
        
    $db_found mysql_select_db($database$db_handle);  

        if (
    $db_found) { 
            
    $SQL "SELECT * FROM Communicator WHERE ID = 1";
            
    $result mysql_query($SQL);
                if(
    $result){ 
                    while (
    $db_field mysql_fetch_assoc($result)){ 
                        
    $reply $db_field['Reply'];                
                    } 
                    if(
    $result
                                print 
    "$reply"
                            else 
                                print 
    "Failure.";
                } 
    }         
    ?>


    PHP Script - Clear

    PHP Code:
    <?php
        $username 
    "mySQL username";  
        
    $password "mySQL password";  
        
    $database "mySQL database";
        
    $server "mySQL server address";      
        
    $db_handle mysql_connect($server$username$password); 
        
    $db_found mysql_select_db($database$db_handle);   

        if (
    $db_found) { 
            
    $SQL "SELECT * FROM Communicator WHERE ID = 1";
            
    $result mysql_query($SQL);
                if(
    $result){ 
                    
    $SQL "UPDATE `Communicator` SET `Reply` = '".$command."' WHERE `ID` = 1";
                    
    $result mysql_query($SQL); 
                    if(
    $result
                                print 
    "Success - commands cleared."
                            else 
                                print 
    "Failure - commands were not cleared.";
                }          
            }
    ?>



    1. Download the free app GroupMe (https://groupme.com/) for your smartphone. This can also be used on a computer via https://app.groupme.com/signin.
    2. Create a new group chat titled "SRL Communicator" or something similar.
    3. Navigate to https://dev.groupme.com/bots and follow the steps to create a bot, selecting your new group chat as the bot's residency.
    4. Place the three PHP scripts somewhere where Simba and GroupMe will be able to access them.
    5. Set the Callback URL as your PHP GroupMe handler script location on your server.
    6. Remember your Bot ID, and place it inside the first script (GroupMe Handler) as indicated.
    7. Download the Communicator include.
    8. Use the test script below to try it out! Have a conversation with an alternate account of yours


    Simba Code:
    program communicatorTest;

    {$DEFINE SMART}
    {$i srl-6/srl.simba}
    {$i srl-6/lib/misc/communicator.simba}

    begin
      smartEnableDrawing := True;
      setupSRL();

      communicator.setup(10,                                 //No. of lines to scan
        '<Your GroupMe Bot ID Here>',                        //BotID
        'http://www.srlclarity.com/communicator/reply.php',  //ReplyPHPScriptURL
        'http://www.srlclarity.com/communicator/clear.php'); //ClearPHPScriptURL

      repeat
        communicator.updateGroupMe();
        communicator.processCommands();
        wait(random(5000, 10000));
      until false;

    end.

    Include Download: communicator.simba

    Enjoy! Please help me make this better by reporting any bugs or issues

    Credits:
    @Justin for helping me test PMing on him all night.
    Last edited by Clarity; 05-02-2015 at 04:43 PM.

  2. #2
    Join Date
    Sep 2010
    Posts
    5,754
    Mentioned
    136 Post(s)
    Quoted
    2736 Post(s)

    Default

    This looks pretty neat + rep


    BTW instead of making a record for TCommunicator you can make it a custom type (does the same thing but you don't have the access the field or whatever)

    Type
    TCommunicator = boolean;

  3. #3
    Join Date
    Dec 2014
    Posts
    188
    Mentioned
    3 Post(s)
    Quoted
    100 Post(s)

    Default

    Wow. You sir are epic.

  4. #4
    Join Date
    Aug 2014
    Location
    Australia
    Posts
    932
    Mentioned
    53 Post(s)
    Quoted
    495 Post(s)

    Default

    This is amazing, very well done.



    New to scripting? Procedures & Functions for Beginners
    Do you use your computer at night? Just get f.lux

  5. #5
    Join Date
    Mar 2013
    Location
    Argentina
    Posts
    758
    Mentioned
    27 Post(s)
    Quoted
    365 Post(s)

    Default



    this guy is on fire
    Formerly known as Undorak7

  6. #6
    Join Date
    May 2014
    Posts
    633
    Mentioned
    8 Post(s)
    Quoted
    322 Post(s)

    Default

    Epic, maybe I will turn pm on now

    Also a further extension of this would be to have it be able to respond when you are mentioned in clan chat

  7. #7
    Join Date
    Dec 2011
    Posts
    2,135
    Mentioned
    218 Post(s)
    Quoted
    1064 Post(s)

    Default

    Indeed, I am working on many more commands and features for more than private messaging!
    Thanks for the feedback everyone, I hope you find this useful!

    Quote Originally Posted by rj View Post
    BTW instead of making a record for TCommunicator you can make it a custom type (does the same thing but you don't have the access the field or whatever)

    Type
    TCommunicator = boolean;
    Thanks, I didn't know that. Will update
    Last edited by Clarity; 05-03-2015 at 01:49 AM.

  8. #8
    Join Date
    Oct 2012
    Posts
    1,233
    Mentioned
    39 Post(s)
    Quoted
    581 Post(s)

    Default

    seems like a lot of work when you could just...
    I'm personally not botting rs anymore but you can still get in touch with me via discord. I'm "acow" in the srl discord.

  9. #9
    Join Date
    Dec 2011
    Posts
    2,135
    Mentioned
    218 Post(s)
    Quoted
    1064 Post(s)

  10. #10
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,700
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Very nice idea! You know what would be cool, rather than just having reply/login/logout, the user could create their own 'response' and assign a procedure to the response. E.g., if you get a screenshot of a stuck bot you can tell it to reset itself, or you can tell it to bank when you want it to, etc.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •