@@ -10,21 +10,32 @@ import (
1010 "github.com/syncfast/clockwise/internal/tui"
1111)
1212
13- // GetParticipantsZoom retrieves the total participant count from a specified
14- // zoom URL. It runs in a loop and updates the passed in `Data` struct every
15- // `refreshInterval` seconds.
16- func GetParticipantsZoom (url string , refreshInterval int , data * tui.Data , pw * playwright.Playwright ) error {
17- if strings .Contains (url , "zoom.us/my/" ) {
18- return fmt .Errorf (`Error: clockwise is not compatible with Zoom Personal Meeting IDs at the moment.
19- Disabling your PMI is as as simple as clicking a checkbox.
20- Please visit https://support.zoom.us/hc/en-us/articles/203276937-Using-Personal-Meeting-ID-PMI- for more info.` )
13+ type Zoom struct {
14+ url string
15+ pw * playwright.Playwright
16+ page playwright.Page
17+ timeout float64
18+ }
19+
20+ func NewZoom (url string , pw * playwright.Playwright ) * Zoom {
21+ return & Zoom {
22+ url : url ,
23+ pw : pw ,
24+ page : nil ,
25+ timeout : 5000 ,
2126 }
27+ }
2228
23- var timeout float64 = 5000
29+ func (z * Zoom ) VisitMeetingUrl () error {
30+ if strings .Contains (z .url , "zoom.us/my/" ) {
31+ return fmt .Errorf (`Error: clockwise is not compatible with Zoom Personal Meeting IDs at the moment.
32+ Disabling your PMI is as as simple as clicking a checkbox.
33+ Please visit https://support.zoom.us/hc/en-us/articles/203276937-Using-Personal-Meeting-ID-PMI- for more info.` )
34+ }
2435
25- url = mutateURL (url )
36+ z . url = mutateURL (z . url )
2637
27- browser , err := pw .Chromium .Launch ()
38+ browser , err := z . pw .Chromium .Launch ()
2839 if err != nil {
2940 return fmt .Errorf ("could not launch browser: %w" , err )
3041 }
@@ -34,31 +45,50 @@ Please visit https://support.zoom.us/hc/en-us/articles/203276937-Using-Personal-
3445 return fmt .Errorf ("could not create page: %w" , err )
3546 }
3647
37- if _ , err = page .Goto (url , playwright.PageGotoOptions {
48+ if _ , err = page .Goto (z . url , playwright.PageGotoOptions {
3849 WaitUntil : playwright .WaitUntilStateLoad ,
3950 }); err != nil {
4051 return fmt .Errorf ("could not goto: %w" , err )
4152 }
4253
54+ return nil
55+ }
56+
57+ func (z * Zoom ) FillBotName (botName string ) error {
4358 selector := "text=Your Name"
44- if err := page .Fill (selector , "clockwise-bot" , playwright.FrameFillOptions {
45- Timeout : & timeout ,
59+ if err := z . page .Fill (selector , "clockwise-bot" , playwright.FrameFillOptions {
60+ Timeout : & z . timeout ,
4661 }); err != nil {
4762 return err
4863 }
4964
50- page .WaitForSelector ("button#joinBtn" )
65+ return nil
66+ }
67+
68+ func (z * Zoom ) JoinMeeting () error {
69+ z .page .WaitForSelector ("button#joinBtn" )
5170
52- if err := page .Click ("button#joinBtn" , playwright.PageClickOptions {
53- Timeout : & timeout ,
71+ if err := z . page .Click ("button#joinBtn" , playwright.PageClickOptions {
72+ Timeout : & z . timeout ,
5473 }); err != nil {
5574 return err
5675 }
5776
58- page .WaitForSelector (".footer-button__number-counter" )
77+ return nil
78+ }
79+
80+ func (z * Zoom ) ActivateVirtualWebcam (camName string ) error {
81+ return nil
82+ }
83+
84+ // GetParticipants retrieves the total participant count from a specified
85+ // zoom URL. It runs in a loop and updates the passed in `Data` struct every
86+ // `refreshInterval` seconds.
87+ func (z * Zoom ) GetParticipants (refreshInterval int , data * tui.Data ) error {
88+ z .page .WaitForSelector (".footer-button__number-counter" )
5989
6090 for {
61- res , err := page .QuerySelector (".footer-button__number-counter" )
91+ res , err := z . page .QuerySelector (".footer-button__number-counter" )
6292 if err != nil {
6393 return err
6494 }
0 commit comments