Git Product home page Git Product logo

gamefeeder's Introduction

CI status Release Docker image size

GameFeeder

You can use this bot to get notified about updates and blog posts for multiple games. With the commands you can modify which notifications you want to receive.

Available on Discord and Telegram soonTM.

A TypeScript port of the dota2UpdatesBot by /u/karaflix, supporting multiple clients and games.


Index

About this project

Usage

The quickest way to use the bot is via our public bots and servers:

Discord

On Discord, the bot runs publicly as @GameFeeder#5446. The best way to use the bot is to join our Discord server (make sure to mute the channels you are not interested in). You can also add the bot to your own servers via this invite link.

Discord Preview

Telegram

On Telegram, the bot runs publicly as @AnnounceBot. The best way to use the bot is to add it directly (don't forget to subscribe to the games you are interested in). If you are only interested in Dota 2, you can also use the old Dota 2 Feeder channel.

Telegram Preview

Local setup

You can also download production-ready images from the dockerhub repo. You will still need your own configuration and data files for it to work (more info about how to do that in CONTRIBUTING.md).

Commands

So far, we are providing the following commands:

  • The default prefix on Telegram is /.
  • The default prefix on Discord is !.
  • You can also use the bot's tag as prefix.
Command Role Summary
start User Get started with the GameFeeder.
help User Display all available commands.
about User Display information about this bot.
settings User Display an overview of the settings you can configure for the bot.
games User Display a list of all available games.
stats <game name (optional)> User Display some stats about the bot or a specific game.
ping User Test the delay of the bot.
debug User Display useful debug information.
flip User Flip a coin.
roll <dice count> <dice type> <modifier> User Roll some dice.
subscribe <game name> Admin Subscribe to a game's feed.
unsubscribe <game name> Admin Unsubscribe from a game's feed.
prefix <new prefix> Admin Change the prefix the bot uses on this channel.
notifyAll <message> Owner Send a message to all subscribers.
notifyGameSubs (<game name>) <message> Owner Send a message to all subscribers of a game.
telegramCmds Owner Simplifies the command registration on Telegram by printing the command string.
label <bot name> <channel id> <channel label> Owner Set a label for the channel to simplify debugging.

Note: The messages in the notification commands should be provided in the raw markdown format, they will be reformatted for the different clients. Discord should be used for these commands, as some formatting information gets lost in Telegram (when Telegram uses the same format).

Roles

  • User: Any user can execute this command
  • Admin: Only admins on this server can execute this command
  • Owner: Only the owner of the bot can execute this command

Games

So far, we are supporting the following games:

  • Age of Empires IV
  • Among Us
  • Apex Legends
  • Artifact
  • Cities: Skylines
  • Counter-Strike: Global Offensive
  • Cyberpunk 2077
  • Dave the Diver
  • Dead by Daylight
  • Dead Cells
  • Don't Starve Together
  • Dota 2
  • Dota Underlords
  • Factorio
  • Fall Guys: Ultimate Knockout
  • Forager
  • Grand Theft Auto V
  • GWENT: The Witcher Card Game
  • Hades
  • Helldivers 2
  • Horizon Forbidden West
  • Microsoft Flight Simulator 2020
  • Minecraft
  • MIR4
  • Palworld
  • Payday 2
  • PLAYERUNKNOWN'S BATTLEGROUNDS
  • Risk of Rain 2
  • Rust
  • Satisfactory
  • Sea of Thieves
  • Sid Meier's Civilization VI
  • Stardew Valley
  • Steam
  • Teamfight Manager
  • Team Fortress 2
  • Thronefall
  • Tom Clancy's Rainbow Six Siege
  • Valheim
  • Veloren

Contributing

We welcome all contributors, especially beginners! Please refer to the contributing guidelines.


Miscellaneous

Privacy

As long as you have subscriptions active or a custom prefix defined, we are storing the ID of that channel (unencrypted) on our server.

You can remove it again by unsubscribing from every feed and resetting the prefix.

License

We are providing the bot under the GPL-3.0 License. Read more here.

Disclaimer

Please note that this project is not affiliated with any games or corporations it posts updates for.

Artifact, CS:GO, Dota 2, Steam, Team Fortress 2 and Dota Underlords are registered trademarks of Valve Corporation.

gamefeeder's People

Contributors

dependabot[bot] avatar evelew avatar nickstamat avatar renovate-bot avatar renovate[bot] avatar timjentzsch avatar zachkont avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

gamefeeder's Issues

Fix commands in Telegram channels

Describe the bug
Messages in Telegram channels don't seem to be triggering any message events, so the commands can't be processed.

To Reproduce
Steps to reproduce the behavior:

  1. Start the Telegram bot
  2. Add the bot as an admin to a channel
  3. Write any commands in the channel

The bot will not respond to any commands.

Expected behavior
The bot should work just like in groups and DMs.

Additional context
This might be a bug in the node-telegram-bot-api instead of our code. Similar reports have been made in their issue section (#167, #489).
Enabling / disabling the group privacy, removing and readding the bot and using different message events didn't work for me.

Add start command

Describe the solution you'd like
To comply with the Telegram Command guidelines, we should add a start command (/start).
It could greet the user and help him to get started, such as displaying the command to subscribe to a game feed.

Add command to toggle Discord embeds

Describe the solution you'd like
Add a Discord specific command, e.g. embed, that toggles the bot's usage of embeds for that channel.
When embeds are disabled, the bot sends a normal text message, similar to Telegram.

Fix Telegram markdown formatting in link labels

Describe the bug
Telegram doesn't support bold/italic formatting within links (or links within bold/italic formatting) and just displays the raw markdown text (or raw link) instead.

To Reproduce
Steps to reproduce the behavior:

  1. Subscribe to any game
  2. Look at the Telegram notifications
  3. See the bugged link / markdown formatting

Expected behavior
Links should always be preferred over bold/italic formatting. The markdown text should be cut out within links. Outside of links, the link formatting should be "cut out" of the bold/italic formatting, for example:

  • [*link*](url)* should turn into
    [link](url)
  • *test text with a [link](url) as an example* should turn into
    *test text with a* [link](url) *as an example*

Screenshots
The problem mostly occurs for the headlines:
Link formatting in Telegram

Clients:
The clients affected by the bug:

  • Discord
  • Telegram

Fix bot crahes

Describe the bug
The deployed bot currently crashes for unknown reasons.
It outputs the following error:

0|_main  | 2019-04-12 20:29:27 [Updater]         info:   Started updater.
0|_main  | You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
0|_main  | StatusCodeError: 400 - {"message":"Bad Request","error":400}
0|_main  |     at new StatusCodeError (/home/zach/projects/valveGamesAnnouncerBot/node_modules/request-promise/lib/errors.js:32:15)
0|_main  |     at Request.RP$callback [as _callback] (/home/zach/projects/valveGamesAnnouncerBot/node_modules/request-promise/lib/rp.js:77:29)
0|_main  |     at Request.self.callback (/home/zach/projects/valveGamesAnnouncerBot/node_modules/request/request.js:185:22)
0|_main  |     at Request.emit (events.js:182:13)
0|_main  |     at Request.<anonymous> (/home/zach/projects/valveGamesAnnouncerBot/node_modules/request/request.js:1161:10)
0|_main  |     at Request.emit (events.js:182:13)
0|_main  |     at IncomingMessage.<anonymous> (/home/zach/projects/valveGamesAnnouncerBot/node_modules/request/request.js:1083:12)
0|_main  |     at Object.onceWrapper (events.js:273:13)
0|_main  |     at IncomingMessage.emit (events.js:187:15)
0|_main  |     at endReadableNT (_stream_readable.js:1094:12)
0|_main  |     at args.(anonymous function) (/home/zach/.config/yarn/global/node_modules/event-loop-inspector/index.js:138:29)
0|_main  |     at process._tickCallback (internal/process/next_tick.js:63:19)

To Reproduce
This issue is still under investigation.

Expected behavior
The bot should not crash.

Automatically update reddit user agent

Describe the solution you'd like
Currently, the reddit user agent must be set manually in the config files, including the version number.
This should be split up in the clients (potentially as array), the URL and the username and assembled to the user agent when creating the reddit client. The version number should be taken from package.json, to ensure that it is up-to-date.

Restructure singletons

We should change the way we are handling singletons, the current approach isn't very clean.

Filter out deleted reddit posts

Describe the solution you'd like
Reddit posts that got deleted should not be picked up by the bot.
They can be identified by having [removed] as their content.

Notify owner on error

Describe the solution you'd like
Automatically send a message to the owner / host of the bot, if an error occured. The message should contain the error message and the source of the error.

Rename the bot

Since the bot isn't restricted to Valve's games at all, we might want to think about renaming it before release.

Error in discord logs

The following error appeared in the logs 6 times

Error [ERR_UNHANDLED_ERROR]: Unhandled error. ([object Object])
    at Client.emit (events.js:178:17)
    at WebSocketConnection.onError (/home/zach/projects/valveGamesAnnouncerBot/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:374:17)
    at WebSocket.onError (/home/zach/projects/valveGamesAnnouncerBot/node_modules/discord.js/node_modules/ws/lib/event-target.js:128:16)
    at WebSocket.emit (events.js:189:13)
    at _receiver.cleanup (/home/zach/projects/valveGamesAnnouncerBot/node_modules/discord.js/node_modules/ws/lib/websocket.js:211:14)
    at Receiver.cleanup (/home/zach/projects/valveGamesAnnouncerBot/node_modules/discord.js/node_modules/ws/lib/receiver.js:557:13)
    at WebSocket.finalize (/home/zach/projects/valveGamesAnnouncerBot/node_modules/discord.js/node_modules/ws/lib/websocket.js:206:20)
    at TLSSocket.emit (events.js:189:13)
    at emitErrorNT (internal/streams/destroy.js:82:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
    at args.(anonymous function) (/home/zach/.config/yarn/global/node_modules/event-loop-inspector/index.js:138:29)
    at process._tickCallback (internal/process/next_tick.js:63:19)

Restart the bot on config changes

Describe the solution you'd like
The bot should restart whenever we change the config files in the config folder.
To avoid issues with restarting loops, we should wait with this until #63 is addressed.

Add command to display current subscriptions

Describe the solution you'd like
A command (e.g. /subscriptions) to display the current subscriptions for this channel.
For example, if a channel is subscribed to Artifact and Dota 2, the command would display something like this:

You are subscribed to the following games:

  • Artifact
  • Dota 2

Add indicator to cut off messages

Describe the solution you'd like
When messages are cut off, due to the client's character limit or the notification mode, this should be indicated, e.g. with ... at the end of the message.

Add web interface

Describe the solution you'd like
It would be nice to have a web interface in addition to the bots, that provides a nice overview over the recent updates.

Fix image link parsing

Describe the bug
A lot of posts from the Team Fortress Feed and the Steam Feed seem to be parsed incorrectly, resulting in single exclamation marks (!) being displayed, sometimes as links.
This might be a parsing error with markdown image links.

To Reproduce
Steps to reproduce the behavior:

  1. Subscribe to Steam or Team Fortress
  2. Look at the recent blog posts
  3. See weird exclamation marks in the posts

Expected behavior
The parsing should be fixed, displaying images as link with "Image" as label. The first image could also be used as a thumbnail.

Screenshots
The exclamation marks in a Steam blog post, displayed on Discord:
Discord wrong image parsing

Clients:
The clients affected by the bug:

  • Discord
  • Telegram

Temporarily remove the Dota blog as provider

We can temporarily remove the Dota blog as provider to decrease duplicate notifications. /u/wykrhm is reliable enough to notify us on a blog post.
We can later readd this when we added #26.

Add settings command

Describe the solution you'd like
To comply with the Telegram Command guidelines, we should add a settings command (/settings).
It could display the prefix currently used on this channel as well as the games you subscribed to and show the commands to change them.

Fix certain notifications to send in Telegram

Describe the bug
Certain notifications fail to send on Telegram, with the following error:

Error: ETELEGRAM: 400 Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 26

This is one notification that throws that error:

The issue might be caused by the Telegram Mardown reading an opening, but not finding a closing tag, perhaps in the name csgo_brian. Related issue (python-telegram-bot): #131.

To Reproduce
Steps to reproduce the behavior:

  1. Subscribe to CS:GO in Telegram
  2. Set lastUpdate in updater_config.json to 2019-02-07
    • You might also have to increase the limit, depending on how many posts have been made since 2019-02-07
  3. Start the updater
  4. You should see the following log:
[Telegram] error:  Failed to send notification to channel:
Error: ETELEGRAM: 400 Bad Request: can't parse entities: Can't find end of the entity starting at byte offset 26

Expected behavior
The bot should send the notification without any errors. If this is not possible, the bot should try to send the message without markdown formatting, to try to avoid the error.

Additional context
The error gets caught by the bot and logged accordingly. The notification does not get send, but the bot remains resposive.

Combine similar posts

Describe the solution you'd like
In Dota 2, it often happens that multiple sources post about the same event, such as /u/wykrhm posting the link of a blog post that is already covered by the bot.
The bot should identify similar posts and combine them, ideally chosing the "better" post as the message, but also adding links to the other sources.
If the bot doesn't have the permission to edit its messages on a given server, it should post the other source as normal.

Fix being able to push code with linting issues

Describe the bug
I have been able to push code with a linting issue:
Linting issue
The issue gets recognized by VSCode and Travis CI cought the issue.

Expected behavior
The push should fail while any linting issues are present.

Add command for update auto tagging

Describe the solution you'd like
Add a command (e.g. tag) to let the channel admins define a tag that gets added on every update notification. That way they can define which users recieve a notification.

For example, in Discord the admin could do !tag @everyone to ensure that everyone gets notified. Or he could create a different role for those that want to recieve notifications.

Fix undefined authors for Telegram

Describe the bug
When no author is provided, the Telegram message shows, e.g., "New Team Fortress 2 update by undefined".

To Reproduce
Steps to reproduce the behavior:

  1. Subscribe to Team Fortress
  2. Look through the blog posts
  3. You will find several updates with undefined author

Expected behavior
The title should just say something like, e.g., "New Team Fortress 2 update".

Screenshots
Undefined author

Clients:
The clients affected by the bug:

  • Discord
  • Telegram

Fix restart spam with yarn dev

Describe the bug
When you start the bot with yarn dev, nodemon spams the log with:

[nodemon] restarting due to changes...

This is probably due to the watcher being active before the build finished

To Reproduce
Steps to reproduce the behavior:

  1. Type yarn dev in the terminal
  2. Observe the terminal log

Expected behavior
nodemon should only restart the bot when we actually change the code, not when the code builds.

Screenshots
nodemon spam

Add stats command

Describe the solution you'd like
Add a command (e.g. /stats), that displays stats about the bot, such as the current channels and users using the bot. The output could be something like this:

Total: 123 users in 17 channels

  • Discord: 73 users in 12 channels
  • Telegram: 50 users in 5 channels

Add config initialization check

Describe the solution you'd like
Add an initialization check that ensures that all config files are up to date.
It should compare the .example.json files with their counter parts and replace missing parameters with their defaults.

Promise cancellation

Describe the bug
from the logs:

node-telegram-bot-api deprecated Automatic enabling of cancellation of promises is deprecated.
In the future, you will have to enable it yourself.
See https://github.com/yagop/node-telegram-bot-api/issues/319.

at internal/modules/cjs/loader.js:689:30

To Reproduce
Steps to reproduce the behavior:

  1. Start the bot
  2. Wait a bit

Expected behavior
No error appears

Clients:
The clients affected by the bug:

  • Discord
  • Telegram

Add owner commands

Describe the solution you'd like
Add commands that help the owner / host of the bot to maintain it via the messenger clients.
Suggested commands:

  • /notifyAll <message> to send a message to all subs
  • /notifyGame (<game alias>) <message> to send a message to all subs of a game

Refresh recent updates

Describe the solution you'd like
Some posts, like the reddit analysis provided by /u/Magesunite, get updated multiple times after being posted.
The bot should revisit posts that are less than ~2 days old, check if they changed and update the messages accordingly. If the bot doesn't have the permission to edit his message on a given channel, he should just not edit the message without throwing an error.

Add tests

Describe the solution you'd like
Add tests to the project that cover as much code / use cases as possable to reduce the risk of accidently breaking the bot.
The tests should also be added to the Travis CI tasks in .travis.yml.

Fix Discord subscriber notifications in DMs after restart

Describe the bug
The Discord bot won't notify subscribers in DMs after the bot has been restarted.

To Reproduce
Steps to reproduce the behavior:
Without restart:

  1. Configure updater_config.json:
    • Set lastUpdate to something old, like 2019-01-10
    • Set autostart to true
    • Set autosave to false
  2. Clear the Discord subscriptions in subscribers.json
  3. Start the bot
  4. After the bot started, but before the updater started, subscribe to a game (for example Dota 2) in a DM

Result: The bot correctly notifies you about the updates.

With restart:

  1. Configure updater_config.json:
    • Set lastUpdate to something old, like 2019-01-10
    • Set autostart to true
    • Set autosave to false
  2. Clear the Discord subscriptions in subscribers.json
  3. Start the bot
  4. Subscribe to a game (for example Dota 2) in a DM
  5. Restart the bot
  6. Wait for the updater to notify users

Result: The bot doesn't notify you about the updates.

Expected behavior
The bot should notify subscribers about game updates even after the bot has been restarted.

Add Underlords as a game

Describe the solution you'd like
With the launch of Dota Underlords, we should add it to our game list.
Sources:

  • /u/wykrhm on /r/underlords

Blog post

Add privacy command

Describe the solution you'd like
A command (e.g. /privacy) to display privacy information as described in the README. Furthermore, a variation (e.g. /privacy delete) to delete all of the channel's user data (in subscribers.json).

Add config check on startup

Describe the solution you'd like
Check if the config files are up-to-date on startup. If they don't exist, they should be created, if they do, they should be compared to the example files. If any values are missing, they should be filled in by the default values in the example files.

Compress multiple line breaks

Describe the solution you'd like
Too many linebreaks should be compressed together.
For example:

This is a test paragraph.


And this is another paragraph.

Should turn into:

This is a test paragraph.

And this is another paragraph.

Fix updater crashing when the Dota blog is down

Describe the bug
Apparently, when the Dota blog is unavailable, the updater crashes.
Error log:

0|valveGam | 2019-07-18 18:38:49 [Updater]       error:  Update loop failed:
0|valveGam | StatusCodeError: 503 - "<!DOCTYPE html>\n<html>\n  <head>\n    <title>503 Backend fetch failed</title>\n  </head>\n  <body style=\"background-color: #000000; color: #ffffff;font-family: Arial, Helvetica, sans-serif; font-size: 12px; background-image: url( 'http://cdn.store.steampowered.com/public/images/v5/content_bg.png'); background-repeat: repeat-x; background-position: top;) \">\n    <div style=\"width: 940px; margin: 16px auto;\">\n      <img src=\"http://cdn.store.steampowered.com/public/images/v5/globalheader_logo.png\" style=\"float: right; margin-top: 30px;\">\n      <br><h1>Sorry</h1>\n      <h2> www.dota2.com is currently unavailable.  Please try again later.</h2>\n      <br><br><br><br><br>\n      <p>Error 503 Backend fetch failed</p>\n      <p>XID: 601262449</p>\n    </div>\n  </body>\n</html>\n" 

Expected behavior
The bot should catch the error and just try again later.

Add reddit title filters

Describe the solution you'd like
Add a possibility to filter reddit post titles from the reddit providers via a regular expression defined in the json files, so that the providers don't have to be cautious about what to post.

Rework icon

Describe the solution you'd like
The bot should have an icon that is not specific to a certain game. This would be shown on the servers and as the bot's avatar.

Make post size configurable

Describe the solution you'd like
Some people might want the full post contents in their notifications, others might only want the link. We could add commands to configure the size of the notifications. Suggested options:

  • Detailed: Full contents with thumbnail
  • Normal: Full contents without thumbnail
  • Compact: Just the link, author and game name

Those would have to be adjusted for the different clients. Telegram can't display images, but has the instant view that could be used for all modes.

Handle missing permission

Describe the bug
Currently, the bot returns an unhandled promise rejection if it doesn't have permission to write in a channel.

To Reproduce

  1. Add the bot to a server
  2. Remove the writing permission on a channel for the bot
  3. Send the bot a command (e.g. !sub d2)
  4. The bot will return an unhandled promise rejection

Expected behavior
The bot should handle the rejected promise or not try to write in the channel at all. If the channel is subscribed to the bot it should unsubscribe itself, to prevent errors in the future.

Refactor config files and bot data saving

The config files should exclusively contain configurations provided by the bot owner.
The data that we currently save in the config folder (e.g. subscribers.json and the update stuff in updater_config.json should be moved in a new folder (e.g. data).
This makes much more sense and enables us to restart the bot on changes in the config folder.

Additionally the bot_config.json should be renamed to something more fitting, like api_config.json.

Optimize Telegram notifications for Instant View

Describe the solution you'd like
The bot should use Telegram's Instant View to display most notifications on the Telegram client.
For that we need to create Instant View templates for all major sources we provide and configure the messages accordingly.

Add config option to disable reddit notifications

Describe the solution you'd like
For debugging purposes it would be nice to have a config option to disable the reddit notifications (similar to the bots), e.g. when you don't have your tokens yet.
The infrastructure is already partially there, so this should be easy to implement.

Refactor regexes to reuse expressions

As described here, the regular expessions for the markdown parsing should be refactored to strings, so that we can reuse common expressions and improve maintainability.

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.