Giter VIP home page Giter VIP logo

pockybot.net's Introduction

PockyBot.NET

PockyBot.NET nuget package PockyBot.NET on Travis CI Codacy Grade Badge Codacy Coverage Badge PockyBot.NET on Codecov Total alerts on LGTM commits contributors commitizen friendly

A C# .NET Standard implementation of PockyBot.

Getting started

Bot Library

In order to use this bot, an implementation of GlobalX.ChatBots.Core is required. Install the library alongside this library and follow its configuration instructions.

Configuration

In order to use this bot, some configuration is required. This can either be done through appsettings.json, or at the time of configuring the bot.

Example Configuration

// In appsettings.json
{
    "PockyBot.NET": {
        "BotId": "id",
        "BotName": "BotName",
        "DatabaseConnectionString": "Host=postgres.host.com;Port=5432;Username=user;Password=pass;Database=pockybot;"
    }
}

Using Dependency Injection

In the ConfigureServices method of your Startup.cs file, add the following:

using PockyBot.NET;

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    // Add other service registrations here
    services.ConfigurePockyBot(Configuration);
    return services;
}

If you have not provided your configuration inside appsettings.json, you may do so when you configure the bot:

using PockyBot.NET;
using PockyBot.NET.Configuration;

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    // Add other service registrations here
    var settings = new PockyBotSettings
    {
        BotId = "id",
        BotName = "BotName",
        DatabaseConnectionString = "Host=postgres.host.com;Port=5432;Username=user;Password=pass;Database=pockybot;"
    };

    services.ConfigurePockyBot(settings);
}

You will also need to provide an implementation of IResultsUploader to upload the generated results to a location such as Google Cloud and return the link where those results are accessible.

using PockyBot.NET;

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    // other service registrations
    services.AddTransient<IResultsUploader, MyResultsUploader>();
}

You will also need to inject logging classes. See this documentation for details.

Without Dependency Injection

You can get a concrete implementation of the library by calling the PockyBotFactory.CreatePockyBot method.

using GlobalX.ChatBots.Core;
using PockyBot.NET;
using PockyBot.NET.Configuration;

// Some code here

IChatHelper chatHelper; // An implementation of GlobalX.ChatBots.Core.IChatHelper
IResultsUploader resultsUploader; // An implementation of PockyBot.NET.IResultsUploader

var settings = new PockyBotSettings
{
    BotId = "id",
    BotName = "BotName",
    DatabaseConnectionString = "Host=postgres.host.com;Port=5432;Username=user;Password=pass;Database=pockybot;"
};

ILoggerFactory factory = new LoggerFactory().AddConsole(); // add any providers you want here
IPockyBot pockybot = PockyBotFactory.CreatePockyBot(settings, chatHelper, resultsUploader, factory);

Using The Bot

Once you have an instance of IPockyBot, you can use it to respond to a message like so:

using GlobalX.ChatBots.Core;
using PockyBot.NET;

Message message; // input from somewhere
IPockyBot pockybot; // initialised elsewhere

pockybot.Respond(message);

Database

PockyBot requires a postgres database. The database folder in this repository contains a number of .sql files you can use to set this up.

Table generalconfig is initalised with default values as follows:

Value Default Explanation
limit 10 The number of pegs each user is allowed to give out each cycle
minimum 5 The minimum number of pegs each user is required to give out to be eligible to win
winners 3 The number of winners displayed (using a dense ranking)
commentsRequired 1 Boolean value of whether a reason is required to give a peg
pegWithoutKeyword 0 Boolean value of whether the "peg" keyword is required to give a peg (if true, pegs can be given with @PockyBot @Person <reason>)
requireValues 1 Boolean value of whether a keyword is required in the reason for a peg to be given

Table stringconfig is used to define keywords. Name field is 'keyword' and 'value' is the value of the keyword desired. Default keywords are 'customer', 'collaboration', 'amazing', 'integrity', and 'improvement', shorthands for the Dye & Durham company values.

