Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Added t.me support
Browse files Browse the repository at this point in the history
  • Loading branch information
zhukov committed Jan 12, 2017
1 parent 61401c8 commit 300721e
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 20 deletions.
4 changes: 2 additions & 2 deletions app/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4934,7 +4934,7 @@ angular.module('myApp.controllers', ['myApp.i18n'])
function updateLink (force) {
var chat = AppChatsManager.getChat($scope.chatID)
if (chat.username) {
$scope.exportedInvite = {link: 'https://telegram.me/' + chat.username, short: true}
$scope.exportedInvite = {link: 'https://t.me/' + chat.username, short: true}
selectLink()
return
}
Expand Down Expand Up @@ -5197,6 +5197,6 @@ angular.module('myApp.controllers', ['myApp.i18n'])
}

$scope.share = function () {
LocationParamsService.shareUrl('https://telegram.me/addstickers/' + $scope.stickerset.short_name, $scope.stickerset.title)
LocationParamsService.shareUrl('https://t.me/addstickers/' + $scope.stickerset.short_name, $scope.stickerset.title)
}
})
24 changes: 12 additions & 12 deletions app/js/lib/ng_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1660,10 +1660,6 @@ angular.module('izhukov.utils', [])

case 'messageEntityUrl':
case 'messageEntityTextUrl':
if (options.noLinks) {
skipEntity = true
break
}
var inner
if (entity._ == 'messageEntityTextUrl') {
url = entity.url
Expand All @@ -1673,13 +1669,17 @@ angular.module('izhukov.utils', [])
url = wrapUrl(entityText, false)
inner = encodeEntities(replaceUrlEncodings(entityText))
}
html.push(
'<a href="',
encodeEntities(url),
'" target="_blank" rel="noopener noreferrer">',
inner,
'</a>'
)
if (options.noLinks) {
html.push(inner);
} else {
html.push(
'<a href="',
encodeEntities(url),
'" target="_blank" rel="noopener noreferrer">',
inner,
'</a>'
)
}
break

case 'messageEntityLinebreak':
Expand Down Expand Up @@ -1929,7 +1929,7 @@ angular.module('izhukov.utils', [])
if (unsafe == 2) {
url = 'tg://unsafe_url?url=' + encodeURIComponent(url)
}
else if ( (tgMeMatch = url.match(/^https?:\/\/telegram\.me\/(.+)/))) {
else if ( (tgMeMatch = url.match(/^https?:\/\/t(?:elegram)?\.me\/(.+)/))) {
var path = tgMeMatch[1].split('/')
switch (path[0]) {
case 'joinchat':
Expand Down
13 changes: 10 additions & 3 deletions app/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -4409,11 +4409,17 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
}
Storage.set({tgme_sync: {canRedirect: canRedirect, ts: ts}})

var script = $('<script>').appendTo('body')
var script1 = $('<script>').appendTo('body')
.on('load error', function () {
script.remove()
script1.remove()
})
.attr('src', '//telegram.me/_websync_?authed=' + (canRedirect ? '1' : '0'))

var script2 = $('<script>').appendTo('body')
.on('load error', function () {
script2.remove()
})
.attr('src', '//t.me/_websync_?authed=' + (canRedirect ? '1' : '0'))
})
}

Expand Down Expand Up @@ -4513,7 +4519,8 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils'])
url: url
}).then(function () {
var target = '_blank'
if (url.search('https://telegram.me/') === 0) {
if (url.search('https://telegram.me/') === 0 ||
url.search('https://t.me/') === 0) {
target = '_self'
}
window.open(url, target)
Expand Down
2 changes: 1 addition & 1 deletion app/partials/desktop/channel_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

<div class="md_modal_section_param_wrap" ng-if="chatFull.chat.username">
<div class="md_modal_section_param_value">
<a class="settings_modal_username_link" ng-click="shareLink($event)" ng-bind="'https://telegram.me/' + chatFull.chat.username" ng-href="https://telegram.me/{{chatFull.chat.username}}" target="_blank"></a>
<a class="settings_modal_username_link" ng-click="shareLink($event)" ng-bind="'https://t.me/' + chatFull.chat.username" ng-href="https://t.me/{{chatFull.chat.username}}" target="_blank"></a>
</div>
<div class="md_modal_section_param_name" my-i18n="channel_modal_share_link"></div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/partials/desktop/error_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h4 ng-if="!error" class="md_simple_header" ng-switch="title_html !== undefined
<span ng-switch-when="INVITE_HASH_EMPTY" my-i18n="error_modal_invite_link_invalid"></span>
<span ng-switch-when="CHANNEL_PRIVATE" my-i18n="error_modal_channel_not_accessible"></span>
<span ng-switch-when="PEER_FLOOD" my-i18n="error_modal_not_contact_flood">
<my-i18n-param name="more-info-link"><a href="https://telegram.me/spambot">{0}</a></my-i18n-param>
<my-i18n-param name="more-info-link"><a href="https://t.me/spambot">{0}</a></my-i18n-param>
</span>
<span ng-switch-when="2FA_RECENT_CONFIRM" my-i18n="error_modal_2fa_recent_confirm"></span>
<span ng-switch-when="2FA_CONFIRM_WAIT_TIME" my-i18n="error_modal_2fa_delayed_time_md">
Expand Down
2 changes: 1 addition & 1 deletion app/partials/mobile/channel_modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ <h4 class="mobile_modal_section_header" my-i18n="channel_modal_description"></h4
<div class="mobile_modal_section" ng-if="chatFull.chat.username || chatFull.chat.pFlags.creator">
<h4 class="mobile_modal_section_header" my-i18n="channel_modal_share_link"></h4>
<div class="mobile_modal_section_value" ng-switch="chatFull.chat.username.length > 0">
<a ng-switch-when="true" class="settings_modal_username_link" ng-click="shareLink($event)" ng-bind="'https://telegram.me/' + chatFull.chat.username" ng-href="https://telegram.me/{{chatFull.chat.username}}" target="_blank"></a>
<a ng-switch-when="true" class="settings_modal_username_link" ng-click="shareLink($event)" ng-bind="'https://t.me/' + chatFull.chat.username" ng-href="https://t.me/{{chatFull.chat.username}}" target="_blank"></a>
<a ng-switch-default ng-click="shareLink($event)" ng-bind="chatFull.exported_invite.link" ng-href="{{chatFull.exported_invite.link}}" target="_blank"></a>
</div>
</div>
Expand Down

0 comments on commit 300721e

Please sign in to comment.