Skip to content

Commit 4dd1c58

Browse files
committed
Fix dialog matching when character_substitute is not set to underscore
1 parent 190c454 commit 4dd1c58

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/util.rb

+4
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ def get_backup_dir
1818
def get_media_dir(dialog)
1919
File.join(get_backup_dir, get_safe_name(dialog['print_name']) + '_files')
2020
end
21+
22+
def strip_tg_special_chars(print_name)
23+
print_name.gsub(/[_@#]/, '')
24+
end

telegram-history-dump.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,10 @@ def backup_target?(dialog)
128128
return true if candidates.empty?
129129
candidates.each do |candidate|
130130
next unless candidate
131-
dialog_name = get_safe_name(dialog['print_name']).upcase
132-
candidate_name = get_safe_name(candidate).upcase
131+
dialog_name = strip_tg_special_chars(dialog['print_name'])
132+
dialog_name = get_safe_name(dialog_name).upcase
133+
candidate_name = strip_tg_special_chars(candidate)
134+
candidate_name = get_safe_name(candidate_name).upcase
133135
return true if dialog_name.include?(candidate_name)
134136
end
135137
false

0 commit comments

Comments
 (0)