Electron_i_k 0 Posted June 16, 2016 Подскажите, как сделать ссылку активной, которая ведёт на внешний сайт, в клиенте WoT в центре уведомлений. href чёт не работает. Заранее спасибо. Quote Share this post Link to post Short link Share on other sites
Ekspoint 2,122 #333265 Posted June 16, 2016 (edited) import re import BigWorld from gui.SystemMessages import SM_TYPE from gui.SystemMessages import pushMessage from notification.settings import NOTIFICATION_TYPE from gui.Scaleform.daapi.view.lobby.LobbyView import LobbyView from notification.actions_handlers import NotificationsActionsHandlers def new_handleAction(self, model, typeID, entityID, actionName): if typeID == NOTIFICATION_TYPE.MESSAGE and re.match('https?://', actionName, re.I): BigWorld.wg_openWebBrowser(actionName) else: old_handleAction(self, model, typeID, entityID, actionName) old_handleAction = NotificationsActionsHandlers.handleAction NotificationsActionsHandlers.handleAction = new_handleAction def NewLobbyView_populate(self): OldLobbyView_populate(self) global Show if not Show: Show = True pushMessage(u'<font color="#12c812">При поддержке сайта</font>' + ' ' + u'<a href="event:http://www.koreanrandom.com"><font color="#eb2222">korean</font></a>', SM_TYPE.GameGreeting) Show = False OldLobbyView_populate = LobbyView._populate LobbyView._populate = NewLobbyView_populate Edited June 16, 2016 by Ekspoint 3 Quote Share this post Link to post Short link Share on other sites
Electron_i_k 0 #333276 Posted June 16, 2016 import re import BigWorld from gui.SystemMessages import SM_TYPE from gui.SystemMessages import pushMessage from notification.settings import NOTIFICATION_TYPE from gui.Scaleform.daapi.view.lobby.LobbyView import LobbyView from notification.actions_handlers import NotificationsActionsHandlers def new_handleAction(self, model, typeID, entityID, actionName): if typeID == NOTIFICATION_TYPE.MESSAGE and re.match('https?://', actionName, re.I): BigWorld.wg_openWebBrowser(actionName) else: old_handleAction(self, model, typeID, entityID, actionName) old_handleAction = NotificationsActionsHandlers.handleAction NotificationsActionsHandlers.handleAction = new_handleAction def NewLobbyView_populate(self): OldLobbyView_populate(self) global Show if not Show: Show = True pushMessage(u'<font color="#12c812">При поддержке сайта</font>' + ' ' + u'<a href="event:http://www.koreanrandom.com"><font color="#eb2222">korean</font></a>', SM_TYPE.GameGreeting) Show = False OldLobbyView_populate = LobbyView._populate LobbyView._populate = NewLobbyView_populate спасибо Quote Share this post Link to post Short link Share on other sites
goofy67 55 #333518 Posted June 18, 2016 import re import BigWorld from gui.SystemMessages import SM_TYPE from gui.SystemMessages import pushMessage from notification.settings import NOTIFICATION_TYPE from gui.Scaleform.daapi.view.lobby.LobbyView import LobbyView from notification.actions_handlers import NotificationsActionsHandlers def new_handleAction(self, model, typeID, entityID, actionName): if typeID == NOTIFICATION_TYPE.MESSAGE and re.match('https?://', actionName, re.I): BigWorld.wg_openWebBrowser(actionName) else: old_handleAction(self, model, typeID, entityID, actionName) old_handleAction = NotificationsActionsHandlers.handleAction NotificationsActionsHandlers.handleAction = new_handleAction def NewLobbyView_populate(self): OldLobbyView_populate(self) global Show if not Show: Show = True pushMessage(u'<font color="#12c812">При поддержке сайта</font>' + ' ' + u'<a href="event:http://www.koreanrandom.com"><font color="#eb2222">korean</font></a>', SM_TYPE.GameGreeting) Show = False OldLobbyView_populate = LobbyView._populate LobbyView._populate = NewLobbyView_populate Другая возможность: import re from gui.shared import g_eventBus, events from gui.SystemMessages import pushMessage, SM_TYPE from notification.actions_handlers import NotificationsActionsHandlers def new_NotificationsActionsHandlers_handleAction(self, model, typeID, entityID, actionName): regex = re.compile( r'^https?://' r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' r'(?::\d+)?' r'(?:/?|[/?]\S+)$', re.IGNORECASE ) if regex.match(actionName) is None: return old_NotificationsActionsHandlers_handleAction(self, model, typeID, entityID, actionName) g_eventBus.handleEvent(events.OpenLinkEvent(events.OpenLinkEvent.SPECIFIED, actionName)) return None old_NotificationsActionsHandlers_handleAction = NotificationsActionsHandlers.handleAction NotificationsActionsHandlers.handleAction = new_NotificationsActionsHandlers_handleAction msg = '<font color="#12c812">Forum: </font><a href="event:http://www.koreanrandom.com"><font color="#eb2222">Korean</font></a>' pushMessage(msg, SM_TYPE.GameGreeting) Quote Share this post Link to post Short link Share on other sites
Ekspoint 2,122 #333535 Posted June 18, 2016 Другая возможность: import re from gui.shared import g_eventBus, events from gui.SystemMessages import pushMessage, SM_TYPE from notification.actions_handlers import NotificationsActionsHandlers def new_NotificationsActionsHandlers_handleAction(self, model, typeID, entityID, actionName): regex = re.compile( r'^https?://' r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?|' r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' r'(?::\d+)?' r'(?:/?|[/?]\S+)$', re.IGNORECASE ) if regex.match(actionName) is None: return old_NotificationsActionsHandlers_handleAction(self, model, typeID, entityID, actionName) g_eventBus.handleEvent(events.OpenLinkEvent(events.OpenLinkEvent.SPECIFIED, actionName)) return None old_NotificationsActionsHandlers_handleAction = NotificationsActionsHandlers.handleAction NotificationsActionsHandlers.handleAction = new_NotificationsActionsHandlers_handleAction msg = '<font color="#12c812">Forum: </font><a href="event:http://www.koreanrandom.com"><font color="#eb2222">Korean</font></a>' pushMessage(msg, SM_TYPE.GameGreeting) и нахрена это, когда можно обойтись меньшим кодом Quote Share this post Link to post Short link Share on other sites
goofy67 55 #333562 Posted June 18, 2016 и нахрена это, когда можно обойтись меньшим кодом Это не "лучше", просто "разные". Quote Share this post Link to post Short link Share on other sites