You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

package-info.java 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. * Copyright (c) 2006-2015 DMDirc Developers
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy
  5. * of this software and associated documentation files (the "Software"), to deal
  6. * in the Software without restriction, including without limitation the rights
  7. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. * copies of the Software, and to permit persons to whom the Software is
  9. * furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  20. * SOFTWARE.
  21. */
  22. /**
  23. * 'Actions' provide a way for users to execute commands in response to certain events.
  24. *
  25. * <h2>Action types and meta-types</h2>
  26. *
  27. * Actions are executed in response to events in the client. Each event has a corresponding
  28. * {@link com.dmdirc.interfaces.actions.ActionType}, which has both a user-friendly name and an
  29. * internal name, as well as a meta-type which describes the arguments it takes.
  30. *
  31. * <p>
  32. * For example, when a message on a channel is received, the client looks for actions that respond
  33. * to the {@link com.dmdirc.actions.CoreActionType#CHANNEL_MESSAGE} action type. The channel message
  34. * type has a meta-type of
  35. * {@link com.dmdirc.actions.metatypes.ChannelEvents#CHANNEL_SOURCED_EVENT_WITH_ARG} which says that
  36. * the event will come with three arguments: a channel, a user, and a message. It also defines the
  37. * types of those arguments ({@link com.dmdirc.Channel},
  38. * {@link com.dmdirc.parser.interfaces.ChannelClientInfo}, and {@link java.lang.String}
  39. * respectively).
  40. *
  41. * <h2>Conditions</h2>
  42. *
  43. * Before an action is executed, its 'conditions' are checked. These are a simple collection of
  44. * rules concerning the state of the client, or the event's arguments. There are two types of
  45. * condition: component-based and string-based.
  46. *
  47. * <p>
  48. * Component-based conditions start off with one of the action's arguments, and then apply one or
  49. * more components to it to get some useful property. Components all implement
  50. * {@link com.dmdirc.interfaces.actions.ActionComponent} and essentially transform one object into
  51. * another, somehow. A component may take a {@link com.dmdirc.Channel} object and return that
  52. * channel's name as a string, or could take a string and return the length of it as an integer
  53. * (these components are implemented in {@link com.dmdirc.actions.CoreActionComponent#CHANNEL_NAME}
  54. * and {@link com.dmdirc.actions.CoreActionComponent#STRING_LENGTH}).
  55. *
  56. * <p>
  57. * A component based action could be as simple as "the message's content", or as complicated as "the
  58. * channel's server's network name's length". These chains of components are handled by an
  59. * {@link ActionComponentChain}.
  60. *
  61. * <p>
  62. * String-based conditions simply start off with a plain string, which is subject to substitution as
  63. * described below.
  64. *
  65. * <p>
  66. * Action conditions also specify a comparison. These define various methods of comparing objects,
  67. * such as checking two strings are equal
  68. * ({@link com.dmdirc.actions.CoreActionComparison#STRING_EQUALS}) or that an integer is greater
  69. * than a pre-defined value ({@link com.dmdirc.actions.CoreActionComparison#INT_GREATER}). All
  70. * comparisons implement {@link com.dmdirc.interfaces.actions.ActionComparison}. The second argument
  71. * is always a string provided by the user.
  72. *
  73. * <p>
  74. * Finally, if more than one condition is present the user can decide how they are matched. The two
  75. * most common and straight-forward options are a conjunction (where all the conditions must be
  76. * true) and a disjunction (where one of the conditions must be true). Users can also specify their
  77. * own, more complicated, rules such as "condition 1 AND (condition 2 OR condition 3)". These are
  78. * all expressed as a {@link ConditionTree}.
  79. *
  80. * <h2>Commands and substitutions</h2>
  81. *
  82. * When an action is triggered and its conditions are satisfied, it will execute a set of user
  83. * specified commands. These are executed on the relevant
  84. * {@link com.dmdirc.commandparser.parsers.CommandParser}, so are interpreted as though the user
  85. * typed them in the window where the event occurred. For example if in response to a channel
  86. * message the user had entered the command {@code /part}, then the client would part the channel
  87. * where the message was received.
  88. *
  89. * <p>
  90. * Commands and condition arguments are subject to action substitutions. This allows users to
  91. * include various dynamic properties in their responses or conditions. Substitutions are prefixed
  92. * with a {@code $} character, and come in several varieties:
  93. *
  94. * <ul>
  95. * <li>Configuration keys. Any setting in the 'actions' domain with the key 'key' can be substituted
  96. * using {@code $key}.</li>
  97. * <li>Words. Events that include a message allow substitution of individual words in the form
  98. * {@code $n} or ranges in the form {@code $n-} or {@code $n-m}, for some indices n and m.</li>
  99. * <li>Argument components. Any argument that is part of the action may be substituted in using the
  100. * format {@code ${n.component}}, where 'n' is the index of the argument and 'component' is the name
  101. * of the component to apply to it. Multiple components may be chained together:
  102. * {@code ${n.component1.component2}}.</li>
  103. * <li>Connection components. For convenience, any event that is triggered within the context of a
  104. * connection allows a shorthand form for connection-based substitutions. This is the same as an
  105. * argument-based substitution, but without the argument number. The substituter locates an
  106. * appropriate argument it can obtain a {@link com.dmdirc.interfaces.Connection} from and applies
  107. * the component to the relevant connection directly.</li>
  108. * </ul>
  109. */
  110. package com.dmdirc.actions;