{"id":22923880,"url":"https://github.com/daftmaple/twitchbot-announce-once","last_synced_at":"2025-04-01T14:45:57.661Z","repository":{"id":266924560,"uuid":"899780203","full_name":"daftmaple/twitchbot-announce-once","owner":"daftmaple","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-19T14:32:10.000Z","size":57,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-07T09:29:12.633Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/daftmaple.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-07T02:16:35.000Z","updated_at":"2024-12-13T15:50:20.000Z","dependencies_parsed_at":"2025-02-07T09:39:07.973Z","dependency_job_id":null,"html_url":"https://github.com/daftmaple/twitchbot-announce-once","commit_stats":null,"previous_names":["daftmaple/announce-once","daftmaple/twitchbot-announce-once"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daftmaple%2Ftwitchbot-announce-once","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daftmaple%2Ftwitchbot-announce-once/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daftmaple%2Ftwitchbot-announce-once/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daftmaple%2Ftwitchbot-announce-once/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daftmaple","download_url":"https://codeload.github.com/daftmaple/twitchbot-announce-once/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246659633,"owners_count":20813331,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T08:17:48.053Z","updated_at":"2025-04-01T14:45:57.123Z","avatar_url":"https://github.com/daftmaple.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Announce Once\n\nSimple bot to:\n\n- run announce command with inbuilt cooldown\n- shoutout-on-raid\n\nYou can run these features for multiple channels wherever your bot is modded.\n\n## Setup\n\nYou need to set both `config.json` and `tokens.json`. Guides is available below. If you don't set these json files correctly, the app will throw validation error (refer to `src/validator.ts`) and won't work.\n\n## Obtaining initial token\n\nObtain your Oauth token with the guide provided by [this project](https://github.com/daftmaple/twitch-oauth-token), scopes needed are:\n\n```json\n{\n  \"scope\": [\n    \"chat:edit\",\n    \"chat:read\",\n    \"moderator:manage:announcements\",\n    \"moderator:manage:shoutouts\"\n  ]\n}\n```\n\nOnce you have obtained the token, copy the token to the root directory of this project as `tokens.json`, and rename these properties on the `tokens.json` file:\n\n```\naccess_token -\u003e accessToken\nrefresh_token -\u003e refreshToken\ntoken_type -\u003e tokenType\nexpires_in -\u003e expiresIn\n```\n\nRemove property `token_type` and add property `obtainmentTimestamp` with value `0`, so the tokens.json file should look something like:\n\n```json\n{\n  \"accessToken\": \"token\",\n  \"refreshToken\": \"token\",\n  \"expiresIn\": 12000,\n  \"obtainmentTimestamp\": 0\n}\n```\n\nThis token will eventually be handled by the `@twurple/auth` library used in this project.\n\n## Config\n\nUse the `config.example.json` provided, copy it as `config.json`. Within the channel object, there are few optional properties for trigger message\n\n```json\n{\n  \"channelName\": \"channel name where you are broadcaster/mod\",\n  \"triggers\": [\n    {\n      \"input\": {}, // Input kind\n      \"output\": {} // Output kind\n    }\n  ]\n}\n```\n\nThe valid input and output is available on the table below, with explanation for each section\n\n## Table of valid input-output pair\n\n|                                  | _ChatClient event_ | Shoutout (API) | Announce (API) | Say (Chat) | Moderation actions (API) |\n| -------------------------------- | ------------------ | -------------- | -------------- | ---------- | ------------------------ |\n| Message                          | onMessage          | X              | O              | O          |                          |\n| Raid                             | onRaid             | O              | O              | O          |                          |\n| Subscriptions (Vanilla sub only) | onSub              | X              | O              | O          |                          |\n| Action (/me)                     |                    |                |                |            |                          |\n| Cheers                           |                    |                |                |            |                          |\n| Chat mode change                 |                    |                |                |            |                          |\n\n## Input\n\n### Message (`ChatClient.onMessage`)\n\nIf `non-subscriber` is listed in role, then any role enables trigger.\n\n```ts\ntype Role =\n  | \"broadcaster\"\n  | \"mod\"\n  | \"vip\"\n  | \"subscriber\"\n  | \"founder\"\n  | \"artist\"\n  | \"non-subscriber\";\n\ntype MessageMatcher = {\n  text: string;\n  type?: \"exact\" | \"includes\" | \"startsWith\"; // default startsWith\n  caseSensitive?: boolean; // default true\n};\n\ntype MessageInput = {\n  type: \"message\";\n  message: MessageMatcher;\n  role: Role[];\n};\n```\n\n### Raid (`ChatClient.onRaid`)\n\nTrigger is enabled if `minViewer` is undefined, or raider viewer count is larger than or equal to `minViewer`\n\n```ts\ntype RaidInput = {\n  type: \"raid\";\n  minViewer?: number | undefined;\n};\n```\n\n## Output\n\n### Shoutout (`APIClient.chat.shoutoutUser`)\n\n```ts\ntype ShoutoutOutput = {\n  type: \"shoutout\";\n  delay?: number | undefined;\n};\n```\n\n### Announce (`APIClient.chat.sendAnnouncement`)\n\n```ts\ntype AnnounceOutput = {\n  type: \"announce\";\n  message: string;\n  cooldown?: number | undefined;\n  delay?: number | undefined;\n  color?: \"blue\" | \"green\" | \"orange\" | \"purple\" | \"primary\" | undefined;\n};\n```\n\nIf cooldown is not defined, this defaults to 10 seconds.\n\n### Say (`ChatClient.say`)\n\nBehaves similarly to announce, with properties:\n\n```ts\ntype SayOutput = {\n  type: \"say\";\n  message: string;\n  cooldown?: number | undefined;\n  delay?: number | undefined;\n};\n```\n\nCooldown on [say](#say-chatclientsay) behaves differently to [announce](#announce-apiclientchatsendannouncement). If this is not defined, cooldown is entirely skipped\n\n## Message output replacer available\n\nAny output fields with `message` field may have replacer text, which can be replaced by the `MessageScope` object below\n\n```ts\nexport type MessageScope = {\n  channel: {\n    id: string;\n    name: string;\n  };\n  user: {\n    id: string;\n    name: string;\n  };\n  subInfo?: {\n    plan: SubType;\n    streak?: number;\n  };\n};\n```\n\n`subInfo` is available only on subscription event, otherwise this will return `undefined`\n\n```ts\ntype SubType = \"tier1\" | \"tier2\" | \"tier3\" | \"prime\";\n```\n\nTo access properties eg. user, use double curly braces as replacer:\n\n```json\n{\n  \"type\": \"announce\",\n  \"message\": \"Thank you {{user.name}} for the raid!\",\n  \"cooldown\": 10,\n  \"color\": \"purple\"\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaftmaple%2Ftwitchbot-announce-once","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaftmaple%2Ftwitchbot-announce-once","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaftmaple%2Ftwitchbot-announce-once/lists"}