GithubHelp home page GithubHelp logo

spacefox / calvinandbot Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 749 KB

A very simple Discord bot that displays contents from Calvin and Hobbes comics.

License: Apache License 2.0

Kotlin 100.00%
kotlin kotlin-coroutines kotlin-jvm discord4j-bot lucene koin-kotlin ktor jsoup mockk

calvinandbot's Introduction

Calvin and Bot

A very simple Discord bot that displays contents from Calvin and Hobbes comics.

This shares comics from GoComics and will look only on original publication dates (between 18th november 1985 and 31th december 1995).

Inviting the bot to your Discord server

Click here to invite the bot to your Discord server

How to interact with it

You can call this bot with mention, /calvin (customizable) and direct message.

Commands:

  • help: You’re reading it!
  • random: gives you a random strip.
  • yyyy-mm-dd, yy-mm-dd, dd/mm/yyyy or dd/mm/yy: displays the strip for the given date (between 18th november 1985 and 31th december 1995) (sorry to US people, you’ll have to use logical date formats).
  • any other terms will search a strip with provided terms in transcript.

Search allows wilcards (single-character te?t or multiple characters te*t), regular expressions (/[mb]oat/), fuzzy search (roam~) and any Lucene-supported terms modifier as specified here.

How to run it

Build

There is a shadowWar Gradle command to build a single executable Jar file : ./gradlew shadowJar

Run

Just run it as a standard executable Jar:

java -Xmx64m -Ddiscord4j.token={your token here} -jar calvinandbot-1.0.0-all.jar

Configure

This bot will accept following parameters as Java VM options (-Dparameter.name=value form):

Name Type Default Comment
discord4j.token String None Mandatory. Your Discord bot token.
bot.command String /calvin The command to trigger the bot in public channels.
lucene.index.path Path (as String) lucene/ Path to store Lucene indexation files.
strips.dataUrl URL (as String) Empty URL to store the strips data to use, before indexation. If empty, blank or non-provided, the bot will use embedded data (should be complete).
scraper.enabled Boolean (true or false) false Enables the data scraper to re-download strips data from GoComics.
scraper.delayMs Integer 1000 Delay between two strips loads, in milliseconds. Used only if scraper is enabled.
scraper.timeoutMs Integer 30000 Timeout for strip scraping, in milliseconds. Used only if scraper is enabled.

Real project’s goal

OK, this is mainly a test for various technologies, as Kotlin coroutines, Gradle’s Kotlin DSL, Discord4J, embedded Lucene index (there was a private ElasticSearch + Spring Boot version of this bot, which required way more RAM), Koin (dependency injection) Ktor (HTTP client), JSoup (HTML parsing) and MockK (mocking).

This also explains the lack of CI, very partial test coverage (some tests are quite complicated) and deployment stuff.

Transcripts from GoComics contains lots of typos, and indexation settings are badly tuned, thus this bot will probably give quite bad results.

calvinandbot's People

Contributors

spacefox avatar

Watchers

 avatar  avatar

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.