[ADMIN] Email Commands to Server

Discussion in 'Archived: Plugin Requests' started by SPKuja, Jun 5, 2012.

  1. Offline

    SPKuja

    Plugin category: Admin

    Suggested name: ByYourCommand

    A bit about me: I'm pretty new into the Minecraft scene, but I now have my own server intergrated into my site. I love Battlestar Galactica (hence the name of the plugin ;) ) And I'm really hoping to have my site and server unified and have seemless transitions from one to the other!

    What I want: Okay, so basically, it's pretty simple (I think). All I would like, is a plugin that listens for emails from a certain address, and when it recieves said emails, it reads the contents, and if it is a command, it will execute it.

    I know there is a plugin out there called TextPlayer (Which I have tried, and is amazing), which does some thing like this, but unfortunatley it doesn't seem to like auto generated e-mails from an SMF server, some thing to do with the return e-mail address that is set to none by SMF I think.

    My over all plan is this:
    • Users post on my forum and gain credits
    • Users can use credits in the forum shop to buy in game items, eg, a dimond sword
    • The forum shop sends an email to a specified email address, with the command /give USER 276 1
    • The plugin reads the email (For example a gmail account), recognises the email address it is sent from (or maybe even a secret key that has to be put in the body of each email, as the users never see the content of the message that is sent)
    • The plugin executes the command and the user recieves their item
    Obviously, admins would also be able to email in other commands. Like server messages, commands to back up the server, the possibilites would be endless!

    Ideas for commands: Maybe just the one, eg: /byc check which could check for new messages on the email (Or just have it check every 60 seconds or so automatically)

    Ideas for permissions: Probably just byyourcommand.admin which would allow the user to use the check function?

    When I'd like it by: As soon as possible really :)

    Similar plugin requests: None that I know of

    Thanks in advance to any one that is interested in this idea :)
     
  2. Offline

    Elon_Than

    /give command will not work when user is offline (I think). What then?
     
  3. Offline

    SPKuja

    I already have a notice in each of the forums items that the user has to be online to receive the items, but maybe a log file that records the commands that are sent? That way if some one does it by accident when they are offline, the admin can view the log, see if they recieved the items, and give them the stuff manually?
     
  4. Offline

    Elon_Than

    I think there's better way to do this: from the forum side should be simple WebService with two methods (to get pending commands and to confirm performed commands).
    Plugin will check WS each minute and try to perform commands. When user is offline, command will not be confirmed as "done" so plugin will retry next time (until the user will be online).
    You don't have to add items manually when something went wrong (eg. user offline) :)
     
  5. Offline

    SPKuja

    That sounds like a better idea :)

    Though would it still be emails form the forums? As that is how the system is set up and I can't change it to some thing else (I'm using a mod for the forums)
     
  6. Offline

    Elon_Than

    Hmm, commands have to be in database to use WS, so it won't work in this case.

    In this case, plugin should get commands from e-mail and save failed commands in file and then retry them.
     
  7. Offline

    Deathmarine

    The problem that I see with this is that the minecraft server will have to have access to the mail server and maintain a constant connection to listen for the message sent. I mean it can be done under the right circumstances and development of mail client for java however there are more viable options to sending items to players via web as opposed to email. As for the offline issue, you can always cache the info and/or save it till the player logs in.

    Do you have a pop3 connection to your mail server? If so I can make this happen.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 26, 2016
  8. Offline

    SPKuja

    I believe I do, if not, I'm sure gmail does?
     
  9. Offline

    lol768

  10. Offline

    Norbo11

  11. Offline

    SPKuja

    lol768 I wouldn't know where to start with that... and as I explained, it needs to be able to recieve from the forum email

    Norbo11 I have buycraft but that is for using physical money, I want to be able to use the forum points system
     
  12. Offline

    Ne0nx3r0

    I sincerely doubt using email is the best way to do this, even if you already have everything in place but the plugin.

    For one thing, it opens a number of security holes that will be difficult to patch, unless you use some kind of signing/hashing algorithm.

    The way you do this is the server listens on a port for something, and the web site hands data to the server using a secret token only the web site and the server know.

    The "cheaper" way to do it is for the user to enter a command (or any other trigger such as onJoin) which then connects to a web service you have setup (again with a secret token) and requests whatever rewards the player has. The advantage here is no ports need to be opened for the service to be setup, and (slightly) less lag on the server.

    There might be a plugin out there to do this already for you, also you might be able to use UrlCommands.

    Something like this would work for simple rewards:
    Code:
    getmyrewards:
      url: http://www.yoursite.com/getrewards.php
      params: username
      data:
        key: secret_key_goes_here
        action:get_rewards
      resultConsoleCommand: "%commandToRun%"
      showPlayerResult: false
    
     
  13. Offline

    kezz101

    I agree with Neon here. Say someone got hold of that E-Mail! You'd be screwed!
     
  14. Offline

    SPKuja

    Then maybe through the plugin limit the commands that can be sent?
     
  15. Offline

    Ne0nx3r0

    *facepalm* Well, I have no interest in setting up an email digester.

    That said, good luck with this.
     
  16. Offline

    SPKuja

    Ne0nx3r0 Look, I don't know a lot about this, so keep your facepalms to your self. At the end of the day, I've listed what I need, and if no one wants to help then fine, I can live with out the automated system if need be and I'll give out coupons instead. It would be nice however to be able to have it all automated
     
  17. Offline

    Deathmarine

    I made a semi working version, but this isn't viable. My spam filter started catching the messages. Then my mail server banned my ip for too many connections considering the connection to the server can't be held open for some reason (javax.mail) but out of boredom I attempted it.

    Code:
    18:17:08 [SEVERE] javax.mail.AuthenticationFailedException: [IN-USE] Maximum num
    ber of connections from user+IP exceeded (mail_max_userip_connections)
    18:17:08 [SEVERE]      at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store
    .java:208)
    18:17:08 [SEVERE]      at javax.mail.Service.connect(Service.java:295)
    18:17:08 [SEVERE]      at javax.mail.Service.connect(Service.java:176)
    18:17:08 [SEVERE]      at com.modcrafting.emailcommand.Main$1.run(Main.java:124
    )
    18:17:08 [SEVERE]      at org.bukkit.craftbukkit.scheduler.CraftWorker.run(Craf
    tWorker.java:34)
    18:17:08 [SEVERE]      at java.lang.Thread.run(Unknown Source)
    
    It read one message which held the command /stop
     
  18. Offline

    np98765

    As it's been said, email isn't the best way to do this. There are a number of other options.

    You could set up a currency system. Depending on what forums you use, and all this other stuff, you would be able to link your forums to your server.

    Then, all you have to do is set up a shop. Instead of having this shop send an email, then have the email execute /give (hopefully the user is online), you would set up a shop... Without any emailing involved. My favorite is ChestShop. They click the sign of the item they want. No emailing, simple.

    The hardest part would be linking your forums to your server. There are many ways to do this, I'm sure, but I don't know which forum system you use, or what it can do, or anything of the sort.

    Even if I did, I wouldn't be able to help you regarding linking forums, but there are many who could.
     
  19. Offline

    SPKuja

    Looks like I'll just have to work out how to get TextPlayer working then. Thanks for at least attempting it though!
     
  20. Offline

    Ne0nx3r0

    I'm not making fun of you, I was annoyed because you glazed over the working options I gave you and ignored the warnings about email.

    What you want to accomplish is very easy, and it's been done thousands of times: one server is the "sender" and the other the "listener", and between the two you hand the data you want. Yes, it requires some custom web site code, but that's still much simpler, more secure, and more stable than trying to write a custom email handler.

    Introducing email into the equation is akin digging a river between you and the grocery store because you own a jet ski and want to save on gas mileage.
     

Share This Page