Skip to content

Commit ca640dc

Browse files
committed
feat: allow owner reply with only message copy
1 parent c8697da commit ca640dc

File tree

5 files changed

+206
-6
lines changed

5 files changed

+206
-6
lines changed

pmcenter/.editorconfig

+187
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
[*.cs]
22

3+
max_line_length = 120
4+
35
# CA1303: Do not pass literals as localized parameters
46
dotnet_diagnostic.CA1303.severity = none
57

@@ -38,3 +40,188 @@ dotnet_diagnostic.CA2234.severity = suggestion
3840

3941
# CA2227: Collection properties should be read only
4042
dotnet_diagnostic.CA2227.severity = suggestion
43+
44+
[*.cs]
45+
#### 命名样式 ####
46+
47+
# 命名规则
48+
49+
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion
50+
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
51+
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
52+
53+
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion
54+
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
55+
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
56+
57+
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion
58+
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
59+
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
60+
61+
# 符号规范
62+
63+
dotnet_naming_symbols.interface.applicable_kinds = interface
64+
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
65+
dotnet_naming_symbols.interface.required_modifiers =
66+
67+
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
68+
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
69+
dotnet_naming_symbols.types.required_modifiers =
70+
71+
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
72+
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
73+
dotnet_naming_symbols.non_field_members.required_modifiers =
74+
75+
# 命名样式
76+
77+
dotnet_naming_style.begins_with_i.required_prefix = I
78+
dotnet_naming_style.begins_with_i.required_suffix =
79+
dotnet_naming_style.begins_with_i.word_separator =
80+
dotnet_naming_style.begins_with_i.capitalization = pascal_case
81+
82+
dotnet_naming_style.pascal_case.required_prefix =
83+
dotnet_naming_style.pascal_case.required_suffix =
84+
dotnet_naming_style.pascal_case.word_separator =
85+
dotnet_naming_style.pascal_case.capitalization = pascal_case
86+
87+
dotnet_naming_style.pascal_case.required_prefix =
88+
dotnet_naming_style.pascal_case.required_suffix =
89+
dotnet_naming_style.pascal_case.word_separator =
90+
dotnet_naming_style.pascal_case.capitalization = pascal_case
91+
csharp_using_directive_placement = outside_namespace:silent
92+
csharp_style_expression_bodied_methods = false:silent
93+
csharp_style_expression_bodied_constructors = false:silent
94+
csharp_style_expression_bodied_operators = false:silent
95+
csharp_style_expression_bodied_properties = true:silent
96+
csharp_style_expression_bodied_indexers = true:silent
97+
csharp_style_expression_bodied_accessors = true:silent
98+
csharp_style_expression_bodied_lambdas = true:silent
99+
csharp_style_expression_bodied_local_functions = false:silent
100+
csharp_style_conditional_delegate_call = true:suggestion
101+
csharp_style_var_for_built_in_types = false:silent
102+
csharp_style_var_when_type_is_apparent = false:silent
103+
csharp_space_between_method_declaration_name_and_open_parenthesis = false
104+
csharp_space_between_method_declaration_parameter_list_parentheses = false
105+
csharp_space_around_binary_operators = before_and_after
106+
csharp_indent_labels = one_less_than_current
107+
csharp_style_var_elsewhere = false:silent
108+
csharp_prefer_simple_using_statement = true:suggestion
109+
csharp_prefer_braces = true:silent
110+
csharp_style_namespace_declarations = block_scoped:silent
111+
csharp_style_prefer_top_level_statements = true:silent
112+
csharp_style_prefer_method_group_conversion = true:silent
113+
csharp_style_prefer_primary_constructors = true:suggestion
114+
csharp_prefer_static_local_function = true:suggestion
115+
csharp_prefer_static_anonymous_function = true:suggestion
116+
csharp_style_prefer_readonly_struct = true:suggestion
117+
csharp_style_prefer_readonly_struct_member = true:suggestion
118+
csharp_style_allow_embedded_statements_on_same_line_experimental = true:silent
119+
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:silent
120+
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = true:silent
121+
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
122+
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
123+
csharp_style_prefer_switch_expression = true:suggestion
124+
csharp_style_prefer_pattern_matching = true:silent
125+
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
126+
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
127+
csharp_style_prefer_not_pattern = true:suggestion
128+
csharp_style_prefer_extended_property_pattern = true:suggestion
129+
csharp_style_throw_expression = true:suggestion
130+
csharp_style_prefer_null_check_over_type_check = true:suggestion
131+
csharp_prefer_simple_default_expression = true:suggestion
132+
csharp_style_prefer_local_over_anonymous_function = true:suggestion
133+
csharp_style_prefer_index_operator = true:suggestion
134+
csharp_style_prefer_range_operator = true:suggestion
135+
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
136+
csharp_style_prefer_tuple_swap = true:suggestion
137+
csharp_style_prefer_utf8_string_literals = true:suggestion
138+
csharp_style_inlined_variable_declaration = true:suggestion
139+
csharp_style_deconstructed_variable_declaration = true:suggestion
140+
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
141+
csharp_style_unused_value_expression_statement_preference = discard_variable:silent
142+
143+
[*.vb]
144+
#### 命名样式 ####
145+
146+
# 命名规则
147+
148+
dotnet_naming_rule.interface_should_be_以_i_开始.severity = suggestion
149+
dotnet_naming_rule.interface_should_be_以_i_开始.symbols = interface
150+
dotnet_naming_rule.interface_should_be_以_i_开始.style = 以_i_开始
151+
152+
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.severity = suggestion
153+
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.symbols = 类型
154+
dotnet_naming_rule.类型_should_be_帕斯卡拼写法.style = 帕斯卡拼写法
155+
156+
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.severity = suggestion
157+
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.symbols = 非字段成员
158+
dotnet_naming_rule.非字段成员_should_be_帕斯卡拼写法.style = 帕斯卡拼写法
159+
160+
# 符号规范
161+
162+
dotnet_naming_symbols.interface.applicable_kinds = interface
163+
dotnet_naming_symbols.interface.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
164+
dotnet_naming_symbols.interface.required_modifiers =
165+
166+
dotnet_naming_symbols.类型.applicable_kinds = class, struct, interface, enum
167+
dotnet_naming_symbols.类型.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
168+
dotnet_naming_symbols.类型.required_modifiers =
169+
170+
dotnet_naming_symbols.非字段成员.applicable_kinds = property, event, method
171+
dotnet_naming_symbols.非字段成员.applicable_accessibilities = public, friend, private, protected, protected_friend, private_protected
172+
dotnet_naming_symbols.非字段成员.required_modifiers =
173+
174+
# 命名样式
175+
176+
dotnet_naming_style.以_i_开始.required_prefix = I
177+
dotnet_naming_style.以_i_开始.required_suffix =
178+
dotnet_naming_style.以_i_开始.word_separator =
179+
dotnet_naming_style.以_i_开始.capitalization = pascal_case
180+
181+
dotnet_naming_style.帕斯卡拼写法.required_prefix =
182+
dotnet_naming_style.帕斯卡拼写法.required_suffix =
183+
dotnet_naming_style.帕斯卡拼写法.word_separator =
184+
dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case
185+
186+
dotnet_naming_style.帕斯卡拼写法.required_prefix =
187+
dotnet_naming_style.帕斯卡拼写法.required_suffix =
188+
dotnet_naming_style.帕斯卡拼写法.word_separator =
189+
dotnet_naming_style.帕斯卡拼写法.capitalization = pascal_case
190+
191+
[*.{cs,vb}]
192+
dotnet_style_qualification_for_field = false:silent
193+
dotnet_style_qualification_for_property = false:silent
194+
dotnet_style_qualification_for_method = false:silent
195+
dotnet_style_qualification_for_event = false:silent
196+
end_of_line = lf
197+
insert_final_newline = true
198+
tab_width = 4
199+
indent_size = 4
200+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
201+
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
202+
dotnet_code_quality_unused_parameters = all:suggestion
203+
dotnet_style_readonly_field = true:suggestion
204+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
205+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
206+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
207+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
208+
dotnet_style_allow_multiple_blank_lines_experimental = true:silent
209+
dotnet_style_allow_statement_immediately_after_block_experimental = true:silent
210+
dotnet_style_coalesce_expression = true:suggestion
211+
dotnet_style_null_propagation = true:suggestion
212+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
213+
dotnet_style_prefer_auto_properties = true:silent
214+
dotnet_style_object_initializer = true:suggestion
215+
dotnet_style_collection_initializer = true:suggestion
216+
dotnet_style_prefer_simplified_boolean_expressions = true:suggestion
217+
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
218+
dotnet_style_prefer_conditional_expression_over_return = true:silent
219+
dotnet_style_explicit_tuple_names = true:suggestion
220+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
221+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
222+
dotnet_style_prefer_compound_assignment = true:suggestion
223+
dotnet_style_prefer_simplified_interpolation = true:suggestion
224+
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion
225+
dotnet_style_namespace_match_folder = true:suggestion
226+
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
227+
dotnet_style_predefined_type_for_member_access = true:silent

