Services API Reference
This section provides technical documentation for the various services used by the agent.
Tweet Generator
services.tweet_generator
Tweet Generator Service for Pokemon LLM Agent.
Orchestrates the tweet generation flow: 1. Generate image via ComfyUI (with achievement-specific prompts) 2. Generate tweet text via LLM 3. Send to Chronicle as a DRAFT for Admin approval
Note: Discord approval and direct Twitter posting have been replaced by Chronicle Drafts.
Classes
TweetGenerator
Orchestrates tweet generation with image and text, sending to Chronicle as a draft.
Source code in services/tweet_generator.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | |
Functions
__init__(image_service=None, llm_client=None)
Initialize the tweet generator.
Source code in services/tweet_generator.py
generate_and_post_achievement_tweet(achievement, run_state=None, game_state=None, screenshot_path=None)
async
Generate content and send to Chronicle as a draft.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
achievement
|
Achievement
|
The achievement that triggered this tweet |
required |
run_state
|
Any
|
RunState object with run context |
None
|
game_state
|
dict
|
Current game state dict |
None
|
screenshot_path
|
str
|
Path to the current game screenshot (optional) |
None
|
Returns:
| Type | Description |
|---|---|
TweetGeneratorOutcome
|
TweetGeneratorOutcome with result and details |
Source code in services/tweet_generator.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
generate_and_post_tweet(is_continuing_run, run_state=None, game_state=None)
async
Generate and post a stream start tweet (no specific achievement).
Source code in services/tweet_generator.py
TweetGeneratorOutcome
dataclass
Outcome of the tweet generation process.
Source code in services/tweet_generator.py
TweetGeneratorResult
Bases: Enum
Final result of the tweet generation process.
Source code in services/tweet_generator.py
Functions
create_tweet_generator(llm_client=None)
Zora Poster Service
services.zora_poster_service
Zora Poster Service.
Orchestrates the creation of Zora posts (coins) for achievements. - Polls ZoraAchievementTracker for pending achievements - Generates images (ComfyUI) or retrieves screenshots - Creates collages for gallery posts - Calls Chronicle Server (Zora Sidecar) to create DRAFTS - Handles rate limiting and queues - Supports token-gated exclusive content
Classes
ZoraPosterService
Orchestrates Zora posting workflow.
Source code in services/zora_poster_service.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
Functions
start()
async
Start the posting worker loop.
Source code in services/zora_poster_service.py
stop()
async
Stop the posting worker.
Source code in services/zora_poster_service.py
Functions
ComfyUI Image Service
services.comfyui_image_service
ComfyUI Image Generation Service for Pokemon LLM Agent.
Triggers image generation workflows on a ComfyUI server to create images for tweet attachments.
Classes
ComfyUIImageService
Image generation service using ComfyUI as the backend. Generates 1024x1024 images for tweet attachments.
Source code in services/comfyui_image_service.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 | |
Functions
__init__(base_url=None, workflow_path=None, output_dir=None, timeout=120.0)
Initialize the ComfyUI Image Generation service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
ComfyUI server URL (e.g., "http://localhost:8188") |
None
|
workflow_path
|
str
|
Path to the image generation workflow JSON file |
None
|
output_dir
|
str
|
Local directory to save generated images |
None
|
timeout
|
float
|
Request timeout in seconds (image gen can be slow) |
120.0
|
Source code in services/comfyui_image_service.py
check_connection()
async
Check if ComfyUI server is reachable.
Source code in services/comfyui_image_service.py
cleanup_image(image_path)
Remove an image file after it has been used (posted/denied). Called after tweet flow completes.
Source code in services/comfyui_image_service.py
generate_image(seed=None, positive_prompt_addition=None, negative_prompt_addition=None)
async
Generate an image using the ComfyUI workflow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
seed
|
int
|
Optional seed for reproducibility. If None, uses random. |
None
|
positive_prompt_addition
|
str
|
Text to append to the positive prompt. |
None
|
negative_prompt_addition
|
str
|
Text to append to the negative prompt. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Path to the downloaded image file, or None on failure. |
Source code in services/comfyui_image_service.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 | |
load_workflow()
async
Load and convert the workflow template.
Source code in services/comfyui_image_service.py
Functions
create_image_service(base_url=None, workflow_path=None, output_dir=None)
Factory function to create a ComfyUI Image Service instance.
Source code in services/comfyui_image_service.py
ComfyUI TTS Service
services.comfyui_tts_service
ComfyUI Text-to-Speech Service for Pokemon LLM Agent. Triggers TTS workflows on a ComfyUI server to generate speech from text.
Classes
ComfyUITTSService
Text-to-Speech service using ComfyUI as the backend.
Triggers TTS workflows on ComfyUI and retrieves generated audio. Supports both localhost and hosted ComfyUI instances.
Source code in services/comfyui_tts_service.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 | |
Attributes
is_available
property
Check if TTS service is configured.
Functions
__init__(base_url=None, workflow_path=None, output_dir=None, timeout=10.0, on_playback_start=None, audio_speed=None, audio_pitch=None)
Initialize the ComfyUI TTS service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
ComfyUI server URL (e.g., "http://localhost:8188") |
None
|
workflow_path
|
str
|
Path to the TTS workflow JSON file |
None
|
output_dir
|
str
|
Directory to save generated audio files |
None
|
timeout
|
float
|
Request timeout in seconds |
10.0
|
on_playback_start
|
callable
|
Callback(text, duration_ms) called when audio starts playing |
None
|
audio_speed
|
float
|
Playback speed multiplier (e.g., 1.1 = 10% faster) |
None
|
audio_pitch
|
float
|
Pitch shift in semitones (e.g., 2 = 2 semitones higher) |
None
|
Source code in services/comfyui_tts_service.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | |
cancel_all_and_interrupt()
Cancel EVERYTHING - current playback, queue, and ComfyUI workflows. Use this when new high-priority commentary arrives to ensure it plays immediately.
Returns:
| Type | Description |
|---|---|
int
|
Number of queue items cleared |
Source code in services/comfyui_tts_service.py
cancel_current()
Cancel the currently playing audio and any pending ComfyUI workflow.
Source code in services/comfyui_tts_service.py
cancel_pending_chat_responses()
Cancel all pending chat response synthesis (for game commentary priority). Keeps the queue but cancels in-progress synthesis tasks.
Returns:
| Type | Description |
|---|---|
int
|
Number of tasks cancelled |
Source code in services/comfyui_tts_service.py
check_connection()
async
Check if ComfyUI server is reachable. Returns True if connected, False otherwise.
Source code in services/comfyui_tts_service.py
clear_queue()
async
close()
async
get_next_ready_audio()
Get the next completed TTS request that has audio ready. Removes it from the queue.
Returns:
| Type | Description |
|---|---|
Optional[TTSRequest]
|
TTSRequest with audio_path populated, or None if none ready |
Source code in services/comfyui_tts_service.py
get_queue_status()
Get queue status for debugging.
Source code in services/comfyui_tts_service.py
get_stats()
Get service statistics.
load_workflow()
Load the TTS workflow template from file. Converts ComfyUI export format (nodes array) to API format (prompt dict).
Source code in services/comfyui_tts_service.py
play_audio_ephemeral(audio_path)
Play audio file ephemerally (no file retention).
Source code in services/comfyui_tts_service.py
play_preloaded(audio_path, text, wait=True)
async
Play a preloaded audio file with UI callbacks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio_path
|
str
|
Path to the preloaded audio file |
required |
text
|
str
|
Original text for callbacks |
required |
wait
|
bool
|
If True, wait for playback to complete |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if playback completed successfully |
Source code in services/comfyui_tts_service.py
play_ready_audio(request, wait=True)
async
Play audio from a completed TTSRequest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
TTSRequest
|
TTSRequest with audio_path populated |
required |
wait
|
bool
|
If True, wait for playback to complete |
True
|
Returns:
| Type | Description |
|---|---|
bool
|
True if playback completed successfully |
Source code in services/comfyui_tts_service.py
process_queue()
async
Process the next item in the TTS queue.
Returns:
| Type | Description |
|---|---|
Optional[TTSRequest]
|
Completed TTSRequest or None if queue is empty. |
Source code in services/comfyui_tts_service.py
prune_old_items(current_cycle)
Remove old TTS items from previous cycles (keep max 1 prev cycle). Also enforces MAX_QUEUE_SIZE.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
current_cycle
|
int
|
The current game cycle number |
required |
Returns:
| Type | Description |
|---|---|
int
|
Number of items pruned |
Source code in services/comfyui_tts_service.py
queue_and_start_synthesis(text, priority=None, cycle_id=0, metadata=None)
async
Queue a TTS request AND start background synthesis immediately. Does not wait for synthesis to complete - returns immediately.
Use get_next_ready_audio() to retrieve completed audio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to synthesize |
required |
priority
|
int
|
Request priority |
None
|
cycle_id
|
int
|
The game cycle this request is from |
0
|
Returns:
| Type | Description |
|---|---|
Optional[TTSRequest]
|
TTSRequest with synthesis_task started, or None if queue full |
Source code in services/comfyui_tts_service.py
queue_tts(text, priority=None, cycle_id=0, metadata=None)
async
Queue a TTS request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to synthesize |
required |
priority
|
int
|
Request priority (higher = more important) |
None
|
cycle_id
|
int
|
The game cycle this request is from (for pruning) |
0
|
metadata
|
Dict[str, Any]
|
Optional context data (e.g. reply info) |
None
|
Source code in services/comfyui_tts_service.py
synthesize_and_play(text, priority=None, wait=True, metadata=None)
async
Synthesize speech and play it ephemerally (no file retention needed by caller).
This is the main method for TTS playback - handles synthesis, playback, and waiting for completion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to synthesize |
required |
priority
|
int
|
Priority level (PRIORITY_COMMENTARY or PRIORITY_CHAT_RESPONSE) |
None
|
wait
|
bool
|
If True, wait for playback to complete before returning |
True
|
metadata
|
Dict[str, Any]
|
Optional context data (e.g. reply_to info for UI display) |
None
|
Returns:
| Type | Description |
|---|---|
bool
|
True if synthesis and playback started successfully |
Source code in services/comfyui_tts_service.py
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 | |
synthesize_only(text)
async
Synthesize TTS audio without playing it. Used for preloading audio during countdown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to synthesize |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Path to generated audio file, or None if failed. |
Source code in services/comfyui_tts_service.py
synthesize_speech(text)
async
Synthesize speech from text using ComfyUI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
Text to convert to speech |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Path to generated audio file, or None if failed. |
Source code in services/comfyui_tts_service.py
wait_for_playback(timeout=30.0)
async
TTSRequest
dataclass
Represents a pending TTS request with async synthesis support.
Source code in services/comfyui_tts_service.py
Functions
create_tts_service(base_url=None, workflow_path=None, output_dir=None, on_playback_start=None)
Factory function to create a ComfyUITTSService instance.
Uses environment variables if parameters not provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
on_playback_start
|
callable
|
Async callback(text, duration_ms) called when audio starts |
None
|
Source code in services/comfyui_tts_service.py
ComfyUI Vision Service
services.comfyui_vision_service
ComfyUI Vision Service for Pokemon LLM Agent. Triggers Vision workflows on a ComfyUI server to analyze images using models like Moondream.
Classes
ComfyUIVisionService
Vision service using ComfyUI as the backend.
Source code in services/comfyui_vision_service.py
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 | |
Functions
__init__(base_url=None, workflow_path=None, timeout=30.0, node_id='7')
Initialize the ComfyUI Vision service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
ComfyUI server URL (e.g., "http://localhost:8188") |
None
|
workflow_path
|
str
|
Path to the Vision workflow JSON file |
None
|
timeout
|
float
|
Request timeout in seconds |
30.0
|
node_id
|
str
|
ID of the node producing the text output |
'7'
|
Source code in services/comfyui_vision_service.py
analyze_image(image_path, prompt_text='Describe this image in detail.')
async
Analyze image using ComfyUI workflow. Returns description string.
Source code in services/comfyui_vision_service.py
upload_image(image_path)
async
Upload image to ComfyUI and return filename.
Source code in services/comfyui_vision_service.py
WebSocket Service
services.websocket_service
Functions
broadcast_message(message)
async
Sends a JSON message to all connected clients.
Source code in services/websocket_service.py
run_server_forever(app_state_dict)
async
Starts the WebSocket server and keeps it running indefinitely.
Source code in services/websocket_service.py
Screenshot Manager
services.screenshot_manager
Screenshot Manager for Zora Gallery Posts.
Maintains a rolling buffer of recent screenshots for creating gallery posts on the LLMLetsPlay Zora account. Unlike the ScreenshotHistoryTracker (which keeps only 2 screenshots for UI diff checking), this manager keeps 5 screenshots for creating rich gallery posts.
Screenshots are NOT deleted - they're just rotated out of the buffer. The actual cleanup is handled elsewhere.
Classes
ScreenshotEntry
dataclass
A single screenshot with context metadata.
Source code in services/screenshot_manager.py
Functions
exists()
to_dict()
Convert to dictionary for serialization.
Source code in services/screenshot_manager.py
ScreenshotManager
Manages a rolling buffer of recent screenshots for Zora gallery posts.
This is separate from ScreenshotHistoryTracker which handles UI diff checking. The ScreenshotManager: - Keeps up to 5 most recent screenshots - Copies screenshots to a dedicated gallery directory - Provides methods for creating gallery posts - Does NOT delete screenshots (just rotates buffer)
Usage
manager = ScreenshotManager(gallery_dir="data/zora_gallery")
Every cycle, capture the screenshot
manager.capture( source_path="/path/to/current_screenshot.png", cycle_number=42, action_number=123, map_name="PALLET_TOWN" )
When creating a Zora post
screenshots = manager.get_gallery_paths() # Returns up to 5 paths
Source code in services/screenshot_manager.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
Functions
__init__(gallery_dir='data/zora_gallery', max_screenshots=5)
Initialize the screenshot manager.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gallery_dir
|
str
|
Directory to store gallery screenshots |
'data/zora_gallery'
|
max_screenshots
|
int
|
Maximum screenshots to keep in buffer (default 5) |
5
|
Source code in services/screenshot_manager.py
capture(source_path, cycle_number, action_number, map_name='', location_description='')
Capture a screenshot by copying it to the gallery directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_path
|
str
|
Path to the source screenshot file |
required |
cycle_number
|
int
|
Current game cycle number |
required |
action_number
|
int
|
Current action number |
required |
map_name
|
str
|
Current map/location name |
''
|
location_description
|
str
|
Human-readable location description |
''
|
Returns:
| Type | Description |
|---|---|
Optional[ScreenshotEntry]
|
ScreenshotEntry if successful, None if source doesn't exist |
Source code in services/screenshot_manager.py
cleanup_old_files(max_age_hours=24)
Clean up old gallery files beyond a certain age.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_age_hours
|
int
|
Maximum age in hours before files are deleted |
24
|
Source code in services/screenshot_manager.py
clear()
get_gallery_paths(count=5)
Get paths to recent screenshots for a gallery post.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Maximum number of paths to return |
5
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List of file paths (oldest to newest) |
Source code in services/screenshot_manager.py
get_journey_summary()
Get a summary of the screenshots in the buffer for progress posts.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary with journey metadata |
Source code in services/screenshot_manager.py
get_latest()
Get the most recent screenshot entry.
Returns:
| Type | Description |
|---|---|
Optional[ScreenshotEntry]
|
ScreenshotEntry if available, None otherwise |
Source code in services/screenshot_manager.py
get_latest_path()
Get path to the most recent screenshot.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Path string if available, None otherwise |
get_recent(count=5)
Get the N most recent screenshot entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Maximum number of screenshots to return |
5
|
Returns:
| Type | Description |
|---|---|
List[ScreenshotEntry]
|
List of ScreenshotEntry objects (oldest to newest) |
Source code in services/screenshot_manager.py
get_stats()
Get manager statistics.
Functions
get_screenshot_manager(gallery_dir='data/zora_gallery', max_screenshots=5)
Get or create the singleton screenshot manager instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gallery_dir
|
str
|
Directory for gallery screenshots |
'data/zora_gallery'
|
max_screenshots
|
int
|
Maximum screenshots to retain |
5
|
Returns:
| Type | Description |
|---|---|
ScreenshotManager
|
ScreenshotManager instance |
Source code in services/screenshot_manager.py
Chat Response Service
services.chat_response_service
Chat Response Service for Pokemon LLM Agent. Handles Twitch chat responses using a separate LLM API (Featherless AI / Alkahest). Includes SKIP/RESPOND decision making and Lass personality consistency.
Classes
ChatResponseService
Service for generating chat responses using a separate LLM.
Uses a configurable LLM provider (e.g., Featherless, Alkahest, OpenAI) keeping the main game LLM separate from chat interactions.
Source code in services/chat_response_service.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 | |
Attributes
is_available
property
Check if service is configured.
Functions
__init__(client=None, model=None)
Initialize the chat response service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
client
|
Optional[OpenAI]
|
Initialized OpenAI-compatible client |
None
|
model
|
str
|
Model name to use |
None
|
Source code in services/chat_response_service.py
decide_skip_or_respond(messages)
async
Decide SKIP or RESPOND for a batch of messages.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
messages
|
List[Dict[str, Any]]
|
List of dicts with username, display_name, message, timestamp |
required |
Returns:
| Type | Description |
|---|---|
List[DecidedMessage]
|
List of DecidedMessage objects with decisions |
Source code in services/chat_response_service.py
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
generate_response(username, message, is_past=False, chatter_context='')
async
Generate a response to a single chat message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Display name of the user |
required |
message
|
str
|
The chat message |
required |
is_past
|
bool
|
If True, respond in past tense (catching up) |
False
|
chatter_context
|
str
|
Context about the user (e.g. "VIP viewer", "Sentiment: positive") |
''
|
Returns:
| Type | Description |
|---|---|
str
|
Response text or empty string on failure |
Source code in services/chat_response_service.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 | |
get_stats()
update_context(game_context=None, commentary=None, location=None, team=None, history=None, memory=None, token_info=None, screen_type=None)
Update context for more coherent responses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
game_context
|
str
|
Current game state summary |
None
|
commentary
|
str
|
Most recent Lass commentary |
None
|
location
|
str
|
Current map/location name |
None
|
team
|
str
|
Pokemon team summary (e.g., "Charmander Lv5, Pidgey Lv3") |
None
|
history
|
str
|
Brief summary of recent actions |
None
|
memory
|
str
|
Important events/milestones |
None
|
token_info
|
str
|
$LASS token market data (e.g., "$LASS: $0.00043 (+12% 24h)") |
None
|
screen_type
|
str
|
Current screen type (title, overworld, battle, menu, dialogue, name_entry) |
None
|
Source code in services/chat_response_service.py
Functions
create_chat_response_service(provider=None)
Create a ChatResponseService instance using a configured LLM provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
Explicit provider name. If None, reads LLM_CHAT_PROVIDER from env. |
None
|
Source code in services/chat_response_service.py
Twitch Chat Service
services.twitch_chat_service
Twitch Chat Service for Pokemon LLM Agent. Connects to Twitch IRC chat via twitchio library to read and respond to viewer messages. Includes test mode for generating fake messages when CHAT_TEST_MODE=true.
Classes
TwitchChatService
Manages Twitch chat connection for the Pokemon LLM agent.
Features: - Listens for @mentions of the bot - Maintains message queue with timestamps - Provides API for getting pending/past messages - Sends responses back to Twitch chat
Source code in services/twitch_chat_service.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 | |
Attributes
is_available
property
Check if Twitch chat service is available (real or test mode).
Functions
__init__(bot_username=None, oauth_token=None, channel=None, on_mention_callback=None)
Initialize the Twitch chat service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bot_username
|
str
|
The bot's Twitch username (e.g., "LassAI") |
None
|
oauth_token
|
str
|
OAuth token with chat:read and chat:edit scopes |
None
|
channel
|
str
|
The Twitch channel to join |
None
|
on_mention_callback
|
Optional[Callable]
|
Optional callback when bot is mentioned |
None
|
Source code in services/twitch_chat_service.py
add_message(msg)
Add a message to the queue (called by the bot).
Source code in services/twitch_chat_service.py
generate_single_test_message()
Generate a single random test message for natural trickling in test mode.
Returns:
| Type | Description |
|---|---|
dict
|
A single message dict compatible with chat_response_service. |
Source code in services/twitch_chat_service.py
generate_test_messages(count=None)
Generate fake test messages for development/testing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Number of messages to generate. Defaults to TWITCH_TEST_MESSAGES_PER_CYCLE. |
None
|
Returns:
| Type | Description |
|---|---|
List[dict]
|
List of message dicts compatible with chat_response_service. |
Source code in services/twitch_chat_service.py
get_messages_for_cycle()
Get all messages since the last commentary timestamp, formatted for processing.
Returns messages as dicts for compatibility with chat_response_service. Sorted by timestamp (oldest first).
Returns:
| Type | Description |
|---|---|
List[dict]
|
List of message dicts with username, display_name, message, timestamp |
Source code in services/twitch_chat_service.py
get_messages_for_cycle_or_test()
Get messages for the current cycle, using test messages if CHAT_TEST_MODE is enabled.
Returns:
| Type | Description |
|---|---|
List[dict]
|
List of message dicts (real or test) for processing. |
Source code in services/twitch_chat_service.py
get_past_messages(count=5)
Get older messages that weren't responded to (for fallback responses).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
count
|
int
|
Maximum number of messages to return. |
5
|
Returns:
| Type | Description |
|---|---|
List[ChatMessage]
|
List of older ChatMessage objects that are mentions but not responded. |
Source code in services/twitch_chat_service.py
get_pending_mentions(since_timestamp=None)
Get mentions that haven't been responded to yet.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
since_timestamp
|
float
|
Only get mentions after this timestamp. If None, uses last commentary timestamp. |
None
|
Returns:
| Type | Description |
|---|---|
List[ChatMessage]
|
List of ChatMessage objects that are mentions and not yet responded. |
Source code in services/twitch_chat_service.py
get_stats()
Get service statistics.
Source code in services/twitch_chat_service.py
mark_commentary_timestamp()
Mark the current time as when the last game commentary was sent.
mark_responded(msg)
send_response(username, message)
async
Send a response to Twitch chat.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
username
|
str
|
Username to mention in response (without @) |
required |
message
|
str
|
Response message |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if sent successfully, False otherwise. |
Source code in services/twitch_chat_service.py
start()
async
Start the Twitch chat bot. Returns True if started successfully, False otherwise.
Source code in services/twitch_chat_service.py
stop()
async
Stop the Twitch chat bot.
Source code in services/twitch_chat_service.py
Functions
create_twitch_service(bot_username=None, oauth_token=None, channel=None, on_mention_callback=None)
Factory function to create a TwitchChatService instance.
Uses environment variables if parameters not provided.