Skip to content

Commit 0b54b97

Browse files
author
darkdarin
committed
First release
1 parent d06cf1a commit 0b54b97

File tree

117 files changed

+4468
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

117 files changed

+4468
-0
lines changed

.editorconfig

+241
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
[*]
2+
charset = utf-8
3+
end_of_line = lf
4+
indent_size = 4
5+
indent_style = space
6+
insert_final_newline = true
7+
max_line_length = 120
8+
tab_width = 4
9+
ij_continuation_indent_size = 8
10+
ij_formatter_off_tag = @formatter:off
11+
ij_formatter_on_tag = @formatter:on
12+
ij_formatter_tags_enabled = false
13+
ij_smart_tabs = false
14+
ij_visual_guides = none
15+
ij_wrap_on_typing = false
16+
17+
[.editorconfig]
18+
ij_editorconfig_align_group_field_declarations = false
19+
ij_editorconfig_space_after_colon = false
20+
ij_editorconfig_space_after_comma = true
21+
ij_editorconfig_space_before_colon = false
22+
ij_editorconfig_space_before_comma = false
23+
ij_editorconfig_spaces_around_assignment_operators = true
24+
25+
[{*.yml,*.yaml}]
26+
indent_size = 2
27+
tab_width = 2
28+
29+
[{*.ctp,*.hphp,*.inc,*.module,*.php,*.php4,*.php5,*.phtml}]
30+
ij_continuation_indent_size = 4
31+
ij_php_align_assignments = false
32+
ij_php_align_class_constants = false
33+
ij_php_align_group_field_declarations = false
34+
ij_php_align_inline_comments = false
35+
ij_php_align_key_value_pairs = false
36+
ij_php_align_multiline_array_initializer_expression = false
37+
ij_php_align_multiline_binary_operation = false
38+
ij_php_align_multiline_chained_methods = false
39+
ij_php_align_multiline_extends_list = true
40+
ij_php_align_multiline_for = true
41+
ij_php_align_multiline_parameters = false
42+
ij_php_align_multiline_parameters_in_calls = true
43+
ij_php_align_multiline_ternary_operation = false
44+
ij_php_align_phpdoc_comments = false
45+
ij_php_align_phpdoc_param_names = false
46+
ij_php_anonymous_brace_style = end_of_line
47+
ij_php_api_weight = 28
48+
ij_php_array_initializer_new_line_after_left_brace = true
49+
ij_php_array_initializer_right_brace_on_new_line = true
50+
ij_php_array_initializer_wrap = on_every_item
51+
ij_php_assignment_wrap = off
52+
ij_php_attributes_wrap = off
53+
ij_php_author_weight = 28
54+
ij_php_binary_operation_sign_on_next_line = false
55+
ij_php_binary_operation_wrap = off
56+
ij_php_blank_lines_after_class_header = 0
57+
ij_php_blank_lines_after_function = 1
58+
ij_php_blank_lines_after_imports = 1
59+
ij_php_blank_lines_after_opening_tag = 1
60+
ij_php_blank_lines_after_package = 1
61+
ij_php_blank_lines_around_class = 1
62+
ij_php_blank_lines_around_constants = 0
63+
ij_php_blank_lines_around_field = 0
64+
ij_php_blank_lines_around_method = 1
65+
ij_php_blank_lines_before_class_end = 0
66+
ij_php_blank_lines_before_imports = 1
67+
ij_php_blank_lines_before_method_body = 0
68+
ij_php_blank_lines_before_package = 1
69+
ij_php_blank_lines_before_return_statement = 0
70+
ij_php_blank_lines_between_imports = 1
71+
ij_php_block_brace_style = end_of_line
72+
ij_php_call_parameters_new_line_after_left_paren = true
73+
ij_php_call_parameters_right_paren_on_new_line = true
74+
ij_php_call_parameters_wrap = on_every_item
75+
ij_php_catch_on_new_line = false
76+
ij_php_category_weight = 28
77+
ij_php_class_brace_style = next_line
78+
ij_php_comma_after_last_array_element = false
79+
ij_php_concat_spaces = true
80+
ij_php_copyright_weight = 28
81+
ij_php_deprecated_weight = 28
82+
ij_php_do_while_brace_force = always
83+
ij_php_else_if_style = combine
84+
ij_php_else_on_new_line = false
85+
ij_php_example_weight = 28
86+
ij_php_extends_keyword_wrap = off
87+
ij_php_extends_list_wrap = on_every_item
88+
ij_php_fields_default_visibility = private
89+
ij_php_filesource_weight = 28
90+
ij_php_finally_on_new_line = false
91+
ij_php_for_brace_force = always
92+
ij_php_for_statement_new_line_after_left_paren = true
93+
ij_php_for_statement_right_paren_on_new_line = true
94+
ij_php_for_statement_wrap = off
95+
ij_php_force_short_declaration_array_style = true
96+
ij_php_getters_setters_naming_style = camel_case
97+
ij_php_getters_setters_order_style = getters_first
98+
ij_php_global_weight = 28
99+
ij_php_group_use_wrap = on_every_item
100+
ij_php_if_brace_force = always
101+
ij_php_if_lparen_on_next_line = false
102+
ij_php_if_rparen_on_next_line = false
103+
ij_php_ignore_weight = 28
104+
ij_php_import_sorting = alphabetic
105+
ij_php_indent_break_from_case = true
106+
ij_php_indent_case_from_switch = true
107+
ij_php_indent_code_in_php_tags = false
108+
ij_php_internal_weight = 28
109+
ij_php_keep_blank_lines_after_lbrace = 0
110+
ij_php_keep_blank_lines_before_right_brace = 0
111+
ij_php_keep_blank_lines_in_code = 2
112+
ij_php_keep_blank_lines_in_declarations = 2
113+
ij_php_keep_control_statement_in_one_line = true
114+
ij_php_keep_first_column_comment = true
115+
ij_php_keep_indents_on_empty_lines = false
116+
ij_php_keep_line_breaks = true
117+
ij_php_keep_rparen_and_lbrace_on_one_line = true
118+
ij_php_keep_simple_classes_in_one_line = false
119+
ij_php_keep_simple_methods_in_one_line = false
120+
ij_php_lambda_brace_style = end_of_line
121+
ij_php_license_weight = 28
122+
ij_php_line_comment_add_space = false
123+
ij_php_line_comment_at_first_column = true
124+
ij_php_link_weight = 28
125+
ij_php_lower_case_boolean_const = true
126+
ij_php_lower_case_keywords = true
127+
ij_php_lower_case_null_const = true
128+
ij_php_method_brace_style = next_line
129+
ij_php_method_call_chain_wrap = off
130+
ij_php_method_parameters_new_line_after_left_paren = true
131+
ij_php_method_parameters_right_paren_on_new_line = true
132+
ij_php_method_parameters_wrap = on_every_item
133+
ij_php_method_weight = 28
134+
ij_php_modifier_list_wrap = false
135+
ij_php_multiline_chained_calls_semicolon_on_new_line = false
136+
ij_php_namespace_brace_style = 1
137+
ij_php_new_line_after_php_opening_tag = true
138+
ij_php_null_type_position = in_the_end
139+
ij_php_package_weight = 28
140+
ij_php_param_weight = 0
141+
ij_php_parameters_attributes_wrap = off
142+
ij_php_parentheses_expression_new_line_after_left_paren = false
143+
ij_php_parentheses_expression_right_paren_on_new_line = false
144+
ij_php_phpdoc_blank_line_before_tags = false
145+
ij_php_phpdoc_blank_lines_around_parameters = false
146+
ij_php_phpdoc_keep_blank_lines = true
147+
ij_php_phpdoc_param_spaces_between_name_and_description = 1
148+
ij_php_phpdoc_param_spaces_between_tag_and_type = 1
149+
ij_php_phpdoc_param_spaces_between_type_and_name = 1
150+
ij_php_phpdoc_use_fqcn = false
151+
ij_php_phpdoc_wrap_long_lines = false
152+
ij_php_place_assignment_sign_on_next_line = false
153+
ij_php_place_parens_for_constructor = 0
154+
ij_php_property_read_weight = 28
155+
ij_php_property_weight = 28
156+
ij_php_property_write_weight = 28
157+
ij_php_return_type_on_new_line = false
158+
ij_php_return_weight = 1
159+
ij_php_see_weight = 28
160+
ij_php_since_weight = 28
161+
ij_php_sort_phpdoc_elements = true
162+
ij_php_space_after_colon = true
163+
ij_php_space_after_colon_in_named_argument = true
164+
ij_php_space_after_colon_in_return_type = true
165+
ij_php_space_after_comma = true
166+
ij_php_space_after_for_semicolon = true
167+
ij_php_space_after_quest = true
168+
ij_php_space_after_type_cast = false
169+
ij_php_space_after_unary_not = false
170+
ij_php_space_before_array_initializer_left_brace = false
171+
ij_php_space_before_catch_keyword = true
172+
ij_php_space_before_catch_left_brace = true
173+
ij_php_space_before_catch_parentheses = true
174+
ij_php_space_before_class_left_brace = true
175+
ij_php_space_before_closure_left_parenthesis = true
176+
ij_php_space_before_colon = true
177+
ij_php_space_before_colon_in_named_argument = false
178+
ij_php_space_before_colon_in_return_type = false
179+
ij_php_space_before_comma = false
180+
ij_php_space_before_do_left_brace = true
181+
ij_php_space_before_else_keyword = true
182+
ij_php_space_before_else_left_brace = true
183+
ij_php_space_before_finally_keyword = true
184+
ij_php_space_before_finally_left_brace = true
185+
ij_php_space_before_for_left_brace = true
186+
ij_php_space_before_for_parentheses = true
187+
ij_php_space_before_for_semicolon = false
188+
ij_php_space_before_if_left_brace = true
189+
ij_php_space_before_if_parentheses = true
190+
ij_php_space_before_method_call_parentheses = false
191+
ij_php_space_before_method_left_brace = true
192+
ij_php_space_before_method_parentheses = false
193+
ij_php_space_before_quest = true
194+
ij_php_space_before_short_closure_left_parenthesis = true
195+
ij_php_space_before_switch_left_brace = true
196+
ij_php_space_before_switch_parentheses = true
197+
ij_php_space_before_try_left_brace = true
198+
ij_php_space_before_unary_not = false
199+
ij_php_space_before_while_keyword = true
200+
ij_php_space_before_while_left_brace = true
201+
ij_php_space_before_while_parentheses = true
202+
ij_php_space_between_ternary_quest_and_colon = false
203+
ij_php_spaces_around_additive_operators = true
204+
ij_php_spaces_around_arrow = false
205+
ij_php_spaces_around_assignment_in_declare = false
206+
ij_php_spaces_around_assignment_operators = true
207+
ij_php_spaces_around_bitwise_operators = true
208+
ij_php_spaces_around_equality_operators = true
209+
ij_php_spaces_around_logical_operators = true
210+
ij_php_spaces_around_multiplicative_operators = true
211+
ij_php_spaces_around_null_coalesce_operator = true
212+
ij_php_spaces_around_relational_operators = true
213+
ij_php_spaces_around_shift_operators = true
214+
ij_php_spaces_around_unary_operator = false
215+
ij_php_spaces_around_var_within_brackets = false
216+
ij_php_spaces_within_array_initializer_braces = false
217+
ij_php_spaces_within_brackets = false
218+
ij_php_spaces_within_catch_parentheses = false
219+
ij_php_spaces_within_for_parentheses = false
220+
ij_php_spaces_within_if_parentheses = false
221+
ij_php_spaces_within_method_call_parentheses = false
222+
ij_php_spaces_within_method_parentheses = false
223+
ij_php_spaces_within_parentheses = false
224+
ij_php_spaces_within_short_echo_tags = true
225+
ij_php_spaces_within_switch_parentheses = false
226+
ij_php_spaces_within_while_parentheses = false
227+
ij_php_special_else_if_treatment = false
228+
ij_php_subpackage_weight = 28
229+
ij_php_ternary_operation_signs_on_next_line = false
230+
ij_php_ternary_operation_wrap = off
231+
ij_php_throws_weight = 2
232+
ij_php_todo_weight = 28
233+
ij_php_unknown_tag_weight = 28
234+
ij_php_upper_case_boolean_const = false
235+
ij_php_upper_case_null_const = false
236+
ij_php_uses_weight = 28
237+
ij_php_var_weight = 28
238+
ij_php_variable_naming_style = mixed
239+
ij_php_version_weight = 28
240+
ij_php_while_brace_force = always
241+
ij_php_while_on_new_line = false

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.idea
2+
/vendor
3+
composer.lock

