/ebooks

Creates markov-chains from text gathered in a discord server and other shitty memes

Primary LanguagePythonGNU General Public License v3.0GPL-3.0

ebooks

Creates markov-chains from text gathered in a discord server to then post them or write them on images. And lots more…

Uses discord.py, markovify, python-pillow and pyfiglet

Table of Contents

Setup

Usage

Settings

Contributing

License

Setup

replace token on the last line client.run('token') with your bot token

make sure you have the correct libraries installed

start with python3.5 ebooks.py


or just invite the bot to your server with:

https://discordapp.com/oauth2/authorize?client_id=189772464161685506&scope=bot

Usage

Commands

set username to change my username (this only works twice per hour)

@ebooks set username newusername

set avatar to change my avatar

@ebooks set avatar http(s)://website.tld/imageurl

settings set to change an option

@ebooks settings set option value

settings show shows the currently set options

@ebooks settings show

meme text to get a dank meme (if no text is given a random sentence will be generated)

@ebooks meme_text sentence

meme image to get a meme_image (uses the last posted image on the server)

@ebooks meme_image meme

animated send an animated text message

@ebooks animated animation

ascii turns your message into huge ascii letters

@ebooks ascii string

information sends the current stats

@ebooks info

say sends a message to all mentioned channels

@ebooks say string #channel-mention1 #channel-mention2 … #channel-mentionN

invite to receive an invite link for another server

@ebooks invite

Animated Text

slot machine

Set the slot machine items with @ebooks settings set slot_machine emoji1 emoji2 emoji3 … emojiN

slot_machine

dick

Yeah i know…

dick

meme text

Alias: meme_txt, meme_text

meme text

meme image

Alias: meme_img, meme_image

Information

Alias: info

information

ascii

Turns text into ascii:

ascii text

Manga preview

When sadpanda is set to true the bot will post the info

sadpanda manga preview

when fakku is set to true the bot will post the info

fakku manga preview

Farewell and Greetings

If farewell or greetings is set to true the bot will post a configurable message as soon as a new member joins/leaves.

set this message with @ebooks settings set farewell_text/greetings_text **Hope to see you soon again, $member <3**

possible variables are:

  1. $member will be replaced with the name of the new/leaving member

  2. $mention will be replaced with a mention of that user

  3. $server will be replaced with the name of that server

Conversation

Mention @ebooks and he will respond with a random sentence based on previous messages on the server (markov-chains).

You need to exchange a few dozen messages for this to properly work.

Questions

Questions are messages with a bot mention and ending on a ?

choice

If the question contains an or the bot will decide between the choices. You can add more choices with a ,.

choice

yes/no

If no or is included the bot presumes this is a yes/no question and sends an image-url to an anime girl saying either yes or no.

Sleep

If a message contains the word sleep or night, the bot will respond with an image-url to a kagapost

Ratings

If you include the word rate in your message the bot will give a rating from 1 to 10.

Settings

settings set

For commands that only a certain role should be able to use, you can just use a role mention.

Every role that is higher in the role hierarchy will also have access to that command.

Currently those are:

  1. info (settings command)
  2. meme_img
  3. meme_txt
  4. image (the deprecated pic command)
  5. help
  6. ascii
  7. animated
  8. say

role option

You can disable certain context cues by setting them to false.

Currently those are:

  1. question
  2. fakku
  3. sadpanda
  4. rate
  5. farewell
  6. greetings
  7. animated
  8. sleep

bool option

The other options are:

  1. farewell_text
  2. greetings_text
  3. slot_machine

settings show

If you don't give any further arguments every option will be displayed:

settings show all

If you add the name of one option only that will be shown:

settings show one

If you only want mentions and raw text add a quiet at the end:

settings quiet

settings advanced

If you're hosting an instance yourself and want to manually edit the settings for a server, you can find a settings.json in every server directory (the directories are named after the server ids) Example:

{
	"info": "236706075779268609", 
	"meme_img": "236706075779268609", 
	"question": true, 
	"greetings_text": "**Welcome $mention to __$server__**!", 
	"version": 6, 
	"image": "236706075779268609", 
	"slot_machine": [":pizza:", ":frog:", ":alien:", ":green_apple:", ":heart:"], 
	"fakku": true, 
	"sadpanda": true, 
	"farewell_text": "**Hope to see you soon again, $member <3**", 
	"meme_txt": "236706075779268609", 
	"help": "236706075779268609", 
	"options": "236806163763560449", 
	"rate": true, 
	"farewell": false, 
	"ascii": "236706075779268609", 
	"greetings": false, 
	"animated": "236706075779268609", 
	"sleep": true, 
	"say": "236806163763560449"
}

the version key is need to add new options to the settings file.

the long numbers resemble the role id.

contributing

Besides the usual code cleaning I should do and new memes, both commands meme image and meme text both use this json file: info.json

You can easily create new memes for these two commands by make pull requests for this file.

To add a new image for meme text add an entry in this form: (play around with the size, it's not pixel based.=

{
  "memes_text": [
    {
      "image": "image name",
      "image_url": "image url",
      "style": "choose a style",
      "size": {
        "up": border top (integer),
        "left": border left (integer),
        "bottom": border bottom (integer),
        "right": border right (integer),
        "center": center point (integer)
      }
    }
  ]
}

If you want to use a different font, you can define a new style like this:

{
  "styles": {
    "manga00": {
      "font": "font name",
      "font_size": font size,
      "font_color": "font color in hex-decimal",
      "font_url": "a link to the font"
    }
}

To add a new meme for meme image add an entry in this form: (if background is set to true the original image will be placed on top. background_color defines a background color for transparent images in RGBA notation.)

{
  "memes_images": {
    "name of meme": {
      "image": "image name",
      "image_url": "image url",
      "background" : bool
      "background_color" : [0,0,0,0] 
    }
  }
}

#License ebooks uses a gpl license available here