Skip to content

Commit c698617

Browse files
authored
Fixed bot crash on '/nextmeetup' command (#49)
* Fixed bot crash on '/nextmeetup' command
1 parent c9b4fab commit c698617

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

telegram-bot/meetup.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,16 @@ func nextmeetup(ID int64, client mongo.Client) {
137137
var data meetupdata
138138
err := collection.FindOne(context.TODO(), bson.M{}).Decode(&data)
139139
if err != nil {
140-
log.Fatal(err)
140+
log.Print(err)
141+
bot.Send(tbot.NewMessage(ID, "No meetup scheduled."))
142+
} else {
143+
//the string inside Format method is a sample string to specify the display
144+
//format of meetupTimeString
145+
timeString := data.Date.Local().Format("Mon _2 Jan 2006")
146+
nxtMeetupData := "Details of next OSDC Meetup :" + "\n" + "Title -" + "\t" +
147+
data.Name + "\n" + "Date -" + "\t" + timeString + "\n" + "Time -" + "\t" +
148+
data.Date.Local().Format("15:04") + "\n" + "Venue -" + "\t" + data.Venue
149+
bot.Send(tbot.NewMessage(ID, nxtMeetupData))
141150
}
142151
location, err := time.LoadLocation("Asia/Kolkata")
143152
if err != nil {

0 commit comments

Comments
 (0)