Coder Social home page Coder Social logo

u32i64 / signalupdates-bot Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 2.0 375 KB

An unofficial bot that creates posts about new tags in Signal repositories in the corresponding beta feedback topics.

License: MIT License

Rust 100.00%
bot cloudflare-workers discourse discourse-api github github-api workers-rs git wasm discord discord-webhook-notifications

signalupdates-bot's Introduction

signalupdates-bot

An unofficial bot that creates posts about new tags in Signal repositories in the corresponding beta feedback topics and sends update notices to Discord.

Running an instance

To run this bot, do the following:

Setup

  1. Install Rust.
  2. Follow the Cloudflare Workers Get started guide from the beginning up to, but not including, step 3.
  3. Clone this repository using Git:
    git clone https://github.com/u32i64/signalupdates-bot

Configuration

General

  1. Copy the wrangler.example.toml file to wrangler.toml.

  2. In wrangler.toml, fill in the following:

    Field Description
    account_id Available in the Cloudflare dashboard.
    id for STATE binding in kv_namespaces Create a KV namespace in the dashboard, then copy its ID. If you'll be deploying the staging variant as well, it is recommended to create a separate KV namespace for it.
    USER_ID The bot's numeric user ID like 12345. You can find it by inspecting the HTML or JSON of any of the bot's posts. It is used to find the bot's posts when confirming post approval (which is done without the API key in case the post is returned even if it's not approved, so the yours property of posts can't be used).
    TOPIC_ID_FOR_SERVER_UPDATES The topic's ID for posting server updates, for example 12345. TOPIC_ID_OVERRIDE overrides this one as well.
    TOPIC_ID_OVERRIDE If you'd like all of the bot's posts to go to a single topic, set this variable to the topic's ID, for example 12345. Otherwise, leave it empty.
    DRY_RUN If you'd like the bot to skip actually posting to Discourse, but otherwise do everything else, including modifying the state (with dummy post numbers), set this to true. Otherwise, leave it empty.
    ENABLED_PLATFORMS Specify first letters of platform names you want to enable. For example, specify said to enable all supported platforms (Server, Android, iOS, and Desktop).
    DISCORD_UPDATES_MENTION_ROLE Role ID to mention about new versions in Discord.
    DISCORD_SERVER_UPDATES_MENTION_ROLE Role ID to mention about new Server versions in Discord.
    DISCORD_ERRORS_MENTION_ROLE Role ID to mention about errors in Discord.
    ACCESS_TOKEN Token that can be used to run the bot on demand or tell the latest Android Firebase version to it via API.
  3. In the KV namespace(s) you created, manually create a key-value pair with the key state and a value like:

    {
        "android": {
            "last_posted_tag_previous_release": { "name": "v1.2.3" },
            "last_posted_tag": { "name": "v1.3.0" }
        },
        "ios": {
            "last_posted_tag_previous_release": { "name": "1.2.0.4-beta" },
            "last_posted_tag": { "name": "1.3.0.4-beta" }
        },
        "desktop": {
            "last_posted_tag_previous_release": { "name": "v1.2.0-beta.1" },
            "last_posted_tag": { "name": "v1.3.0-beta.1" }
        },
        "server": {
            "last_posted_tag_previous_release": { "name": "v11.99.0" },
            "last_posted_tag": { "name": "v12.6.0" }
        }
    }

    Adjust the value accordingly if you'd like to skip posting many old versions after starting the bot.

    You can also add other values used in PlatformState (see src/state.rs), but this is not required, as default values will be used automatically.

Discourse

Configure the bot's access to Discourse.

  1. Create a new user for the bot in the Discourse instance, if necessary.

  2. Log in as that user and create a Discourse user API key, for example using this CLI tool: KengoTODA/discourse-api-key-generator.

    To use this tool, you will need to install NPM, specifically you need the npx command from it.

  3. In the folder where you have the bot's code, run:

    wrangler secret put DISCOURSE_API_KEY -e production

    When prompted, paste the API key you've created and press Enter.

    If you'll be deploying the staging variant as well, run the same command with staging instead of production (and also do this for future commands below). Note that you might not be able to create two different API keys using the tool above (when you create a new one, the old one may be removed); you may have to use the same API key for both production and staging.

    Note: you may have to publish the bot once before running this command. To publish it, see the Deploying section below.

Discord

To send the bot's log to a Discord channel in case an error occurs, set up a webhook.

  1. Create a webhook in a Discord server (guild) by following this article.

  2. Once you have the webhook URL, configure the bot with it, similar to what you did with the Discourse API key:

    wrangler secret put DISCORD_WEBHOOK_URL -e production

For sending update notices themselves to Discord as well, set DISCORD_WEBHOOK_URL_UPDATES and DISCORD_WEBHOOK_URL_SERVER_UPDATES in the same way.

Deployment

Run the following command to deploy the bot:

wrangler publish -e production

The production variant is configured by default to run every 10 minutes. For the staging variant, you have to invoke it manually by visiting its URL (that looks like signalupdates-bot-staging.<your-workers-subdomain>.workers.dev/ACCESS_TOKEN/run).

Acknowledgements

Special thanks to all participants of the discussion in this topic and to @newuser for developing their version of the bot.

Disclaimer

This is an unofficial project. It is not affiliated with the Signal Technology Foundation or Signal Messenger, LLC.

signalupdates-bot's People

Contributors

awaitlink avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

var52yt

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.