{"id":26655613,"url":"https://github.com/gramiojs/session","last_synced_at":"2025-10-10T09:08:01.180Z","repository":{"id":226915839,"uuid":"769975996","full_name":"gramiojs/session","owner":"gramiojs","description":"Session plugin for GramIO","archived":false,"fork":false,"pushed_at":"2024-12-11T15:53:27.000Z","size":60,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-19T06:58:03.508Z","etag":null,"topics":["gramio","gramio-plugin","in-memory","redis","sessions","telegram","telegram-bot-api"],"latest_commit_sha":null,"homepage":"https://gramio.netlify.app/plugins/official/session.html","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/gramiojs.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,"zenodo":null}},"created_at":"2024-03-10T15:31:09.000Z","updated_at":"2024-12-11T15:50:55.000Z","dependencies_parsed_at":"2024-03-10T15:43:05.022Z","dependency_job_id":"de770b82-90c2-4ca4-9c4a-5160423527cc","html_url":"https://github.com/gramiojs/session","commit_stats":null,"previous_names":["gramiojs/session"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/gramiojs/session","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Fsession","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Fsession/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Fsession/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Fsession/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gramiojs","download_url":"https://codeload.github.com/gramiojs/session/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gramiojs%2Fsession/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003390,"owners_count":26083579,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["gramio","gramio-plugin","in-memory","redis","sessions","telegram","telegram-bot-api"],"created_at":"2025-03-25T06:36:36.822Z","updated_at":"2025-10-10T09:08:01.123Z","avatar_url":"https://github.com/gramiojs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @gramio/session\n\n[![npm](https://img.shields.io/npm/v/@gramio/session?logo=npm\u0026style=flat\u0026labelColor=000\u0026color=3b82f6)](https://www.npmjs.org/package/@gramio/session)\n[![npm downloads](https://img.shields.io/npm/dw/@gramio/session?logo=npm\u0026style=flat\u0026labelColor=000\u0026color=3b82f6)](https://www.npmjs.org/package/@gramio/session)\n[![JSR](https://jsr.io/badges/@gramio/session)](https://jsr.io/@gramio/session)\n[![JSR Score](https://jsr.io/badges/@gramio/session/score)](https://jsr.io/@gramio/session)\n\nSession plugin for GramIO.\n\n**!!!Currently not optimized and WIP!!!**\n\n## Usage\n\n```ts\nimport { Bot } from \"gramio\";\nimport { session } from \"@gramio/session\";\n\nconst bot = new Bot(process.env.token!)\n    .extend(\n        session({\n            key: \"sessionKey\",\n            initial: () =\u003e ({ apple: 1 }),\n        })\n    )\n    .on(\"message\", (context) =\u003e {\n        context.send(`🍏 apple count is ${++context.sessionKey.apple}`);\n    })\n    .onStart(console.log);\n\nbot.start();\n```\n\nYou can use this plugin with any storage ([Read more](https://gramio.dev/storages/))\n\n### Redis example\n\n[More info](https://github.com/gramiojs/storages/tree/master/packages/redis)\n\n```ts\nimport { Bot } from \"gramio\";\nimport { session } from \"@gramio/session\";\nimport { redisStorage } from \"@gramio/storage-redis\";\n\nconst bot = new Bot(process.env.token!)\n    .extend(\n        session({\n            key: \"sessionKey\",\n            initial: () =\u003e ({ apple: 1 }),\n            storage: redisStorage(),\n        })\n    )\n    .on(\"message\", (context) =\u003e {\n        context.send(`🍏 apple count is ${++context.sessionKey.apple}`);\n    })\n    .onStart(console.log);\n\nbot.start();\n```\n\n### TypeScript\n\nTo **type** a session data, you need to specify the type as the `ReturnType` of the initial function.\n\n```ts\ninterface MySessionData {\n    apple: number;\n    some?: \"maybe-empty\";\n}\n\nbot.extend(\n    session({\n        key: \"sessionKey\",\n        initial: (): MySessionData =\u003e ({ apple: 1 }),\n    })\n);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgramiojs%2Fsession","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgramiojs%2Fsession","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgramiojs%2Fsession/lists"}