Addded notifs.
This commit is contained in:
		
							parent
							
								
									54920e1545
								
							
						
					
					
						commit
						8ea41bb592
					
				| @ -263,10 +263,12 @@ class NotificationAudio { | |||||||
|         this.schedule = new Schedule(timeout); |         this.schedule = new Schedule(timeout); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     sounds = [ |     sounds = { | ||||||
|         "/audio/soundfx.d_beep3.mp3", |         "message": "/audio/soundfx.d_beep3.mp3", | ||||||
|         "/audio/mention1.wav" |         "mention":  "/audio/750607__deadrobotmusic__notification-sound-1.wav", | ||||||
|     ]; |         "messageOtherChannel":  "/audio/750608__deadrobotmusic__notification-sound-2.wav", | ||||||
|  |         "ping":  "/audio/750609__deadrobotmusic__notification-sound-3.wav", | ||||||
|  |     } | ||||||
| 
 | 
 | ||||||
|     play(soundIndex = 0) { |     play(soundIndex = 0) { | ||||||
|         this.schedule.delay(() => { |         this.schedule.delay(() => { | ||||||
|  | |||||||
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -116,19 +116,32 @@ | |||||||
| 
 | 
 | ||||||
|     setInterval(updateTimes, 1000); |     setInterval(updateTimes, 1000); | ||||||
| 
 | 
 | ||||||
|     function isMention(message){ |     function isMentionToMe(message){ | ||||||
|         const mentionText = '@{{ user.username.value }}'; |         const mentionText = '@{{ user.username.value }}'; | ||||||
|         return message.toLowerCase().includes(mentionText); |         return message.toLowerCase().includes(mentionText); | ||||||
|     } |     } | ||||||
|  |     function extractMentions(message) { | ||||||
|  |         return [...new Set(message.match(/@\w+/g) || [])]; | ||||||
|  |     } | ||||||
|  |     function isMentionForSomeoneElse(message){ | ||||||
|  |         const mentions = extractMentions(message); | ||||||
|  |         const mentionText = '@{{ user.username.value }}'; | ||||||
|  |         return mentions.length > 0 && mentions.indexOf(mentionText) == -1; | ||||||
|  |     } | ||||||
|      |      | ||||||
|     app.addEventListener("channel-message", (data) => { |     app.addEventListener("channel-message", (data) => { | ||||||
|         if (data.channel_uid !== channelUid) return; |         if (data.channel_uid !== channelUid) { | ||||||
| 
 |             if(!isMentionForSomeoneElse(data.message)){ | ||||||
|  |                 app.playSound("messageOtherChannel"); | ||||||
|  |             } | ||||||
|  |              | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|         if (data.username !== "{{ user.username.value }}") { |         if (data.username !== "{{ user.username.value }}") { | ||||||
|             if(isMention(data.message)){ |             if(isMentionToMe(data.message)){ | ||||||
|                 app.playSound(1); |                 app.playSound("mention"); | ||||||
|             }else{ |             }else if (!isMentionForSomeoneElse(data.message)){ | ||||||
|             app.playSound(0); |                 app.playSound("message"); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|          |          | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user