DyarWeb /
php-telegram-bot
| 1 | <?php |
||
| 2 | declare(strict_types=1); |
||
| 3 | |||
| 4 | namespace DyarWeb\SendRequest; |
||
| 5 | |||
| 6 | use DyarWeb\Base; |
||
| 7 | |||
| 8 | /** |
||
| 9 | * Class Send |
||
| 10 | * @package DyarWeb |
||
| 11 | */ |
||
| 12 | class Send |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @param int|string $chat_id |
||
| 16 | * @param string $text |
||
| 17 | * @param string|null $parse_mode |
||
| 18 | * @param bool $disable_web_page_preview |
||
| 19 | * @param bool $disable_notification |
||
| 20 | * @param int|null $reply_to_message_id |
||
| 21 | * @param array|null $reply_markup |
||
| 22 | * @return object |
||
| 23 | */ |
||
| 24 | public static function sendMessage($chat_id, $text, $parse_mode = null, $disable_web_page_preview = false, $disable_notification = false, $reply_to_message_id = null, $reply_markup = null) |
||
| 25 | { |
||
| 26 | $params = compact('chat_id', 'text', 'parse_mode', 'disable_web_page_preview', 'disable_notification', 'reply_to_message_id', 'reply_markup'); |
||
| 27 | |||
| 28 | return Base::sendRequest('sendMessage', $params); |
||
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param int|string $chat_id |
||
| 33 | * @param int $from_chat_id |
||
| 34 | * @param bool $disable_notification |
||
| 35 | * @param int $message_id |
||
| 36 | * @return object |
||
| 37 | */ |
||
| 38 | public static function forwardMessage($chat_id, $from_chat_id, $disable_notification = false, $message_id) |
||
| 39 | { |
||
| 40 | $params = compact('chat_id', 'from_chat_id', 'disable_notification', 'message_id'); |
||
| 41 | |||
| 42 | return Base::sendRequest('forwardMessage', $params); |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @param int|string $chat_id |
||
| 47 | * @param string $photo |
||
| 48 | * @param string|null $caption |
||
| 49 | * @param string|null $parse_mode |
||
| 50 | * @param bool $disable_notification |
||
| 51 | * @param int|null $reply_to_message_id |
||
| 52 | * @param array|null $reply_markup |
||
| 53 | * @return object |
||
| 54 | */ |
||
| 55 | public static function sendPhoto($chat_id, $photo, $caption = null, $parse_mode = null, $disable_notification = false, $reply_to_message_id = null, $reply_markup = null) |
||
| 56 | { |
||
| 57 | $data = compact('chat_id', 'photo', 'caption', 'parse_mode', 'disable_notification', 'reply_to_message_id', 'reply_markup'); |
||
| 58 | return Base::sendRequest('sendPhoto', $data); |
||
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @param int|string $chat_id |
||
| 63 | * @param string $audio |
||
| 64 | * @param string|null $caption |
||
| 65 | * @param string|null $parse_mode |
||
| 66 | * @param int|null $duration |
||
| 67 | * @param string|null $performer |
||
| 68 | * @param string|null $title |
||
| 69 | * @param string|null $thumb |
||
| 70 | * @param bool $disable_notification |
||
| 71 | * @param int|null $reply_to_message_id |
||
| 72 | * @param array|null $reply_markup |
||
| 73 | * @return object |
||
| 74 | */ |
||
| 75 | public static function sendAudio($chat_id, $audio, $caption = null, $parse_mode = null, $duration = null, $performer = null, $title = null, $thumb = null, $disable_notification = false, $reply_to_message_id = null, $reply_markup = null) |
||
| 76 | { |
||
| 77 | $data = compact('chat_id', 'audio', 'caption', 'parse_mode', 'duration', 'performer', 'title', 'thumb', 'disable_notification', 'reply_to_message_id', 'reply_markup'); |
||
| 78 | return Base::sendRequest('sendAudio', $data); |
||
| 79 | } |
||
| 80 | |||
| 81 | /** |
||
| 82 | * @param int|string $chat_id |
||
| 83 | * @param string $document |
||
| 84 | * @param string|null $thumb |
||
| 85 | * @param string|null $caption |
||
| 86 | * @param string|null $parse_mode |
||
| 87 | * @param bool $disable_notification |
||
| 88 | * @param int|null $reply_to_message_id |
||
| 89 | * @param array|null $reply_markup |
||
| 90 | * @return object |
||
| 91 | */ |
||
| 92 | public static function sendDocument($chat_id, $document, $thumb = null, $caption = null, $parse_mode = null, $disable_notification = false, $reply_to_message_id = null, $reply_markup = null) |
||
| 93 | { |
||
| 94 | $data = compact('chat_id', 'document', 'thumb', 'caption', 'parse_mode', 'disable_notification', 'reply_to_message_id', 'reply_markup'); |
||
| 95 | |||
| 96 | return Base::sendRequest('sendDocument', $data); |
||
| 97 | } |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @param int|string $chat_id |
||
| 101 | * @param string $video |
||
| 102 | * @param int|null $duration |
||
| 103 | * @param int|null $width |
||
| 104 | * @param int|null $height |
||
| 105 | * @param string|null $thumb |
||
| 106 | * @param string|null $caption |
||
| 107 | * @param string|null $parse_mode |
||
| 108 | * @param bool $supports_streaming |
||
| 109 | * @param bool $disable_notification |
||
| 110 | * @param int|null $reply_to_message_id |
||
| 111 | * @param array|null $reply_markup |
||
| 112 | * @return object |
||
| 113 | */ |
||
| 114 | public static function sendVideo($chat_id, $video, $duration = null, $width = null, $height = null, $thumb = null, $caption = null, $parse_mode = null, $supports_streaming = false, $disable_notification = false, $reply_to_message_id = null, $reply_markup = null) |
||
| 115 | { |
||
| 116 | $data = compact('chat_id', 'video', 'duration', 'width', 'height', 'thumb', 'caption', 'parse_mode', 'supports_streaming', 'disable_notification', 'reply_to_message_id', 'reply_markup'); |
||
| 117 | |||
| 118 | return Base::sendRequest('sendVideo', $data); |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * @param int|string $chat_id |
||
| 123 | * @param string $animation |
||
| 124 | * @param int|null $duration |
||
| 125 | * @param int|null $width |
||
| 126 | * @param int|null $height |
||
| 127 | * @param string|null $thumb |
||
| 128 | * @param string|null $caption |
||
| 129 | * @param string|null $parse_mode |
||
| 130 | * @param bool $supports_streaming |
||
| 131 | * @param bool $disable_notification |
||
| 132 | * @param int|null $reply_to_message_id |
||
| 133 | * @param array|null $reply_markup |
||
| 134 | * @return object |
||
| 135 | */ |
||
| 136 | public static function sendAnimation($chat_id, $animation, $duration = null, $width = null, $height = null, $thumb = null, $caption = null, $parse_mode = null, $supports_streaming = false, $disable_notification = false, $reply_to_message_id = null, $reply_markup = null) |
||
| 137 | { |
||
| 138 | $data = compact('chat_id', 'animation', 'duration', 'width', 'height', 'thumb', 'caption', 'parse_mode', 'supports_streaming', 'disable_notification', 'reply_to_message_id', 'reply_markup'); |
||
| 139 | |||
| 140 | return Base::sendRequest('sendAnimation', $data); |
||
| 141 | } |
||
| 142 | |||
| 143 | public static function sendVoice($chat_id, $voice, $duration = null, $caption = null, $parse_mode = null, $disable_notification = false, $reply_to_message_id = null, $reply_markup = null) |
||
| 144 | { |
||
| 145 | $data = compact('chat_id', 'voice', 'duration', 'caption', 'parse_mode', 'disable_notification', 'reply_to_message_id', 'reply_markup'); |
||
| 146 | |||
| 147 | return Base::sendRequest('sendVoice', $data); |
||
| 148 | } |
||
| 149 | |||
| 150 | /** |
||
| 151 | * @param int|string $chat_id |
||
| 152 | * @param string $video_note |
||
| 153 | * @param int|null $duration |
||
| 154 | * @param int|null $length |
||
| 155 | * @param string|null $thumb |
||
| 156 | * @param bool $disable_notification |
||
| 157 | * @param int|null $reply_to_message_id |
||
| 158 | * @param array|null $reply_markup |
||
| 159 | * @return object |
||
| 160 | */ |
||
| 161 | public static function sendVideoNote($chat_id, $video_note, $duration = null, $length = null, $thumb = null, $disable_notification = false, $reply_to_message_id = null, $reply_markup = null) |
||
| 162 | { |
||
| 163 | $data = compact('chat_id', 'video_note', 'duration', 'length', 'thumb', 'disable_notification', 'reply_to_message_id', 'reply_markup'); |
||
| 164 | |||
| 165 | return Base::sendRequest('sendVideoNote', $data); |
||
| 166 | } |
||
| 167 | |||
| 168 | #////////////////sendMediaGroup///////////////////// |
||
| 169 | |||
| 170 | /** |
||
| 171 | * @param int|string $chat_id |
||
| 172 | * @param float $latitude |
||
| 173 | * @param float $longitude |
||
| 174 | * @param int|null $live_period |
||
| 175 | * @param bool $disable_notification |
||
| 176 | * @param int|null $reply_to_message_id |
||
| 177 | * @param array|null $reply_markup |
||
| 178 | * @return object |
||
| 179 | */ |
||
| 180 | public static function sendLocation($chat_id, $latitude, $longitude, $live_period = null, $disable_notification = false, $reply_to_message_id = null, $reply_markup = null) |
||
| 181 | { |
||
| 182 | $params = compact('chat_id', 'latitude', 'longitude', 'live_period', 'disable_notification', 'reply_to_message_id', 'reply_markup'); |
||
| 183 | |||
| 184 | return Base::sendRequest('sendLocation', $params); |
||
| 185 | } |
||
| 186 | |||
| 187 | #////////////////////sendPoll && sendDice///////////////// |
||
| 188 | |||
| 189 | /** |
||
| 190 | * @param int|string $chat_id |
||
| 191 | * @param float $latitude |
||
| 192 | * @param float $longitude |
||
| 193 | * @param string $title |
||
| 194 | * @param string $address |
||
| 195 | * @param string|null $foursquare_id |
||
| 196 | * @param string|null $foursquare_type |
||
| 197 | * @param bool $disable_notification |
||
| 198 | * @param int|null $reply_to_message_id |
||
| 199 | * @param array|null $reply_markup |
||
| 200 | * @return object |
||
| 201 | */ |
||
| 202 | public static function sendVenue($chat_id, $latitude, $longitude, $title, $address, $foursquare_id = null, $foursquare_type = null, $disable_notification = false, $reply_to_message_id = null, $reply_markup = null) |
||
|
0 ignored issues
–
show
|
|||
| 203 | { |
||
| 204 | $params = compact('chat_id', 'latitude', 'longitude', 'title', 'address', 'foursquare_id', 'foursquare_type ', 'disable_notification', 'reply_to_message_id', 'reply_markup'); |
||
| 205 | |||
| 206 | return Base::sendRequest('sendVenue', $params); |
||
| 207 | } |
||
| 208 | |||
| 209 | /** |
||
| 210 | * @param int|string $chat_id |
||
| 211 | * @param string $phone_number |
||
| 212 | * @param string $first_name |
||
| 213 | * @param string|null $last_name |
||
| 214 | * @param string|null $vcard |
||
| 215 | * @param bool $disable_notification |
||
| 216 | * @param int|null $reply_to_message_id |
||
| 217 | * @param array|null $reply_markup |
||
| 218 | * @return object |
||
| 219 | */ |
||
| 220 | public static function sendContact($chat_id, $phone_number, $first_name, $last_name = null, $vcard = null, $disable_notification = false, $reply_to_message_id = null, $reply_markup = null) |
||
| 221 | { |
||
| 222 | $params = compact('chat_id', 'phone_number', 'first_name', 'last_name', 'vcard', 'disable_notification', 'reply_to_message_id', 'reply_markup'); |
||
| 223 | |||
| 224 | return Base::sendRequest('sendContact', $params); |
||
| 225 | } |
||
| 226 | |||
| 227 | /** |
||
| 228 | * @param int|string $chat_id |
||
| 229 | * @param string $action |
||
| 230 | * @return object |
||
| 231 | */ |
||
| 232 | public static function sendChatAction($chat_id, $action) |
||
| 233 | { |
||
| 234 | $actions = [ |
||
| 235 | 'typing', |
||
| 236 | 'upload_photo', |
||
| 237 | 'record_video', |
||
| 238 | 'upload_video', |
||
| 239 | 'record_audio', |
||
| 240 | 'upload_audio', |
||
| 241 | 'upload_document', |
||
| 242 | 'find_location', |
||
| 243 | 'record_video_note', |
||
| 244 | 'upload_video_note' |
||
| 245 | ]; |
||
| 246 | if (isset($action) && in_array($action, $actions)) { |
||
| 247 | $params = compact('chat_id', 'action'); |
||
| 248 | return Base::sendRequest('sendChatAction', $params); |
||
| 249 | } |
||
| 250 | throw new BotException('Invalid Action! Accepted value: ' . implode(', ', $actions)); |
||
|
0 ignored issues
–
show
The type
DyarWeb\SendRequest\BotException was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 251 | } |
||
| 252 | |||
| 253 | /** |
||
| 254 | * @param int|string $chat_id |
||
| 255 | * @param string $sticker |
||
| 256 | * @param bool $disable_notification |
||
| 257 | * @param int|null $reply_to_message_id |
||
| 258 | * @param array|null $reply_markup |
||
| 259 | * @return object |
||
| 260 | */ |
||
| 261 | public static function sendSticker($chat_id, $sticker, $disable_notification = false, $reply_to_message_id = null, $reply_markup = null) |
||
| 262 | { |
||
| 263 | $data = compact('chat_id', 'sticker', 'disable_notification', 'reply_to_message_id', 'reply_markup'); |
||
| 264 | |||
| 265 | return Base::sendRequest('sendSticker', $data); |
||
| 266 | } |
||
| 267 | |||
| 268 | // region Keyboard |
||
| 269 | |||
| 270 | /** |
||
| 271 | * @param array $inline_keyboard |
||
| 272 | * @return false|string |
||
| 273 | */ |
||
| 274 | public static function InlineKeyboardMarkup($inline_keyboard) |
||
| 275 | { |
||
| 276 | return json_encode(compact('inline_keyboard')); |
||
| 277 | } |
||
| 278 | |||
| 279 | /** |
||
| 280 | * @param array $keyboard |
||
| 281 | * @param bool $resize_keyboard |
||
| 282 | * @param bool $one_time_keyboard |
||
| 283 | * @param bool $selective |
||
| 284 | * @return false|string |
||
| 285 | */ |
||
| 286 | public static function replyKeyboardMarkup($keyboard, $resize_keyboard = false, $one_time_keyboard = false, $selective = false) |
||
| 287 | { |
||
| 288 | return json_encode(compact('keyboard', 'resize_keyboard', 'one_time_keyboard', 'selective')); |
||
| 289 | } |
||
| 290 | |||
| 291 | /** |
||
| 292 | * @param bool $selective |
||
| 293 | * @return false|string |
||
| 294 | */ |
||
| 295 | public static function ReplyKeyboardRemove($selective = false) |
||
| 296 | { |
||
| 297 | $remove_keyboard = true; |
||
| 298 | return json_encode(compact('remove_keyboard', 'selective')); |
||
| 299 | } |
||
| 300 | |||
| 301 | /** |
||
| 302 | * @param bool $selective |
||
| 303 | * @return false|string |
||
| 304 | */ |
||
| 305 | public static function forceReply($selective = false) |
||
| 306 | { |
||
| 307 | $force_reply = true; |
||
| 308 | return json_encode(compact('force_reply', 'selective')); |
||
| 309 | } |
||
| 310 | |||
| 311 | // endregion Keyboard |
||
| 312 | } |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.