abelidze / JentuBot

Arios Jentu: Interactive fiction game

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About JentuBot

Arios Jentu (also named JentuBot) is an interactive fiction game from Star Wars about invented by fans character 'Arios Jentu'.

Game is written as Telegram Messenger Bot with using of its API, Python3 language and different libraries for it that are listed below.

Installation

Download project as '.zip' archive and extract it to whatever you like directory or use git:

$ git clone https://github.com/SkillMasters/JentuBot

[Linux only] And then give execute permissions for some shell-scripts:

$ cd JentuBot/run
$ chmod +x loopbot.sh startbot.sh

After installing you shall see the following files and directories:

	archive/             old versions which is using get_updates method
	config/              configurations directory
	jentudb/             database and adminer for it
	requirements/        there would be requirements checker script
	resource/            resource folder for web-application
	run/                 executable scripts to run bot
	ssl/                 certificate examples
	*.py                 source bot files
	CHANGELOG            describing changes
	README               this file

Requirements

Utils and programs:


Python:

Installing:

You can use python-pip to easily install all needed Python packages:

$ pip install pyTelegramBotAPI peewee cherrypy celery==3.1.25

or

$ pip install -r /path/to/JentuBot/requirements/requirements.txt

Used ports:

  • Redis -> 8060
  • CherryPy -> 443
  • PHP(for Adminer) -> 80

Note: you can change it for yourself through related configs

Configuring

JentuBot settings

[bottoken.py]

As Telegram Bot API uses tokens for detecting bots you'll need to add it to your configuration.
For this JentuBot is using a file 'bottoken.py' and function de_token() from 'functions.py'.
You can write your own function for encrypting / decrypting your token or just use it directly - choice is yours.

# Example of bottoken.py file. Place your encrypted / decrypted token here:
token = "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11"

[settings.py]

All JentuBot settings are placed in a single file 'settings.py'. From this file you can configure all main bot's constants.

[database.py]

Because jentu.db isn't distributed with JentuBot you need to configure WEBSERVER_DB constant from settings.py and just run database.py once:

python database.py

It will generate an empty "ready-to-work" SQLite database file.

[redis.conf]

This is an optional Redis settings file which is placed in './config/' directory.

# Main options from it:
port 8060
bind 127.0.0.1
loglevel verbose
dir "/path/to/Redis/data"
logfile "/path/to/Redis/logs/redis.log"

SSL certificate generation

If you want to generate self-signed certificate for using a webhooh, you need to install openssl and use it in this way:

$ openssl genrsa -out application_key.pem 2048
$ openssl req -new -x509 -days 3650 -key application_key.pem -out application_cert.pem

Notes:

  • You'll have to go through the regular routine entering some information while creating a certificate;
  • BUT! When you'll asked to enter 'Common name' be sure to enter IP address of your bot;
  • Certificate generated by command above will be valid for 3650 days (~10 years).

Running

MANUAL

To get bot working you'll need to:

  1. Navigate to JentuBot directory:
    cd /path/to/jentubot
  2. Start Redis-Server:
    redis-server config/redis.conf
  3. Start Celery:
    celery worker -A tasks_config --loglevel=info
  4. And finally run JentuBot:
    python main.py
  5. Optional: also you can start php-server to work with bot database:
    cd jentdb
    php -S 127.0.0.1:80

Note:

  1. on some Linux systems some commands (such as starting php server or main.py) need sudo for successfull running.
  2. use screen, tmux, jobs or similar utils on Linux if you want to start all your bot's services from the same terminal.

AUTOMATIC

Instead of manual launching you can use our scripts ./startbot.sh on Linux and startbot.bat on Windows.

Note that to get them working on Linux you need to install screen and edit your python path /usr/local/bin/python3 from ./loopbot.sh.

Contact

"Arios Jentu" official bot in Telegram: @JentuBot

Developers on Telegram:

https://telegram.me/Abelidze

https://telegram.me/AriosJentu

P.S> Unfinished section

Credits

Developer Product
@eternnoir pyTelegramBotAPI

P.S> Unfinished section

License

P.S> Unfinished section

Disclaimer

This program is provided "AS IS" without warranty of any kind.

About

Arios Jentu: Interactive fiction game

License:MIT License


Languages

Language:Python 96.3%Language:Shell 2.7%Language:Batchfile 1.0%