Senko

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2021 License: MIT Imports: 11 Imported by: 0

README

Telegram-senko-bot

MIT License Telegram Demo build-shield

UwU! An example!

About The Bot

This bot greets new members on telegram groups with a cute, personalised gif with Senko-san.

In case you're wondering, Senko-san is an adorable 800-year old fox goddess from the anime The Helpful Fox Senko-san (jp. 世話やきキツネの仙狐さん).

Getting Started

Follow these steps to set up your own version of this bot.

Prerequisites

For both development and runtime environments:

  • Go 1.13 (see instructions)
  • FFmpeg
    sudo apt install ffmpeg -y
    
Set up using Google Cloud Functions
  1. Download and install the Google Cloud SDK, for example with Snap:
    snap install google-cloud-sdk --classic
    gcloud init
    
  2. Clone the repo:
    git clone https://github.com/4Kaze/telegram-senko-bot.git
    
  3. Download NotoSansCJKjp-Black.otf font into the project folder:
    wget https://noto-website-2.storage.googleapis.com/pkgs/NotoSansCJKjp-hinted.zip -O fonts.zip
    unzip fonts.zip NotoSansCJKjp-Black.otf
    rm fonts.zip
    
  4. Deploy the bot to Google Cloud Functions replacing [YOUR TOKEN] with your bot token from BotFather:
    gcloud functions deploy SenkoSan --entry-point=HandleRequest --runtime go113 --trigger-http --allow-unauthenticated --set-env-vars TOKEN=[YOUR TOKEN]
    
  5. If everything went well, there should be a trigger url in the output in your terminal:
    HttpsTrigger:
        url: https://us-central1-bot-tele-002137.cloudfunctions.net/SenkoSan
    
    Set this url as a webhook for your bot:
    curl https://api.telegram.org/bot[YOUR TOKEN]/setWebhook?url=[YOUR URL]
    
Usage

The bot simply sends a gif with new member's name when they join a group.

In private messages, it supports the following commands:

  • /start - a standard command that displays the description
  • /genewate [name] - a command that generates a new gif with given name
  • /wepo - a command that sends the link to this repo

All names are stripped from emojis, symbols and are truncated to be at maximum 20 characters.

Contributing

I'm open for contributions. Feel free to fork the project to use it for your own means or to create a PR with new features / fixes.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Chat on Telegram

Acknowledgements

Documentation

Index

Constants

View Source
const (
	CHAT_TYPE_PRIVATE    = "private"
	CHAT_TYPE_GROUP      = "group"
	CHAT_TYPE_SUPERGROUP = "supergroup"
	MAX_NAME_CHARACTERS  = 20
	EMOJI_REGEX          = "[\U00010000-\U0010ffff]"
	SYMBOL_REGEX         = "[@#$-/:-?{-~!\"^_`\\[\\]]"
	COMMAND              = "" /* 165-byte string literal not displayed */
	INPUT_FILE           = "%s/greeting.mp4"
	GCP_DIR              = "./serverless_function_source_code"

	START_REPLY = `` /* 304-byte string literal not displayed */

	REPO_URL                   = "https://github.com/4Kaze/telegram-senko-bot"
	GENERATE_USAGE             = "Usage: /genewate [name], whewe [name] is uw name OwO"
	GENERATION_STARTED_MESSAGE = "Gotcha! OwO howd on, it wiww take a dozen seconds"
	START_COMMAND              = "/start"
	REPO_COMMAND               = "/wepo"
	GENERATE_COMMAND           = "/genewate"
)

Variables

This section is empty.

Functions

func HandleRequest

func HandleRequest(w http.ResponseWriter, r *http.Request)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL