Filled MessageCommander (ChatListener)

Discussion in 'Archived: Plugin Requests' started by elkidz, Jul 21, 2014.

  1. Offline

    elkidz

    Plugin category: Admin Tools/Chat Related

    Suggested name: ChatListener

    What I want:
    I want a plugin that will detect/filter a message from the server (like a plugin or broadcast) and then automatically execute commands.

    Examples:

    ---------------------------------------------------------------------------
    Example 1

    (Broadcast) "There are 50 players online! Reward: $500"

    (Config)
    1:
    message:
    - There are 50 players online! Reward: $500
    commands:
    - give money 500 all (another plugin will do that)

    ---------------------------------------------------------------------------´

    #This second example will required a special variable.
    Example 2

    (Plugin) [SurvivalGames] Steve has won the survival games!

    2:
    message:
    - [SurvivalGames] Steve has won the survival games!
    variable: (%player%)
    - Steve
    commands:
    - %player% you just recieved 10 points!
    - points give %player% 10

    ---------------------------------------------------------------------------

    Ideas for commands: No commands needed for this plugin.
    Edit: This could have a useful command: /cl reload

    Ideas for permissions: No permissions needed for this plugin.

    When I'd like it by: ASAP

    If you have any question just ask. :)
     
  2. Offline

    wesley009

    I don't know if I have enough time to make this and whether it is even possible. But I like the idea, this way you could really customize plugin action with ease.
     
  3. Offline

    elkidz

    wesley009 I think that a plugin like this can open a lot of possibilities to server owners make their own combinations and improving features of another plugins.
     
  4. Offline

    elkidz

    BUMP! Edit: Better formatting (font size was too big :eek:) and better colors.
     
  5. Offline

    wesley009

    elkidz
    I found some helpful resources and I know enough to make a initial release.
    Expect it to not yet work with {user} or other variables tough.
     
  6. Offline

    elkidz

  7. Offline

    fromgate Retired Staff

    I have ready plugin created for same request that do something like you need. Can you provide more information about it: what is your input line?
    Or it could be any type of message?
    If I add regular expression support it - will it be useful for you?
     
  8. Offline

    elkidz

    fromgate
    The idea for this plugin is to be fully customisable with a config.yml that I can make my own things.

    Show Spoiler
    1:
    message:
    - something here
    commands:
    - commands here


    Doesn't need to be exactly like this but similar...
     
  9. Offline

    fromgate Retired Staff

    Ok. I have two plugins that I can mix in one. One is executing command according to special formatted line (supports: player chat, chat message, console (server log) and second is MessageFilter.

    I think tomorrow it will be finished (now I'm going to have some sleep ;))
     
  10. Offline

    elkidz

  11. Offline

    fromgate Retired Staff

    elkidz

    It finished, but need some tests. I hope tomorrow you'll find the result )

    MessageCommander (sorry, but I use another name :))
    https://dl.dropboxusercontent.com/u/64799811/MessageCommander/MessageCommander.jar

    This plugin is handle some sources of messages:
    You can globally disable handling of any source using config.yml file:

    Code:
    find-command-in-chat-input: true  # enable/disable player chat
    find-command-in-log: true # enable/disable server log source
    find-command-in-console-input: true # enable/disable console command source
    find-command-in-chat-output: true # enable/disable chat messages
    
    Note. When you try to catch message in chat-message, don't forget that message could be received by multiple players, so command will be executed for everyone. For example, you configured rule to catch message "There are 50 players online! Reward: $500" this message will see all players (50??) and 50 commands will be executed.


    How it works

    All rules in MessageCommander stored in files in "MessageCommander/rules" folder. You can add, modify or remove rules by editing rule files. Every rule base on some parameters:
    • Type— defines the method which will used to determine text in message (before display it on screen). There are five types:
      • EQUAL — case insensitive compare (Example: "Aaaa Bbbb" will be equal to "aaaa bbbb")
      • CONTAINS — find substring in input-message
      • START — check if message starts with provided text
      • END — check if message ends with provided text
      • REGEX — using regular expression to find matches
    • source — you can link any rule to any source:
      • ALL — any source
      • CHAT_PLAYER — Message typed by player in chat
      • CHAT_CONSOLE — Message (command) typed in server console
      • CHAT_MESSAGE — Message received by player in chat (message could be sent by player, plugin, mod...)
      • LOG — message in log (by plugin). Don't forget this message will include plugin name prefix ("[MessageCommander]", for example).
    • message-mask — defines input mask, that will used to find matches in original message
    • command-line — defines the command line that will executed. Use placeholder %player% to point to players name.
    • execute-as-console — if "true" command (provided in command-line) will executed by server console.
    • cooldown-time — time defined in format similar to time format used in ReActions plugin. Cooldown used to set up time-limit executing commands using this rule.

    Here is example:
    Code:
    test:
      type: EQUAL
      source: ALL
      message-mask: help me
      command-line: say %player% need help!
      execute-as-console: ture
      cooldown-time: 3s
    
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  12. Offline

    elkidz

    fromgate The plugin seems working perfectly on my test server but on my main server with all plugins disabled doesn't work. Have the same version of Bukkit. Weird...

    Server log: http://pastebin.com/L27QDpxd

    PS: Btw, is it possible make the custom variable? (Example 2) Can't be %player% because is already in use.
     
  13. Online

    timtower Moderator Moderator

    elkidz Install protocolLib
     
    fromgate likes this.
  14. Offline

    fromgate Retired Staff

    elkidz
    Oh! I forget to say that MessageCommander requires a ProtocolLib. It the best way to catch chat message now.


    About player variable - I can change it. But I think it will not be problem... What another plugin use this placeholder?

    Or! I understood. You need a part from original message? Ok. But there will be one problem. I need to think how to solve it.

    For your example:
    Code:
    message:
    - [SurvivalGames] Steve has won the survival games!
    variable: (%player%)
    - Steve
    commands:
    - %player% you just recieved 10 points!
    - points give %player% 10
    This message will see all players and command will be executed for every player. I will think how to execute only one command...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  15. Offline

    elkidz

    timtower Thanks it works now!


    fromgate No problem! Isn't necessary change the current one. I already saw plugins using custom variables like info board (I think). I was wondering using this for my minigames world too and then start working with a points system.

    Show Spoiler
    test:
    message:
    - [Minigame] Steve has won the minigame!
    variable: (%custom%)
    - Steve
    commands:
    - %custom% you just recieved 10 points!
    - points give %custom% 10


    It's like a replacer...

    EDIT: I didn't saw your last message. I was writting on that moment. lol
    Yes! You understood now.
     
  16. Offline

    fromgate Retired Staff

    elkidz
    Can you test this version:
    https://dl.dropboxusercontent.com/u/64799811/MessageCommander/MessageCommander.jar

    Using variables (like you suggest) requires additional parsing logic. I think we can use easier method.

    You can use every word of original message as placeholder in command.

    Example:
    Code:
    test:
      type: EQUAL
      source: ALL
      message-mask: help me
      command-line: say %player% need help! (%word1%)
      execute-as-console: false
      cooldown-time: 3s
    
    This rule will execute command /say fromgate need help! (help)

    Another one thing requires additional tests. Now if final command line and command executor (console or player) are equal, command must execute once only. Can you test it? I'm afraid that there could be some nuances...
     
  17. Offline

    elkidz

    fromgate I can't test right now. I will test later or maybe tomorrow.

    fromgate So... I test the new version and works well but I was thinking this system wrong... It will help me a lot but doesn't do all that I want. The example that I put in this thread isn't correct! (fail)
    If it's possible will be good if you add that (example):

    Code:
    rg1:
      type: EQUAL
      source: CONTAINS
      message-mask: You killed %copyplayername%
      command-line: eco give %pasteplayername% 10
      execute-as-console: true
      cooldown-time: 3s

    I don't know if it's possible. The "variables" that I put above can be another name. (It was just for you understand)
    This is only what is missing for me. MessageCommander is fantastic. :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  18. Offline

    fromgate Retired Staff

    elkidz
    "type" parameter is a type of compare method.
    • Type— defines the method which will used to determine text in message (before display it on screen). There are five types:
      • EQUAL — case insensitive compare (Example: "Aaaa Bbbb" will be equal to "aaaa bbbb")
      • CONTAINS — find substring in input-message (Example: if message mask is "hel" it would be found in input lines: "oh, hell", "hello my friend" and "I'm afraid helicopter sound"
      • START — check if message starts with provided text
      • END — check if message ends with provided text
      • REGEX — using regular expression to find matches

    Source - is place where to catch message. For example you can type text in server console, chat and receive message sent by any plugin:
    • source
      • ALL — any source
      • CHAT_PLAYER — Message typed by player in chat
      • CHAT_CONSOLE — Message (command) typed in server console
      • CHAT_MESSAGE — Message received by player in chat (message could be sent by player, plugin, mod...)
      • LOG — message in log (by plugin). Don't forget this message will include plugin name prefix ("[MessageCommander]", for example).
    I think most demanded is the CHAT_MESSAGE source. Any message displayed in client would be receive from this source :)


    I think this will work like you want:

    Code:
    rg1:
      type: START
      source: CHAT_MESSAGE
      message-mask: 'You killed '
      command-line: eco give %word3% 10
      execute-as-console: true
      cooldown-time: ''
    You see I'm using %word3% placeholder instead of %copyplayer% / %pasteplayer%.
    %word3% is always points to third word of source message.


    But I think usually best way to use regular expressions:

    Code:
    rg1:
      type: REGEX
      source: CHAT_MESSAGE
      message-mask: 'You killed \w+'
      command-line: eco give %word3% 10
      execute-as-console: true
      cooldown-time: ''
     
  19. Offline

    elkidz

    fromgate Oh... I didn't know that I can use an %word3% without the word on "message-mask". Yes works great! Thanks for this awesome plugin! You should put this on BukkitDev. xD
     
  20. Offline

    fromgate Retired Staff

    elkidz
    BukkitDev... yeah... I'm waiting six days for approval for my previous plugin :)

    I'm not sure that I will upload to bukkit dev this plugin. Anyway I'm going to make from it a module for my plugin ReActions. It would greatly increase ReActions' ability of integration with another plugins

    Uploaded to BukkitDev: http://dev.bukkit.org/bukkit-plugins/message-commander/
    But I cannot predict how many time approval process will take...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  21. Offline

    fromgate Retired Staff

    Now this feature was implemented in my plugin ReActions too (new version will be uploaded to BukkitDev after some tests).

     

Share This Page