Table stringconfig is also used to define linked keywords. Name field is 'linkedKeyword' and 'value' is the value of the keyword and a linked word, separated by a colon (e.g. 'amazing:awesome'). These are used to define other words that will act as one of the main keywords for validation and results purposes.

Existing roles are 'ADMIN', 'UNMETERED', 'RESULTS', 'FINISH', 'RESET', 'UPDATE', and 'WINNERS'. Users can have more than one role. Any users with the 'ADMIN' role are considered to have all other roles except for 'UNMETERED'. 'UNMETERED' users are not restricted by the usual 'limit' value from generalconfig. All other roles relate to the commands of the same name displayed below.

Commands

All commands related to PockyBot must begin with a mention of the bot, or be sent directly to the bot. In this readme, mentions will be identified by @PockyBot.

General Commands

Use any of these commands in a room PockyBot is participating in to perform commands.

  • @PockyBot ping — verify that the bot is alive.
  • @PockyBot peg @Person <reason> — give someone a peg.
  • @PockyBot status — get the list of pegs you have given.
  • @PockyBot help — get help with using the bot.
  • @PockyBot rotation — get the snack buying rotation.
  • @PockyBot welcome — welcome users.
  • @PockyBot locationconfig get|add|set|delete <location> — manage locations.
  • @PockyBot userlocation:
    • @PockyBot userlocation get me|all|unset|@User — get users' locations.
    • @PockyBot userlocation set <location> me — set your location.
    • @PockyBot userlocation delete me — delete your location.

Admin-only commands

These commands require special permissions to use.

  • @PockyBot finish — get the results of the cycle.
  • @PockyBot reset — clear all pegs from the last cycle.
  • @PockyBot userlocation:
    • @PockyBot userlocation set <location> @User1 @User2 — set one or more users' locations.
    • @PockyBot userlocation delete @User1 @User2 — delete one or more users' locations.

Direct Message Commands

PockyBot can be messaged directly with certain commands.

  • ping
  • status
  • help
  • rotation
  • welcome

Contributing

For notes on how to contribute, please see our Contribution Guildelines.

pockybot.net's People

Contributors

lauraducky avatar evangelinexx avatar semantic-release-bot avatar jimcullenaus avatar dependabot[bot] avatar thomasgillin avatar chromadream avatar drewfreyling avatar

Stargazers

Li Yu avatar Joel Howard avatar  avatar

Watchers

Adeel avatar James Cloos avatar  avatar  avatar Leon Poole avatar  avatar Yiping Zhang  avatar  avatar Christopher Bowles avatar  avatar Meet Rajdev avatar Warren Lee avatar Erika Lyonsteadt avatar  avatar David Ferrell avatar Shaun Rust avatar  avatar

pockybot.net's Issues

View winners by location

Currently, it can be a difficult task to find who was the winner from a particular location, and this can make smaller locations with fewer people feel like second-class citizens.

We should have a way to display winners by location, in addition to the overall winners.

Add 'stringconfig set' command

Add a feature that allows @PockyBot stringconfig set <key> <value> to set the stringconfig for <key> to <value> in unambiguous cases.

  • If <key> is not yet set, set it to <value>.
  • If <key> is set with one associated value, update that value to <value>.
  • If <key> is set with two or more values, return an error and state what those values are.

Dependabot couldn't reach https://www.myget.org/F/gsf/auth/3d9d8f7e-113e-445c-89f8-941dfbf5d208/api/v3/index.json as it timed out

Dependabot couldn't reach https://www.myget.org/F/gsf/auth/3d9d8f7e-113e-445c-89f8-941dfbf5d208/api/v3/index.json as it timed out.

Is https://www.myget.org/F/gsf/auth/3d9d8f7e-113e-445c-89f8-941dfbf5d208/api/v3/index.json accessible over the internet? If it is then this may be a transitory issue and can be ignored - Dependabot will close it on its next successful update run.

View the update logs.

Enable a reasignment of last peg / unsending last peg

