@@ -255,7 +255,6 @@ func (sm *SessionManager) execCommand(command Command) {
255
255
default :
256
256
sm .uiHandler .PrintText ("[" + config .Config .Colors .Negative + "]Unknown command: [-]" + cmd )
257
257
case "backlog" :
258
- //command
259
258
if sm .currentReceiver == "" {
260
259
return
261
260
}
@@ -266,8 +265,6 @@ func (sm *SessionManager) execCommand(command Command) {
266
265
go sm .getConnection ().LoadChatMessages (sm .currentReceiver , count , firstMsg .Info .Id , firstMsg .Info .FromMe , false , sm )
267
266
}
268
267
}
269
- //FullChatHistory(currentReceiver, 20, 100000, handler)
270
- //messages.GetConnection().LoadFullChatHistory(currentReceiver, 20, 100000, handler)
271
268
case "login" :
272
269
sm .uiHandler .PrintError (sm .login ())
273
270
case "connect" :
@@ -282,19 +279,19 @@ func (sm *SessionManager) execCommand(command Command) {
282
279
text := strings .Join (textParams , " " )
283
280
sm .sendText (command .Params [0 ], text )
284
281
} else {
285
- sm .uiHandler . PrintText ( "[" + config . Config . Colors . Negative + "]Usage:[-] send [user-id[] [message text[]" )
282
+ sm .printCommandUsage ( "send" , " [user-id[] [message text[]" )
286
283
}
287
284
case "select" :
288
285
if checkParam (command .Params , 1 ) {
289
286
sm .setCurrentReceiver (command .Params [0 ])
290
287
} else {
291
- sm .uiHandler . PrintText ( "[" + config . Config . Colors . Negative + "]Usage:[-] select [user-id[]" )
288
+ sm .printCommandUsage ( "select" , " [user-id[]" )
292
289
}
293
290
case "info" :
294
291
if checkParam (command .Params , 1 ) {
295
292
sm .uiHandler .PrintText (sm .db .GetMessageInfo (command .Params [0 ]))
296
293
} else {
297
- sm .uiHandler . PrintText ( "[" + config . Config . Colors . Negative + "]Usage:[-] info [message-id[]" )
294
+ sm .printCommandUsage ( "info" , " [message-id[]" )
298
295
}
299
296
case "download" :
300
297
if checkParam (command .Params , 1 ) {
@@ -304,7 +301,7 @@ func (sm *SessionManager) execCommand(command Command) {
304
301
sm .uiHandler .PrintText ("[::d] -> " + path + "[::-]" )
305
302
}
306
303
} else {
307
- sm .uiHandler . PrintText ( "[" + config . Config . Colors . Negative + "]Usage:[-] download [message-id[]" )
304
+ sm .printCommandUsage ( "download" , " [message-id[]" )
308
305
}
309
306
case "open" :
310
307
if checkParam (command .Params , 1 ) {
@@ -314,7 +311,7 @@ func (sm *SessionManager) execCommand(command Command) {
314
311
sm .uiHandler .PrintError (err )
315
312
}
316
313
} else {
317
- sm .uiHandler . PrintText ( "[" + config . Config . Colors . Negative + "]Usage:[-] open [message-id[]" )
314
+ sm .printCommandUsage ( "open" , " [message-id[]" )
318
315
}
319
316
case "show" :
320
317
if checkParam (command .Params , 1 ) {
@@ -324,7 +321,7 @@ func (sm *SessionManager) execCommand(command Command) {
324
321
sm .uiHandler .PrintError (err )
325
322
}
326
323
} else {
327
- sm .uiHandler . PrintText ( "[" + config . Config . Colors . Negative + "]Usage:[-] show [message-id[]" )
324
+ sm .printCommandUsage ( "show" , " [message-id[]" )
328
325
}
329
326
case "url" :
330
327
if checkParam (command .Params , 1 ) {
@@ -336,7 +333,7 @@ func (sm *SessionManager) execCommand(command Command) {
336
333
}
337
334
}
338
335
} else {
339
- sm .uiHandler . PrintText ( "[" + config . Config . Colors . Negative + "]Usage:[-] url [message-id[]" )
336
+ sm .printCommandUsage ( "url" , " [message-id[]" )
340
337
}
341
338
case "upload" :
342
339
if sm .currentReceiver == "" {
@@ -360,7 +357,7 @@ func (sm *SessionManager) execCommand(command Command) {
360
357
}
361
358
}
362
359
} else {
363
- sm .uiHandler . PrintText ( "[" + config . Config . Colors . Negative + "]Usage:[-] upload /path/to/file" )
360
+ sm .printCommandUsage ( "upload" , " /path/to/file" )
364
361
}
365
362
sm .uiHandler .PrintError (err )
366
363
case "sendimage" :
@@ -385,7 +382,7 @@ func (sm *SessionManager) execCommand(command Command) {
385
382
}
386
383
}
387
384
} else {
388
- sm .uiHandler . PrintText ( "[" + config . Config . Colors . Negative + "]Usage:[-] sendimage /path/to/file" )
385
+ sm .printCommandUsage ( "sendimage" , " /path/to/file" )
389
386
}
390
387
sm .uiHandler .PrintError (err )
391
388
case "sendvideo" :
@@ -410,7 +407,7 @@ func (sm *SessionManager) execCommand(command Command) {
410
407
}
411
408
}
412
409
} else {
413
- sm .uiHandler . PrintText ( "[" + config . Config . Colors . Negative + "]Usage:[-] sendvideo /path/to/file" )
410
+ sm .printCommandUsage ( "sendvideo" , " /path/to/file" )
414
411
}
415
412
sm .uiHandler .PrintError (err )
416
413
case "sendaudio" :
@@ -435,7 +432,7 @@ func (sm *SessionManager) execCommand(command Command) {
435
432
}
436
433
}
437
434
} else {
438
- sm .uiHandler . PrintText ( "[" + config . Config . Colors . Negative + "]Usage:[-] sendaudio /path/to/file" )
435
+ sm .printCommandUsage ( "sendaudio" , " /path/to/file" )
439
436
}
440
437
sm .uiHandler .PrintError (err )
441
438
case "revoke" :
@@ -465,7 +462,7 @@ func (sm *SessionManager) execCommand(command Command) {
465
462
}
466
463
sm .uiHandler .PrintError (err )
467
464
} else {
468
- sm .uiHandler . PrintText ( "[" + config . Config . Colors . Negative + "]Usage:[-] revoke [message-id[]" )
465
+ sm .printCommandUsage ( "revoke" , " [message-id[]" )
469
466
}
470
467
case "leave" :
471
468
groupId := sm .currentReceiver
@@ -488,6 +485,11 @@ func (sm *SessionManager) execCommand(command Command) {
488
485
}
489
486
}
490
487
488
+ // helper for built-in command help
489
+ func (sm * SessionManager ) printCommandUsage (command string , usage string ) {
490
+ sm .uiHandler .PrintText ("[" + config .Config .Colors .Negative + "]Usage:[-] " + command + " " + usage )
491
+ }
492
+
491
493
// check if parameters for command are okay
492
494
func checkParam (arr []string , length int ) bool {
493
495
if arr == nil || len (arr ) < length {
0 commit comments