pmcenter/BotProcess/BotProcess.OwnerReplying.cs

+16-4
Original file line numberDiff line numberDiff line change
@@ -50,17 +50,29 @@ private static async Task OwnerReplying(Update update)
5050
}
5151

5252
// Is replying, replying to forwarded message AND not command.
53-
var forwarded = await Vars.Bot.ForwardMessageAsync(
53+
MessageId? replyToMsgId = null;
54+
if (Vars.CurrentConf.EnableOwnerReplyCopyMessage)
55+
{
56+
replyToMsgId = await Vars.Bot.CopyMessageAsync(
5457
update.Message.ReplyToMessage.ForwardFrom.Id,
5558
update.Message.Chat.Id,
56-
update.Message.MessageId,
59+
update.Message.ReplyToMessage.MessageId,
5760
disableNotification: Vars.CurrentConf.DisableNotifications).ConfigureAwait(false);
61+
}
62+
else
63+
{
64+
replyToMsgId = (await Vars.Bot.ForwardMessageAsync(
65+
update.Message.ReplyToMessage.ForwardFrom.Id,
66+
update.Message.Chat.Id,
67+
update.Message.MessageId,
68+
disableNotification: Vars.CurrentConf.DisableNotifications).ConfigureAwait(false)).MessageId;
69+
}
5870
if (Vars.CurrentConf.EnableMsgLink)
5971
{
60-
Log($"Recording message link: user {forwarded.MessageId} <-> owner {update.Message.MessageId}, user: {update.Message.ReplyToMessage.ForwardFrom.Id}", "BOT");
72+
Log($"Recording message link: user {replyToMsgId} <-> owner {update.Message.MessageId}, user: {update.Message.ReplyToMessage.ForwardFrom.Id}", "BOT");
6173
Vars.CurrentConf.MessageLinks.Add(
6274
new Conf.MessageIDLink()
63-
{ OwnerSessionMessageID = update.Message.MessageId, UserSessionMessageID = forwarded.MessageId, TGUser = update.Message.ReplyToMessage.ForwardFrom, IsFromOwner = true }
75+
{ OwnerSessionMessageID = update.Message.MessageId, UserSessionMessageID = replyToMsgId, TGUser = update.Message.ReplyToMessage.ForwardFrom, IsFromOwner = true }
6476
);
6577
// Conf.SaveConf(false, true);
6678
}

pmcenter/Configurations/Conf.ConfObj.New.cs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public ConfObj()
2525
EnableRepliedConfirmation = true;
2626
EnableForwardedConfirmation = false;
2727
EnableAutoUpdateCheck = false;
28+
EnableOwnerReplyCopyMessage = false;
2829
UseUsernameInMsgInfo = true;
2930
DonateString = "";
3031
LowPerformanceMode = false;

pmcenter/Methods/Proxy/Methods.LatencyBasedProxy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,4 @@ private async Task<WebProxy> GetFastestProxyAsync()
8181
}
8282
}
8383
}
84-
}
84+
}

pmcenter/Setup.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ private static async Task SetUID()
178178
{
179179
Thread.Sleep(200);
180180
}
181-
181+
182182
_ = await testBot.SendTextMessageAsync(receivedUid, Markdown.Escape($"👋 *Hello my owner!\n* Your UID `{receivedUid}` is now being saved."), parseMode: ParseMode.Markdown);
183183
Say($"Hello, [{nickname}]! Your UID has been detected as {receivedUid}.");
184184
SIn($".. Saving UID: {receivedUid}...");

0 commit comments

Comments
 (0)