Occasionally people assign pegs to the wrong person, would be nice to have a way to fix pegs that have been given. though should be limits, options i can think of

  • only undo the last peg you sent (no time limit?)
  • have x time to undo a send peg? how do you do multi pegs?
  • admin only feature, save database edits

a possible implementation could be responding the the PM from pockybot. could investigate how the reply to thread acts in relation to webhooks

Change order of peg checks to improve error messaging

The peg checks should be done in the following order:

penalty keywords > peg count > keywords

Currently, the keywords come before the peg count, meaning that it will block your peg saying it needs a keyword, then when you add one it will block you again but for being out of pegs.

You shouldn't have to jump through hoops only to be told it would never have worked anyway.

Potential security issue

Hello 👋

I run a security community that finds and fixes vulnerabilities in OSS. A researcher (@Youssef1313) has found a potential issue, which I would be eager to share with you.

Could you add a SECURITY.md file with an e-mail address for me to send further details to? GitHub recommends a security policy to ensure issues are responsibly disclosed, and it would help direct researchers in the future.

Looking forward to hearing from you 👍

(cc @huntr-helper)

Allow PockyBot to reply inline to inline comments

Webex has added the ability to reply to comments inline by clicking "start a thread". Further replies to this can be made using the "reply to thread" button in the UI. If a PockyBot message is in response to one of these inline comments, PockyBot should respond by continuing that thread.

Optionally: PockyBot's responses to top-level messages should also be made as a reply to that message, within a thread.

Related to this and this.

Pegs with double newlines fail on entry

When entering a message with multiple consecutive newlines, the bot fails to send the peg. Logs say "System.ArgumentException: Html has more levels than expected".

This may be the result of transformations the Webex client makes to a user's typed text before sending it.

An example message (as typed by a user):

@PockyBot peg @User
message line one
message line two

message line three

Dependabot couldn't authenticate with https://www.myget.org/F/gsf/auth/3d9d8f7e-113e-445c-89f8-941dfbf5d208/api/v3/index.json

Dependabot couldn't authenticate with https://www.myget.org/F/gsf/auth/3d9d8f7e-113e-445c-89f8-941dfbf5d208/api/v3/index.json.

Dependabot tried to authenticate with the details you previously provided, but authentication failed. If they are no longer valid you will need to provide Dependabot with new credentials.

You can provide authentication details in your Dependabot dashboard by clicking into the account menu (in the top right) and selecting 'Config variables'.

View the update logs.

Update usernames before finish

When a user with sufficient permissions calls "@PockyBot finish", the bot should update all usernames before formatting the results, to ensure it has the most up-to-date information.

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you can benefit from your bug fixes and new features again.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can fix this 💪.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here are some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Missing package.json file.

A package.json file at the root of your project is required to release on npm.

Please follow the npm guideline to create a valid package.json file.


Good luck with your project ✨

Your semantic-release bot 📦🚀

Gracefully handle user not found errors in getting response

Gracefully handle the situation where a user has left the Webex Team but exists in the database due to having previously given or received a peg.

Likely in the UpdateUsers method, where the user no longer exist.

Potential resolution: persist the user with their existing name.

Allow derived/related keywords

If you have the keyword "collaborative", it should be possible to also give out pegs by using derived or related keywords like "collaboration" and "collaborate", while still being tied to the same keyword "collaborative".

Proposed implementation: have a mapping from keywordClass to keywordStems. The class is what would be displayed publicly, while the stem(s) would be what is actually used for matching. For the "collaborative" keywordClass, a single keywordStem of "collaborat" might be sufficient.

Brought forward from dyedurham/pockybot#21

Fix userlocation setting

Current behaviour

The two command forms:

@PockyBot userlocation set <location> me and

@PockyBot userlocation set <location> @<user1> @<user2>

both result in no visible response, and the users' locations are not updated.

Expected behaviour

The user me should update the userlocation of the user making the request. Multiple users mentioned in a userlocation set command should set the location for each of those users to the specified location.

Fix help messages

numberconfig help message is not accurate, it specifies an "add" operation when the keyword is "set". Should also look for inconsistencies in other help messages.

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.