Giter Club home page Giter Club logo

uva-stalker's Introduction

uva-stalker Telegram logo UVa logo

License GitHub release

uva-stalker is a Telgram bot to stalk submissions from UVa Online Judge users.

You simply tell it which users you want to follow, and it will send you notifications every time a user makes a new submission.

An instance of the bot is already running and can be interacted with by chatting to UVaStalkerBot, or you can clone this repo and set up the bot in your own server.

NOTE: Due to decreased usage of the bot (no new users in 2021) and decreasing popularity of https://onlinejudge.org/ (no new problems, unmaintained website functionality...), the bot has been shut down on January 1, 2022. The code still works and you may set it up in a new Telegram bot account if you wish.

UVaStalker screenshot 1 UVaStalker screenshot 2

Installation

Follow these instructions to set up the bot in a development environment and test that it works correctly. You can then deploy it to a server.

Creating your own Telegram bot

Chat with BotFather to generate an authorization token for your new bot. Head over to the Telegram documentation for detailed instructions if you're new to creating bots.

Local installation

uva-stalker uses the telegram-bot-sdk library in a Laravel environment using a (tested in Postgres) database.

After cloning the repo and installing dependencies with composer install, you may configure the database credentials in the project folder in a .env file, as well as your APP_KEY (or use php artisan key:generate to fill it in). You must also fill in the variable TELEGRAM_BOT_TOKEN with your authorization token. This project comes with (optional) minimal Bugsnag error reporting, which you may enable by filling in the BUGSNAG_API_KEY and BUGSNAG_APP_VERSION variables. When you're done with the .env file, install the migrations and execute them to build the database tables.

$ cp .env.example .env
$ nano .env # (edit variables)
$ php artisan migrate:install
$ php artisan migrate

The bot needs to be able to write to Laravel's public disk in order to store the PDFs from UVa OJ. The PDFs will be downloaded whenever a UVa OJ user tracked by the bot solves a problem, and immediately deleted after informing all bot users that stalk that UVa OJ user. By default, the public disk uses the local driver and stores these files in storage/app/public. You should create a symbolic link from public/storage to storage/app/public. To create the symbolic link, you may use php artisan storage:link.

Finally, run daemon.php to listen for messages sent to your bot. This script uses long-polling to request updates with curl every second from the Telegram Bot Api using the getUpdates method. It will forward the payloads to the Laravel application, which will process them under the /api/<authorization_token route, where <authorization_token> is the authorization token which BotFather provided you when you created your bot.

$ php daemon.php
Starting bot with config {"id":356029581,"first_name":"UVaStalker","username":"UVaStalkerBot"}

Start polling Telegram api (will poll for updates every 1000 ms)

Poll took 0 ms (slept 1000000 µs)
Poll took 0 ms (slept 1000000 µs)
...

Any incoming updates will be printed to the console.

Deployment to a server

If the bot works normally using long polling, you may want to deploy it to a server and set a webhook so that incoming updates are pushed to you. By default, the Laravel application is listening for updates on /api/<authorization_token, so you should set up the webhook at

https://your-domain-name.com/api/<authorization_token>

Note that you need a domain name with a valid SSL certificate in order to set up the webhook.

If you have a domain name but you don't have a valid SSL certificate, a very easy way to get one is from Let's Encrypt, and install it on a Caddy web server. Don't forget to update the APP_URL environment variable to https://your-domain-name.

All that's left to do is set up your webhook. You may do so using the setWebhook() method of the Bot Api. Telegram has a fantastic guide on webhooks for detailed instructions.

uva-stalker's People

Contributors

david-perez avatar masteve avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

masteve

uva-stalker's Issues

同学,您这个项目引入了663个开源组件,存在28个漏洞,辛苦升级一下

检测到 david-perez/uva-stalker 一共引入了663个开源组件,存在28个漏洞

漏洞标题:serialize-javascript 代码问题漏洞
缺陷组件:[email protected]
漏洞编号:CVE-2020-7660
漏洞描述:Verizon serialize-javascript是美国威瑞森电信(Verizon)公司的一款支持将JavaScript序列化为 JSON超集的软件包。
serialize-javascript 3.1.0之前版本中存在代码问题漏洞。远程攻击者可借助index.js文件中的‘deleteFunctions’函数利用该漏洞注入任意代码。
国家漏洞库信息:https://www.cnvd.org.cn/flaw/show/CNVD-2020-53801
影响范围:(∞, 3.1.0)
最小修复版本:3.1.0
缺陷组件引入路径:@->[email protected]>[email protected]>[email protected]
@->[email protected]>[email protected]>[email protected]>[email protected]

另外还有28个漏洞,详细报告:https://mofeisec.com/jr?p=i166c2

Underscore in verdicts gives italic messages

If the verdict status as in here has an underscore when trying to send the message, it will print as-is and therefore use it as the beginning of an italic text.

It can be seen when server is down and submission stays on queue.

It may be solved by changing following array:

const VERDICTS = [
        Status::NO_VERDICT          => 'NO_VERDICT',
        Status::SUBMISSION_ERROR    => 'SUBMISSION_ERROR',
        Status::CANT_BE_JUDGED      => 'CANT_BE_JUDGED',
        Status::IN_QUEUE            => 'IN_QUEUE',
        Status::COMPILATION_ERROR   => 'CE',
        Status::RESTRICTED_FUNCTION => 'RF',
        Status::RUNTIME_ERROR       => 'RE',
        Status::OUTPUT_LIMIT        => 'OUTPUT LIMIT',
        Status::TIME_LIMIT          => 'TLE',
        Status::MEMORY_LIMIT        => 'MLE',
        Status::WRONG_ANSWER        => 'WA',
        Status::PRESENTATION_ERROR  => 'PE',
        Status::ACCEPTED            => 'AC',
    ];

to this one:

const VERDICTS = [
        Status::NO_VERDICT          => 'NO VERDICT',
        Status::SUBMISSION_ERROR    => 'SUBMISSION ERROR',
        Status::CANT_BE_JUDGED      => 'CANT BE JUDGED',
        Status::IN_QUEUE            => 'IN QUEUE',
        Status::COMPILATION_ERROR   => 'CE',
        Status::RESTRICTED_FUNCTION => 'RF',
        Status::RUNTIME_ERROR       => 'RE',
        Status::OUTPUT_LIMIT        => 'OUTPUT LIMIT',
        Status::TIME_LIMIT          => 'TLE',
        Status::MEMORY_LIMIT        => 'MLE',
        Status::WRONG_ANSWER        => 'WA',
        Status::PRESENTATION_ERROR  => 'PE',
        Status::ACCEPTED            => 'AC',
    ];

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.