Git Product home page Git Product logo

tgjava's Introduction

tgjava

This is a program running in docker using telegram-cli to send/receive messages via MySQL database.

To register a new phone, please run:

docker run -it -v /path/to/myconfig:/root/.telegram-cli b3vis/telegram-cli

/path/to/myconfig is a directory to keep telegram-cli config or session. Please use the same directory in docker-compose.yml.

After that we may run the program using "docker-compose up -d" using the docker-compose.yml file in the docker folder.

The docker-compose.yml file used to run/setup the MySQL database is inside the docker/mysql folder.

Then we use the following SQL to create tables in a database called "telegram" in MySQL database:

CREATE TABLE IF NOT EXISTS contacts ( contact_id int(11) NOT NULL AUTO_INCREMENT, phone varchar(50) COLLATE utf8_unicode_ci NOT NULL, user_id int(11) NOT NULL, nickname varchar(50) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (contact_id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

CREATE TABLE IF NOT EXISTS incoming ( msg_id int(11) NOT NULL, msg_phone varchar(50) COLLATE utf8_unicode_ci NOT NULL, msg_text varchar(1000) COLLATE utf8_unicode_ci NOT NULL, msg_rid int(11) NOT NULL DEFAULT '0', msg_status int(11) NOT NULL DEFAULT '0', msg_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (msg_id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS outgoing ( msg_id int(11) NOT NULL AUTO_INCREMENT, msg_phone varchar(50) COLLATE utf8_unicode_ci NOT NULL, msg_text varchar(1000) COLLATE utf8_unicode_ci NOT NULL, msg_status int(11) NOT NULL DEFAULT '0', msg_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (msg_id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;

To send a message out, insert an entry into the outgoing table. E.g.

INSERT outgoing (msg_phone, msg_text) VALUES ('60121010101', 'This is a test message.')

To send a chat group message, please add the telegram phone number into the group and then send a message 'identify' to this chat group. You shall receive an id identifying the group. If the group id is 12345 for example, just prefix 'g' in front:

INSERT outgoing (msg_phone, msg_text) VALUES ('g12345', 'This is a test chat message.')

Incoming messages are stored into the incoming table.

tgjava's People

Contributors

jinfeei avatar

Watchers

 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.