1 | <?php |
||
11 | abstract class AbstractBot implements BotInterface, Matcher\MatcherAggregate |
||
12 | { |
||
13 | private $matcher; |
||
14 | private $responder; |
||
15 | |||
16 | /** |
||
17 | * @param Matcher\MatcherInterface $matcher |
||
18 | * @param array|ResponderInterface $options |
||
19 | */ |
||
20 | 11 | public function __construct($matcher = null, $options = []) |
|
21 | { |
||
22 | 11 | if (!$matcher) { |
|
23 | 9 | $matcher = new Matcher\DefaultMatcher(); |
|
24 | 8 | } |
|
25 | |||
26 | 11 | $this->setMatcher($matcher); |
|
27 | 11 | $this->responder = $options instanceof ResponderInterface ? $options : new Iterocitor($options); |
|
28 | 11 | } |
|
29 | |||
30 | /** |
||
31 | * @param Matcher\MatcherInterface $matcher |
||
32 | * |
||
33 | * @throws \Crummy\Phlack\Common\Exception\InvalidArgumentException When given an invalid matcher. |
||
34 | * |
||
35 | * @return $this |
||
36 | */ |
||
37 | 11 | public function setMatcher($matcher) |
|
50 | |||
51 | /** |
||
52 | * @return Matcher\MatcherInterface|callable |
||
53 | */ |
||
54 | 2 | public function getMatcher() |
|
58 | |||
59 | /** |
||
60 | * @param string $text |
||
61 | * |
||
62 | * @return \Crummy\Phlack\WebHook\Reply\Reply |
||
63 | */ |
||
64 | 2 | protected function say($text) |
|
68 | |||
69 | /** |
||
70 | * @param string $text |
||
71 | * |
||
72 | * @return \Crummy\Phlack\WebHook\Reply\Reply |
||
73 | */ |
||
74 | protected function emote($text) |
||
78 | |||
79 | /** |
||
80 | * @param string $user The user_id to tell |
||
81 | * @param string $text |
||
82 | * |
||
83 | * @return \Crummy\Phlack\WebHook\Reply\Reply |
||
84 | */ |
||
85 | protected function tell($user, $text) |
||
89 | |||
90 | /** |
||
91 | * @param \Crummy\Phlack\WebHook\CommandInterface $user The user_id, or a CommandInterface to inspect. |
||
92 | * @param string $text |
||
93 | * |
||
94 | * @return \Crummy\Phlack\WebHook\Reply\Reply |
||
95 | */ |
||
96 | 4 | protected function reply($user, $text) |
|
100 | |||
101 | /** |
||
102 | * @param string $text |
||
103 | * |
||
104 | * @return \Crummy\Phlack\WebHook\Reply\Reply |
||
105 | */ |
||
106 | protected function shout($text) |
||
110 | |||
111 | /** |
||
112 | * @param MessageInterface $message |
||
113 | * |
||
114 | * @return \Crummy\Phlack\WebHook\Reply\EmptyReply |
||
115 | */ |
||
116 | protected function send(MessageInterface $message) |
||
120 | } |
||
121 |