{"id":17933591,"url":"https://github.com/matrix86/sentrygram","last_synced_at":"2025-08-16T01:30:01.991Z","repository":{"id":83194486,"uuid":"154718292","full_name":"Matrix86/sentrygram","owner":"Matrix86","description":"SentryGram is a Telegram bot that allows you to execute commands on your machine/server or receive messages on events","archived":false,"fork":false,"pushed_at":"2020-04-28T13:15:58.000Z","size":38,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-23T04:46:05.372Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Matrix86.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":"2018-10-25T18:24:59.000Z","updated_at":"2024-06-19T06:38:56.593Z","dependencies_parsed_at":"2023-07-07T02:19:46.933Z","dependency_job_id":null,"html_url":"https://github.com/Matrix86/sentrygram","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Matrix86/sentrygram","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix86%2Fsentrygram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix86%2Fsentrygram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix86%2Fsentrygram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix86%2Fsentrygram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Matrix86","download_url":"https://codeload.github.com/Matrix86/sentrygram/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Matrix86%2Fsentrygram/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270656005,"owners_count":24623298,"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-08-15T02:00:12.559Z","response_time":110,"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":[],"created_at":"2024-10-28T21:40:51.513Z","updated_at":"2025-08-16T01:30:01.916Z","avatar_url":"https://github.com/Matrix86.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SentryGram\n\nSentryGram is a Telegram bot that allows you to execute commands on your machine/server or receive messages on events. It can load your custom JS plugins (it uses the JS interpreter https://github.com/robertkrimen/otto/) to exec commands received from a chat.\nOnly authorized users can use it and receive messages from it.\n\n*It is still in its initial state so many functionalities should be added.*\n\n## Installation\nMake sure you have a GO \u003e= 1.10 environment installed.\n\n    $ go get github.com/Matrix86/sentrygram\n    $ cd $GOPATH/src/github.com/Matrix86/sentrygram\n    $ make\n    $ make install\n\n## Configuration file\nThe server needs a configuration file to work. On the configuration file you can specify the Telegram APIKEY, enable the users that can use the bot and so on.\nThe configuration file is a simple JSON file like below\n```json\n{\n    \"logs\" : \"\",\n    \"tgm_api\": \"TELEGRAM APIKEY\",\n    \"plugins_path\": \"plugins/\",\n    \"users\": [\"userName\"],\n    \"rpc_enabled\": true,\n    \"rpc_port\": 8082\n}\n```\n\n* **logs**         : specifies the path of the output log (if empty it will use the stdout).\n* **tgm_api**      : specifies the Telegram APIKEY (see https://core.telegram.org/bots#3-how-do-i-create-a-bot).\n* **plugins_path** : specifies the directory path that contains the JS plugins.\n* **users**        : array with all the usernames of users that can interact with the bot.\n* **rpc_enabled**  : if true the server enables the rpc server and you can use the client to interact with the bot from your shell.\n* **rpc_port**     : rpc port (default 8082).\n\n\n## Client\nIf you need to send a message to an authorized user you could use the client program. For example, if a cronjob starts and you want to be alerted of this, you could call this exe to send you a message on the chat that you had previously opened with the bot.\n\n    $ sentrygram_client -u \"Username\" -t \"Text of the message\"\n\n## Plugins\n\nThe bot integrates a plugin system based on Javascript. It is possible to load one or more scripts with different functions in it.  \nEach functions (first letter capitalized) defined in the JS scripts will enable a command on the Telegram bot. The functions exported\nas commands will receive as argument the message read by the bot on private chat, group, etc.\nEvents like \"message received on a group\" or \"message received on a private chat\" call precise functions if they are defined on JS side.\nThe event functions are:\n\nEvent | Description\n--- | ---\nOnUserAddOnGroup | one or more users had been added to the group\nOnGroupMessage | a message arrived on a group\nOnChanMessage | a message arrived on channel\nOnPrivateChatMessage | a message arrived on private chat\nOnSuperGroupMessage | a message arrived on supergroup\n\nAll the events, as the command will receive an object with the following fields:\n\n```\ntype BotMessage struct {\n\tFrom         string\n\tContent      string\n\tChatName     string\n\tIsGroup      bool\n\tIsPrivate    bool\n\tIsSuperGroup bool\n\tIsChannel    bool\n\tIsCommand    bool\n}\n```\n\nThe commands are parsed and executed after the events. If a callback event returns false, the command parsing phase will be skipped.  \nOnly users defined in the configuration can execute commands.\nOn JS side there are some functions defined:\n\nFunction | Description\n--- | ---\nlog(text string) | write a log line\nreadFile(path string, binarymode bool) | read a file on the system and return its content as binary or string\ncpuUsage() | return an array with the usage of each cpu\ngetProcesses() | return an array of struct { Name string, Cpu  float64, Pid  int32, Mem  float64 } with all the processes\nnewBarGraph(title string, values []float64, labels []string) | return the path of an image of a bar graph\nexec(cmd string) | exec a command on the system and return the result\nsendMessage(to string, text string) | send a message to a user or group\nsendImage(to string, path string) | send an image to a user or group\nsendFile(to string, path string) | send a file to a user or group\nsendAudio(to string, path string) | send an audio to a user or group\nsendVideo(to string, path string) | send a video to a user or group\naddBotAdmin(name string) | add a bot's administrator\ngetBotAdmins() | return a list with all the current defined administrators\nkickUser(username string, group string) | kick a user from a group (or chan)\nleaveGroup(group string) | the bot leaves a group\ngetChatMembersCount(group string) | returns the number of users in a group\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrix86%2Fsentrygram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatrix86%2Fsentrygram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatrix86%2Fsentrygram/lists"}