This project allows to start server part with java server side for generating QR images with different variations and settings
All parameters need to be passed through GET
parameters to servlet
All dependencies, that you need are showed here:
- google xing-core 3.4.0
- jfreesvg 3.4.3
- javax.servlet-api 4.0.0
All properties for this application are located in web.xml
Maven To build the application with maven, use:
mvn clean package
To clean the target
folder
mvn clean
Makefile
Before using Makefile
, make sure to place all libraries in lib
directory in project root
To build the application with Makefile
, use:
make all
To clean the working directory, use:
make clean
As example this type of url: https://qr.qxyz.ru/?q=123&p=123
Parameters:
q: String;
p?: String;
d?: String;
site?:String;
All types in array:
['TEXT', 'URL', 'PHONE', 'SMS', 'EMAIL', 'CONTACT', 'WIFI', 'LOCATION']
All types exact explanation:
- Text generation
Parameters:
text: String;
type: TEXT;
- URL generation
Parameters:
url: String;
type: URL;
- Phone number
Parameters:
phone: String;
type: PHONE;
- SMS
Parameters:
phone: String; (валидатор для номеров)
text: String;
type: SMS;
- Email message
Parameters:
email: String;
subject: String;
text: String;
type: EMAIL;
- Contacts
Parameters:
firstName: String;
lastName?: String;
organization?: String;
title?: String;
email?: String;
phone?: String;
mobilePhone?: String; (same)
fax?: String;
street?: String;
city?: String;
region?: String;
postcode?: String;
country?: String;
url?: String;
type: CONTACT;
- WiFi Connection
Parameters:
ssid: String;
password?: String;
encryption?: WEP | WPA;
type: WIFI;
- Location Generating
Parameters:
latitude: float; (dot - separator)
longitude: float;
distance: integer;
type: LOCATION;
color?: String; (формат hex)
background?: String; (формат hex)
fileType?: FileType;
x?: Integer; // размер картинки в px (макс - 2048px)
correctionLevel?: CorrectionLevel;
FileType: [svg, png, jpg, jpeg]
CorrectionLevel: [L, M, Q, H]
- Write to a
BotFather
inTelegram
to get yourAPI key
; - Configure your bot as you like, you may choose name, description and other settings;
- Recommended command to add is
/types
- to add a command for showing available qr types.
All dependencies, that you need are shown here:
- java-telegram-bot-api 7.9.1
- gson-2.10.1
- logging-interceptor-4.12.0
- okhttp-4.12.0
- okio-3.6.0
- okio-jvm-3.6.0
There are options to configure generated QR codes.
- dicrectly in code you can configure
URL
to choose options for qr code, that will be generating - properties file provides an ability to write a token and
URL
to the generating servlet direct, alsodemon
property to define will is detach from console or no.\ Fillbot.token
with your telegram bot token, and qxyz.url with URL to servlet
The main principle consists of using servlet as QR generating platform for telegram bot.
Therefore, you should provide an ability to generate a QR code from Telegram Bot application
Maven
To build the application with maven, go to Bots
directory:
cd Bots/
Then, build with maven:
mvn clean package
To clean the target
folder
mvn clean
Makefile
To build with Makefile
, stay in parent directory and use (!!make sure all dependencies are in lib
):
make all
To clean the working directory, use:
make clean
You might want to start this application for testing, then use starting as java application (property demon should be false
)
Go in work
folder, you will find jar
files and shell
scripts to run application as a demon
cd work/
To start an application as java application, use:
java -jar telegramBot.jar
To start an application as deamon, use scripts in work
folder:
./startBot.sh
Running this script will create a file with PID
of an application, to close it with stopBot.sh
script
./stopBot.sh
The application will automatically try to create a log file next to the jar
file