{"id":21972803,"url":"https://github.com/agustinsrg/ps-bot-lib","last_synced_at":"2025-03-22T23:14:48.146Z","repository":{"id":190802352,"uuid":"680456180","full_name":"AgustinSRG/ps-bot-lib","owner":"AgustinSRG","description":"Simple library to create bots for Pokemon Showdown","archived":false,"fork":false,"pushed_at":"2025-02-15T11:04:19.000Z","size":218,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T14:36:54.629Z","etag":null,"topics":["bot","library","npm","pokemon-showdown","pokemon-showdown-bot","sockjs","typescript","websocket"],"latest_commit_sha":null,"homepage":"https://agustinsrg.github.io/ps-bot-lib/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AgustinSRG.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-08-19T09:50:40.000Z","updated_at":"2025-02-15T10:58:17.000Z","dependencies_parsed_at":"2024-05-03T21:37:44.188Z","dependency_job_id":null,"html_url":"https://github.com/AgustinSRG/ps-bot-lib","commit_stats":null,"previous_names":["agustinsrg/ps-bot-lib"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fps-bot-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fps-bot-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fps-bot-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AgustinSRG%2Fps-bot-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AgustinSRG","download_url":"https://codeload.github.com/AgustinSRG/ps-bot-lib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245031516,"owners_count":20549926,"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":["bot","library","npm","pokemon-showdown","pokemon-showdown-bot","sockjs","typescript","websocket"],"created_at":"2024-11-29T15:21:20.809Z","updated_at":"2025-03-22T23:14:48.122Z","avatar_url":"https://github.com/AgustinSRG.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pokemon Showdown bot library\n\n[![npm version](https://badge.fury.io/js/%40asanrom%2Fps-bot-lib.svg)](https://badge.fury.io/js/%40asanrom%2Fps-bot-lib)\n[![Node.js CI](https://github.com/AgustinSRG/ps-bot-lib/actions/workflows/node.js.yml/badge.svg)](https://github.com/AgustinSRG/ps-bot-lib/actions/workflows/node.js.yml)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/AgustinSRG/ps-bot-lib/blob/master/LICENSE)\n\nSimple library to create bots for [Pokemon Showdown](https://github.com/smogon/pokemon-showdown), coded in typescript, for NodeJS.\n\n## Installation\n\nIn order to install the library to use for your project, run the following command:\n\n```sh\nnpm install --save @asanrom/ps-bot-lib\n```\n\n## Usage\n\nYou can use the library to instantiate Pokemon Showdown bots, controlling their actions and listening for events.\n\nExample code:\n\n```ts\nimport { PokemonShowdownBot } from \"@asanrom/ps-bot-lib\";\n\nconst bot = new PokemonShowdownBot({\n    // Configuration\n    host: \"sim3.psim.us\",\n    port: 443,\n    secure: true,\n    serverId: \"showdown\",\n});\n\nbot.on(\"error\", err =\u003e {\n    // When an error happens, the bot will emit the 'error' event\n    // Make sure to handle it, or otherwise the process will exit\n    console.error(err);\n});\n\nbot.on(\"connecting\", () =\u003e {\n    console.log(\"Bot connecting to the server...\");\n});\n\nbot.on(\"connected\", () =\u003e {\n    console.log(\"Bot connected!\");\n});\n\nbot.on(\"disconnected\", () =\u003e {\n    // If the bot disconnects, it will retry connecting to the server\n    // after 10s by default, you can change it in the configuration\n    console.log(\"Bot disconnected!\");\n});\n\nbot.on(\"can-login\", () =\u003e {\n    // Listen for this event to be able to log into an account\n    bot.rename(\"Example account\", \"eXampl3Pa5w0rd\");\n});\n\nbot.on(\"rename-failure\", err =\u003e {\n    // Could not log in (maybe invalid password?)\n    console.log(\"Could not log in. Error: \" + err.message);\n});\n\nbot.on(\"renamed\", nick =\u003e {\n    // This event indicates you bot successfully logged in\n    console.log(\"Renamed: \" + nick);\n\n    // Now you can send commands\n    bot.sendToGlobal(\"/join Example Room\");\n    bot.pm(\"Example User\", \"Hello!\");\n});\n\nbot.on(\"line\", (room, line, spl, isInitialMessage) =\u003e {\n    // This event is emitted when the bot receives a message line form the server\n    // room is the room identifier the line was received from, an empty string means is a global message\n    // line is the raw line received\n    // spl is the line splitted by the | character\n    // isInitialMessage is true if the line was received in the room initializing message, meaning it may be an old message\n    console.log(`Received message from room: ${room}, line: ${line}`);\n});\n\nbot.on(\"sent\", msg =\u003e {\n    // This event is emitted when the bot sends a message to the server\n    console.log(\"Sent message: \" + msg);\n});\n\nbot.connect();\n```\n\n## Documentation\n\nCheck the [documentation](./DOCUMENTATION.md) for detailed specifications for configuration, methods and events available.\n\nYou can also check the [auto generated documentation](https://agustinsrg.github.io/ps-bot-lib/).\n\n## Building\n\nIn order to build this library, you need:\n\n - [NodeJS](https://nodejs.org/en), latest stable version.\n\nRun the following command to install dependencies:\n\n```sh\nnpm install\n```\n\nRun the following command to build the typescript into javascript:\n\n```sh\nnpm run build\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagustinsrg%2Fps-bot-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fagustinsrg%2Fps-bot-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fagustinsrg%2Fps-bot-lib/lists"}