@@ -53,10 +53,6 @@ func runSlackClient(slackApiToken string, stackSite string, tagToChannelName map
5353 for msg := range rtm .IncomingEvents {
5454 switch ev := msg .Data .(type ) {
5555 case * slack.ConnectedEvent :
56- if ev .ConnectionCount != 1 {
57- log .Fatalln ("This bot is already connected" )
58- }
59-
6056 tagToChannelId := make (map [string ]string , len (tagToChannelName ))
6157
6258 OUTER:
@@ -93,7 +89,8 @@ func watchStack(rtm *slack.RTM, tagToChannelId map[string]string, stackSite stri
9389 if lastCreationDate > 0 {
9490 url = fmt .Sprintf ("%s&min=%d" , baseUrl , lastCreationDate )
9591 } else {
96- url = baseUrl
92+ // During the first iteration, the last question is posted to be sure that the bot works
93+ url = fmt .Sprintf ("%s&pagesize=1" , baseUrl )
9794 }
9895
9996 resp , err := http .Get (url )
@@ -112,7 +109,6 @@ func watchStack(rtm *slack.RTM, tagToChannelId map[string]string, stackSite stri
112109 Tags []string `json:"tags"`
113110 Owner Owner `json:"owner"`
114111 CreationDate int `json:"creation_date"`
115- Title string `json:"title"`
116112 Link string `json:"link"`
117113 }
118114
@@ -134,7 +130,7 @@ func watchStack(rtm *slack.RTM, tagToChannelId map[string]string, stackSite stri
134130 if channelId , ok := tagToChannelId [tag ]; ok {
135131 fmt .Printf ("%v" , channelId )
136132
137- rtm .SendMessage (rtm .NewOutgoingMessage (fmt .Sprintf ("%s (%s) by %s. Tags : %s\n " , item .Title , item . Link , item . Owner .DisplayName , strings .Join (item .Tags , ", " )), channelId ))
133+ rtm .SendMessage (rtm .NewOutgoingMessage (fmt .Sprintf ("Question by %s, tags : %s %s \n " , item .Owner .DisplayName , strings .Join (item .Tags , ", " ), item . Link ), channelId ))
138134 }
139135 }
140136
0 commit comments