@@ -165,52 +165,6 @@ func extractLast256ColorEscapeCode(str string) (string, error) {
165
165
return lastMatch [1 ], nil
166
166
}
167
167
168
- func chunker (inputString string , chromaFormatter string ) []string {
169
- chunks := strings .Split (inputString , "\n " )
170
-
171
- switch chromaFormatter {
172
- case "terminal" :
173
- fallthrough
174
- case "terminal8" :
175
- fallthrough
176
- case "terminal16" :
177
- fallthrough
178
- case "terminal256" :
179
- for count , chunk := range chunks {
180
- lastColorCode , err := extractLast256ColorEscapeCode (chunk )
181
- if err != nil {
182
- continue
183
- }
184
-
185
- if count <= len (chunks )- 2 {
186
- chunks [count + 1 ] = fmt .Sprintf ("\033 [38;5;%sm" , lastColorCode ) + chunks [count + 1 ]
187
- }
188
- }
189
- case "terminal16m" :
190
- fallthrough
191
- default :
192
- }
193
-
194
- return chunks
195
- }
196
-
197
- func sendToIRC (
198
- client * girc.Client ,
199
- event girc.Event ,
200
- message string ,
201
- chromaFormatter string ,
202
- ) {
203
- chunks := chunker (message , chromaFormatter )
204
-
205
- for _ , chunk := range chunks {
206
- if len (strings .TrimSpace (chunk )) == 0 {
207
- continue
208
- }
209
-
210
- client .Cmd .Reply (event , chunk )
211
- }
212
- }
213
-
214
168
func getHelpString () string {
215
169
helpString := "Commands:\n "
216
170
helpString += "help - show this help message\n "
@@ -242,6 +196,13 @@ func setFieldByName(v reflect.Value, field string, value string) error {
242
196
switch fieldValue .Kind () {
243
197
case reflect .String :
244
198
fieldValue .SetString (value )
199
+ case reflect .Int32 :
200
+ intValue , err := strconv .ParseInt (value , 10 , 32 )
201
+ if err != nil {
202
+ return errWrongDataForField
203
+ }
204
+
205
+ fieldValue .SetInt (int64 (intValue ))
245
206
case reflect .Int :
246
207
intValue , err := strconv .Atoi (value )
247
208
if err != nil {
@@ -357,7 +318,7 @@ func handleCustomCommand(
357
318
358
319
result := ChatGPTRequestProcessor (appConfig , client , event , & gptMemory , customCommand .Prompt )
359
320
if result != "" {
360
- sendToIRC (client , event , result , appConfig .ChromaFormatter )
321
+ SendToIRC (client , event , result , appConfig .ChromaFormatter )
361
322
}
362
323
case "gemini" :
363
324
var geminiMemory []* genai.Content
@@ -382,7 +343,7 @@ func handleCustomCommand(
382
343
383
344
result := GeminiRequestProcessor (appConfig , client , event , & geminiMemory , customCommand .Prompt )
384
345
if result != "" {
385
- sendToIRC (client , event , result , appConfig .ChromaFormatter )
346
+ SendToIRC (client , event , result , appConfig .ChromaFormatter )
386
347
}
387
348
case "ollama" :
388
349
var ollamaMemory []MemoryElement
@@ -403,7 +364,7 @@ func handleCustomCommand(
403
364
404
365
result := OllamaRequestProcessor (appConfig , client , event , & ollamaMemory , customCommand .Prompt )
405
366
if result != "" {
406
- sendToIRC (client , event , result , appConfig .ChromaFormatter )
367
+ SendToIRC (client , event , result , appConfig .ChromaFormatter )
407
368
}
408
369
case "openrouter" :
409
370
var memory []MemoryElement
@@ -424,7 +385,7 @@ func handleCustomCommand(
424
385
425
386
result := ORRequestProcessor (appConfig , client , event , & memory , customCommand .Prompt )
426
387
if result != "" {
427
- sendToIRC (client , event , result , appConfig .ChromaFormatter )
388
+ SendToIRC (client , event , result , appConfig .ChromaFormatter )
428
389
}
429
390
default :
430
391
}
@@ -460,7 +421,7 @@ func runCommand(
460
421
461
422
switch args [0 ] {
462
423
case "help" :
463
- sendToIRC (client , event , getHelpString (), "noop" )
424
+ SendToIRC (client , event , getHelpString (), "noop" )
464
425
case "set" :
465
426
if len (args ) < 3 { //nolint: mnd,gomnd
466
427
client .Cmd .Reply (event , errNotEnoughArgs .Error ())
@@ -498,7 +459,13 @@ func runCommand(
498
459
for i := range value .NumField () {
499
460
field := t .Field (i )
500
461
fieldValue := value .Field (i ).Interface ()
501
- client .Cmd .Reply (event , fmt .Sprintf ("%s: %v" , field .Name , fieldValue ))
462
+
463
+ fieldValueString , ok := fieldValue .(string )
464
+ if ! ok {
465
+ continue
466
+ }
467
+
468
+ client .Cmd .Reply (event , fmt .Sprintf ("%s: %v" , field .Name , fieldValueString ))
502
469
}
503
470
case "memstats" :
504
471
var memStats runtime.MemStats
@@ -842,7 +809,7 @@ func OllamaHandler(
842
809
843
810
result := OllamaRequestProcessor (appConfig , client , event , ollamaMemory , prompt )
844
811
if result != "" {
845
- sendToIRC (client , event , result , appConfig .ChromaFormatter )
812
+ SendToIRC (client , event , result , appConfig .ChromaFormatter )
846
813
}
847
814
})
848
815
}
@@ -1005,7 +972,7 @@ func GeminiHandler(
1005
972
result := GeminiRequestProcessor (appConfig , client , event , geminiMemory , prompt )
1006
973
1007
974
if result != "" {
1008
- sendToIRC (client , event , result , appConfig .ChromaFormatter )
975
+ SendToIRC (client , event , result , appConfig .ChromaFormatter )
1009
976
}
1010
977
})
1011
978
}
@@ -1150,7 +1117,7 @@ func ChatGPTHandler(
1150
1117
1151
1118
result := ChatGPTRequestProcessor (appConfig , client , event , gptMemory , prompt )
1152
1119
if result != "" {
1153
- sendToIRC (client , event , result , appConfig .ChromaFormatter )
1120
+ SendToIRC (client , event , result , appConfig .ChromaFormatter )
1154
1121
}
1155
1122
})
1156
1123
}
0 commit comments