README.md

+37
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,39 @@
11
# telegram-bot-sdk
22
SDK for work with Telegram Bot API
3+
4+
Can be used standalone, and with Laravel 10 and Hyperf 3.0
5+
6+
This is an alpha version without full support for all API methods and all API objects.
7+
8+
Version Telegram Bot API: **6.9** (September 22, 2023)
9+
10+
### Supported methods
11+
* getUpdates (https://core.telegram.org/bots/api#getupdates)
12+
* setWebhook (https://core.telegram.org/bots/api#setwebhook)
13+
* deleteWebhook (https://core.telegram.org/bots/api#deletewebhook)
14+
* getWebhookInfo (https://core.telegram.org/bots/api#getwebhookinfo)
15+
* getMe (https://core.telegram.org/bots/api#getme)
16+
* sendMessage (https://core.telegram.org/bots/api#sendmessage)
17+
* forwardMessage (https://core.telegram.org/bots/api#forwardmessage)
18+
* copyMessage (https://core.telegram.org/bots/api#copymessage)
19+
* sendPhoto (https://core.telegram.org/bots/api#sendphoto)
20+
* sendAudio (https://core.telegram.org/bots/api#sendaudio)
21+
* sendDocument (https://core.telegram.org/bots/api#senddocument)
22+
* sendVideo (https://core.telegram.org/bots/api#sendvideo)
23+
* sendAnimation (https://core.telegram.org/bots/api#sendanimation)
24+
* sendVoice (https://core.telegram.org/bots/api#sendvoice)
25+
* sendVideoNote (https://core.telegram.org/bots/api#sendvideonote)
26+
* sendMediaGroup (https://core.telegram.org/bots/api#sendmediagroup)
27+
* sendLocation (https://core.telegram.org/bots/api#sendlocation)
28+
* sendVenue (https://core.telegram.org/bots/api#sendvenue)
29+
* sendContact (https://core.telegram.org/bots/api#sendcontact)
30+
* sendPoll (https://core.telegram.org/bots/api#sendpoll)
31+
* sendDice (https://core.telegram.org/bots/api#senddice)
32+
* sendChatAction (https://core.telegram.org/bots/api#sendchataction)
33+
* editMessageText (https://core.telegram.org/bots/api#editmessagetext)
34+
* editMessageCaption (https://core.telegram.org/bots/api#editmessagecaption)
35+
* editMessageLiveLocation (https://core.telegram.org/bots/api#editmessagelivelocation)
36+
* stopMessageLiveLocation (https://core.telegram.org/bots/api#stopmessagelivelocation)
37+
* editMessageReplyMarkup (https://core.telegram.org/bots/api#editmessagereplymarkup)
38+
* stopPoll (https://core.telegram.org/bots/api#stoppoll)
39+
* deleteMessage (https://core.telegram.org/bots/api#deletemessage)

composer.json

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"name": "darkdarin/telegram-bot-sdk",
3+
"description": "SDK for work with Telegram Bot API",
4+
"license": "MIT",
5+
"type": "package",
6+
"authors": [
7+
{
8+
"name": "Babushkin Pavel",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"autoload": {
13+
"psr-4": {
14+
"DarkDarin\\TelegramBotSdk\\": "src/"
15+
}
16+
},
17+
"require": {
18+
"php": "8.2.*|8.3.*",
19+
"darkdarin/serializer": "^1.3",
20+
"psr/http-client": "^1.0",
21+
"psr/http-factory": "^1.0",
22+
"psr/http-message": "^2.0",
23+
"psr-discovery/http-client-implementations": "^1.0",
24+
"psr-discovery/http-factory-implementations": "^1.0",
25+
"php-http/multipart-stream-builder": "^1.3"
26+
},
27+
"require-dev": {
28+
"laravel/pint": "^1.1",
29+
"illuminate/support": "^10.0",
30+
"hyperf/di": "~3.0.0",
31+
"roave/security-advisories": "dev-latest"
32+
},
33+
"extra": {
34+
"laravel": {
35+
"providers": [
36+
"DarkDarin\\TelegramBotSdk\\TelegramBotSdkServiceProvider"
37+
]
38+
},
39+
"hyperf": {
40+
"config": "DarkDarin\\TelegramBotSdk\\ConfigProvider"
41+
}
42+
},
43+
"config": {
44+
"allow-plugins": {
45+
"php-http/discovery": false
46+
}
47+
}
48+
}

config/telegram.php

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
return [
4+
'default' => 'default',
5+
6+
'bots' => [
7+
'default' => [
8+
'token' => env('TELEGRAM_BOT_TOKEN'),
9+
]
10+
]
11+
];

pint.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"preset": "per"
3+
}

src/ConfigProvider.php

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace DarkDarin\TelegramBotSdk;
4+
5+
use DarkDarin\TelegramBotSdk\Factories\PsrClientFactory;
6+
use DarkDarin\TelegramBotSdk\Factories\PsrRequestFactoryFactory;
7+
use DarkDarin\TelegramBotSdk\Factories\PsrResponseFactoryFactory;
8+
use DarkDarin\TelegramBotSdk\Factories\PsrStreamFactoryFactory;
9+
use DarkDarin\TelegramBotSdk\Factories\TelegramFactory;
10+
use DarkDarin\TelegramBotSdk\TransportClient\TransportClient;
11+
use DarkDarin\TelegramBotSdk\TransportClient\TransportClientInterface;
12+
use Psr\Http\Client\ClientInterface;
13+
use Psr\Http\Message\RequestFactoryInterface;
14+
use Psr\Http\Message\ResponseFactoryInterface;
15+
use Psr\Http\Message\StreamFactoryInterface;
16+
17+
class ConfigProvider
18+
{
19+
public function __invoke(): array
20+
{
21+
return [
22+
'dependencies' => [
23+
ClientInterface::class => PsrClientFactory::class,
24+
RequestFactoryInterface::class => PsrRequestFactoryFactory::class,
25+
ResponseFactoryInterface::class => PsrResponseFactoryFactory::class,
26+
StreamFactoryInterface::class => PsrStreamFactoryFactory::class,
27+
TransportClientInterface::class => TransportClient::class,
28+
Telegram::class => TelegramFactory::class,
29+
],
30+
'publish' => [
31+
[
32+
'id' => 'config',
33+
'description' => 'The config for telegram',
34+
'source' => __DIR__ . '/../config/telegram.php',
35+
'destination' => (defined('BASE_PATH') ? BASE_PATH : '') . '/config/autoload/telegram.php',
36+
],
37+
],
38+
39+
];
40+
}
41+
}

0 commit comments

Comments
 (0)