@@ -5899,6 +5899,8 @@ function checkMuted () {
5899
5899
}
5900
5900
} ) ;
5901
5901
5902
+ galleryMode . unlockIfNeeded ( ) ;
5903
+
5902
5904
setTimeout ( checkMuted , 60 * 1000 ) ;
5903
5905
}
5904
5906
setTimeout ( checkMuted , 60 * 1000 ) ;
@@ -5978,6 +5980,73 @@ function takeVoice ( params, cb ) {
5978
5980
}
5979
5981
}
5980
5982
5983
+ var galleryMode = {
5984
+ lockIfNeeded : function ( ) {
5985
+ if ( this . roomInGallery ( ) ) {
5986
+ bot . log ( 'room already in gallery' ) ;
5987
+ return ;
5988
+ }
5989
+
5990
+ bot . log ( 'locking room' ) ;
5991
+ this . lockRoom ( ) ;
5992
+ } ,
5993
+
5994
+ lockRoom : function ( ) {
5995
+ IO . xhr ( {
5996
+ method : 'POST' ,
5997
+ url : '/rooms/save' ,
5998
+ data : fkey ( {
5999
+ defaultAccess : 'read-only' ,
6000
+ roomId : ownerRoom // implied state. change to variable?
6001
+ } ) ,
6002
+
6003
+ complete : finish
6004
+ } ) ;
6005
+
6006
+ // Not much to do here, tbh...we'd probably get a refresh by the time
6007
+ //this fires. Should probably do error checking.
6008
+ function finish ( ) { }
6009
+ } ,
6010
+
6011
+ // Room should get locked if it's not already in gallery mode.
6012
+ roomInGallery : function ( ) {
6013
+ var lockButtonClass = 'sprite-sec-gallery' ;
6014
+ return document . getElementsByClassName ( lockButtonClass ) . length ;
6015
+ } ,
6016
+
6017
+ unlockIfNeeded : function ( ) {
6018
+ if ( ! this . shouldUnlockRoom ( ) ) {
6019
+ bot . log ( 'not unlocking room' ) ;
6020
+ return ;
6021
+ }
6022
+
6023
+ bot . log ( 'unlocking room' ) ;
6024
+ this . unlockRoom ( ) ;
6025
+ } ,
6026
+
6027
+ unlockRoom : function ( ) {
6028
+ IO . xhr ( {
6029
+ method : 'POST' ,
6030
+ url : '/rooms/save' ,
6031
+ data : fkey ( {
6032
+ defaultAccess : 'read-write' ,
6033
+ roomId : ownerRoom // Again implied state.
6034
+ } ) ,
6035
+
6036
+ complete : finish
6037
+ } ) ;
6038
+
6039
+ // Again, not much to do.
6040
+ function finish ( ) { }
6041
+ } ,
6042
+
6043
+ // Room should be unlocked if there aren't any more muted users and we're
6044
+ //locked.
6045
+ shouldUnlockRoom : function ( ) {
6046
+ return this . roomInGallery ( ) && ! ( Object . keys ( muted ) . length ) ;
6047
+ }
6048
+ } ;
6049
+
5981
6050
IO . register ( 'userregister' , function permissionCb ( user , room ) {
5982
6051
bot . log ( user , room , 'permissionCb' ) ;
5983
6052
var id = user . id ;
@@ -6081,7 +6150,7 @@ bot.addCommand({
6081
6150
return userInfo . error ;
6082
6151
}
6083
6152
else if ( userInfo . id === bot . adapter . user_id ) {
6084
- return 'Never try and mute a bot who can own your ass.' ;
6153
+ return 'Never try and mute a bot which can own your ass.' ;
6085
6154
}
6086
6155
else if ( bot . isOwner ( userInfo . id ) ) {
6087
6156
return 'You probably didn\'t want to mute a room owner.' ;
@@ -6101,6 +6170,7 @@ bot.addCommand({
6101
6170
function finish ( ) {
6102
6171
args . reply (
6103
6172
'Muted user {0} for {1}' . supplant ( userInfo . id , duration ) ) ;
6173
+ galleryMode . lockIfNeeded ( ) ;
6104
6174
}
6105
6175
} ,
6106
6176
@@ -6133,6 +6203,7 @@ bot.addCommand({
6133
6203
6134
6204
function finish ( ) {
6135
6205
args . reply ( 'Unmuted user ' + userID . id ) ;
6206
+ galleryMode . unlockIfNeeded ( ) ;
6136
6207
}
6137
6208
} ,
6138
6209
0 commit comments