Coder Social home page Coder Social logo

mattermost / mattermost-plugin-twitter Goto Github PK

View Code? Open in Web Editor NEW
4.0 26.0 6.0 35 KB

Mattermost plugin to connect to Twitter

License: Apache License 2.0

Makefile 15.80% Go 75.14% HTML 0.16% JavaScript 6.57% TypeScript 2.33%
hacktoberfest mattermost mattermost-plugin

mattermost-plugin-twitter's Introduction

Plugin Starter Template CircleCI branch

This plugin serves as a starting point for writing a Mattermost plugin. Feel free to base your own plugin off this repository.

To learn more about plugins, see our plugin documentation.

Getting Started

Use GitHub's template feature to make a copy of this repository by clicking the "Use this template" button.

Alternatively shallow clone the repository matching your plugin name:

git clone --depth 1 https://github.com/mattermost/mattermost-plugin-starter-template com.example.my-plugin

Note that this project uses Go modules. Be sure to locate the project outside of $GOPATH.

Edit plugin.json with your id, name, and description:

{
    "id": "com.example.my-plugin",
    "name": "My Plugin",
    "description": "A plugin to enhance Mattermost."
}

Build your plugin:

make

This will produce a single plugin file (with support for multiple architectures) for upload to your Mattermost server:

dist/com.example.my-plugin.tar.gz

Development

To avoid having to manually install your plugin, build and deploy your plugin using one of the following options.

Deploying with Local Mode

If your Mattermost server is running locally, you can enable local mode to streamline deploying your plugin. Edit your server configuration as follows:

{
    "ServiceSettings": {
        ...
        "EnableLocalMode": true,
        "LocalModeSocketLocation": "/var/tmp/mattermost_local.socket"
    }
}

and then deploy your plugin:

make deploy

You may also customize the Unix socket path:

export MM_LOCALSOCKETPATH=/var/tmp/alternate_local.socket
make deploy

If developing a plugin with a webapp, watch for changes and deploy those automatically:

export MM_SERVICESETTINGS_SITEURL=http://localhost:8065
export MM_ADMIN_TOKEN=j44acwd8obn78cdcx7koid4jkr
make watch

Deploying with credentials

Alternatively, you can authenticate with the server's API with credentials:

export MM_SERVICESETTINGS_SITEURL=http://localhost:8065
export MM_ADMIN_USERNAME=admin
export MM_ADMIN_PASSWORD=password
make deploy

or with a personal access token:

export MM_SERVICESETTINGS_SITEURL=http://localhost:8065
export MM_ADMIN_TOKEN=j44acwd8obn78cdcx7koid4jkr
make deploy

Q&A

How do I make a server-only or web app-only plugin?

Simply delete the server or webapp folders and remove the corresponding sections from plugin.json. The build scripts will skip the missing portions automatically.

How do I include assets in the plugin bundle?

Place them into the assets directory. To use an asset at runtime, build the path to your asset and open as a regular file:

bundlePath, err := p.API.GetBundlePath()
if err != nil {
    return errors.Wrap(err, "failed to get bundle path")
}

profileImage, err := ioutil.ReadFile(filepath.Join(bundlePath, "assets", "profile_image.png"))
if err != nil {
    return errors.Wrap(err, "failed to read profile image")
}

if appErr := p.API.SetProfileImage(userID, profileImage); appErr != nil {
    return errors.Wrap(err, "failed to set profile image")
}

How do I build the plugin with unminified JavaScript?

Setting the MM_DEBUG environment variable will invoke the debug builds. The simplist way to do this is to simply include this variable in your calls to make (e.g. make dist MM_DEBUG=1).

mattermost-plugin-twitter's People

Contributors

levb avatar mickmister avatar spirosoik avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mattermost-plugin-twitter's Issues

For Main twitter account: specify options for posting tweets into Mattermost

The plugin wil require a "main" twitter account which will be used for rendering tweets, but also this main account could be tracked for posts/replies/retweets. For example a shared company account called "Mattermost" would be authenticated. Then any tweets sent by that account could been posted to a Mattermost channel so people can stay on top of any replies to the company account.

(We should consider the ability to add MULTIPLE twitter handles to track in future)

Allow the user to specify which tweets will get posted to the channel from a checkbox of options.

Options: (Only post messages sent TO the account, Only Messages sent FROM the account, or Both sent/received messages)

  • Option to Include @mentions of the account (checkbox)
  • Include in the incoming message the name of the twitter account it is posting.

Add User Authentication and Tweet Rendering

  • Allow an admin to authenticate a twitter account and store the credentials.
  • Use those credentials to generate a URL link preview whenever a twitter URL is posted in Mattermost.
  • The tweet preview should work on both mobile and desktop clients

Twitter Integration: Build a Simple Plugin to render twitter URLs posted in channels

(NOTE: I have broken this ticket down into multiple tickets in this repo)

Create a Twitter Plugin that renders previews of Twitter URL links posted into Mattermost (***)

Problem:

  • Twitter no longer provides Opengraph data on it’s pages, so rendering a preview of a tweet when someone posts a twitter URL into a channel - is no longer possible.
  • Twitter requires vendors to use their APi to get the tweet data, then render it in the Channel.

Create a twitter plugin that will:

  • Authenticate with a Twitter account using Oauth. (Not just a twitter API key, the user should be able to login)
  • Render a URL preview whenever a tweet URL is posted in any channel
  • Provide a tooltip hover that shows a simple rendering of a tweet when the mouse is hovered over any tweet URL in Mattermost
  • Allow a user to monitor the associated twitter account and post any new tweets FROM/TO that account into a channel of the user’s choice.
  • Allow the user to specify which tweets will get posted to the channel from a checkbox of options.
    • Options: (Only post messages sent TO the account, Only Messages sent FROM the account, or Both sent/received messages)
      - Option to Include @mentions of the account (checkbox)
      - Include in the incoming message the name of the twitter account it is posting.
  • Ideally render the post so that it works on both desktop and mobile clients

You can use an older plugin by @bwesterb for inspiration https://github.com/bwesterb/twittermost and we have the starter plugin template located here: https://github.com/mattermost/mattermost-plugin-starter-template. Create a new Repo from this starter template and we'll work on the project there.

Jira Ticket: https://mattermost.atlassian.net/browse/MM-25940

cc @hanzei

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.