From e3785a535783307949acfaa161fb708cc68b5be1 Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Fri, 10 Feb 2017 17:50:25 +0300 Subject: [PATCH 1/5] [Feature] Openshift --- README.md | 29 ++++++++++++++++++++++++++++- core/config.js | 2 +- core/telegram.js | 10 ++++++---- 3 files changed, 35 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index bed6876..f5c6e2e 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ For Unix users, use the preffered method [here](https://nodejs.org/en/download/) ### MongoDB -You need MongoDB to run this bot, You can get a free deployment from [mongolab](https://mlab.com). Follow the instructions below: +You need MongoDB to run this bot, You can get a free deployment from [mongolab](https://mlab.com). Follow the instructions below (skip if deploying to Openshift): @@ -152,6 +152,33 @@ $ npm install -g forever $ forever start bot.js ``` +### Openshift + + + +```bash +# Ensure You Have Node.JS Installed! +$ node -v + +# Clone The Repo +$ git clone https://github.com/kamikazechaser/ThorsHammer.git -b openshift +$ cd ThorsHammer +# Ensure all fields in core/config.js are present! Except the MONGODB_URL, leave it as is! + +# Log into your Openshift web console +# Create a new app +# Select Node.js [Latest] +# Launch the app +# Add a cartridge > Install your own cartridge +# Enter this => https://raw.githubusercontent.com/icflorescu/openshift-cartridge-mongodb/master/metadata/manifest.yml +# Add your ssh keys to Openshift and ensure they are available in $HOME/.ssh locally +# Copy your git address from the side, on the web console + +$ git remote add openshift [REMOTE GIT ADDRESS, COPIED FROM ABOVE] +$ git push openshift master --force + +``` + *Other Strategies* You can modify `core/telegram.js` to implement your own strategy, such as clustering or websockets. diff --git a/core/config.js b/core/config.js index c6a851f..a70d29b 100644 --- a/core/config.js +++ b/core/config.js @@ -1,5 +1,5 @@ module.exports = { - MONGO_URI: process.env.MONGO_URI || '', + MONGO_URI: process.env.MONGODB_URL || '', BOT_TOKEN: process.env.BOT_TOKEN || '', SUDO: process.env.SUDO || '', LOG_CHANNEL: process.env.LOG_CHANNEL || '' diff --git a/core/telegram.js b/core/telegram.js index cb3f84b..a6b7803 100644 --- a/core/telegram.js +++ b/core/telegram.js @@ -1,13 +1,15 @@ 'use strict'; -const Tg = require('node-telegram-bot-api'); +const Tgfancy = require('tgfancy'); const config = require('./config'); const moment = require('moment'); const rangi = require('rangi'); -const bot = new Tg(config.BOT_TOKEN, { - polling: true -}); +const bot = new Tgfancy(config.BOT_TOKEN, { + tgfancy: { + openshiftWebHook: true, + }, +});; bot.getMe().then(me => { console.log(rangi.cyan(`Bot Is Running => ${me.username}`)); From 9b9d6cf66bbd645abfb524df2cb122a4e892ca7d Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Fri, 10 Feb 2017 17:56:20 +0300 Subject: [PATCH 2/5] [Fix] Add tgfancy to package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 79a7e9c..32dec48 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "keywords": [ "telegram", "banhammer" - ], + ], "repository": { "type": "git", "url": "https://github.com/kamikazechaser/ThorsHammer" @@ -20,8 +20,8 @@ "moment": "^2.17.1", "mongoose": "^4.7.8", "node-cron": "^1.1.2", - "node-telegram-bot-api": "^0.26.0", "rangi": "^1.0.1", - "tg-resolve": "^1.3.1" + "tg-resolve": "^1.3.1", + "tgfancy": "^0.8.0" } } From 3b16840cd11d40bc49b9c4b81602a05fb233e0db Mon Sep 17 00:00:00 2001 From: Sahri Riza Umami Date: Wed, 22 Mar 2017 09:00:20 +0700 Subject: [PATCH 3/5] [Translation] Bahasa Indonesia --- controllers/menu.js | 71 ++++++++++++++++++++++++++++++++------------- core/locale.json | 17 ++++++++++- 2 files changed, 67 insertions(+), 21 deletions(-) diff --git a/controllers/menu.js b/controllers/menu.js index 4824812..481d763 100644 --- a/controllers/menu.js +++ b/controllers/menu.js @@ -21,6 +21,9 @@ const helpKeyboard = [[{ }, { text: `๐Ÿ‡ฎ๐Ÿ‡น Italiano`, callback_data: `help_it` +}, { + text: `๐Ÿ‡ฎ๐Ÿ‡ฉ Bahasa Indonesia`, + callback_data: `help_id` }]] const inlineKeyboard = [[{ @@ -41,6 +44,9 @@ const inlineKeyboard = [[{ }, { text: `๐Ÿ‡ฎ๐Ÿ‡น Italiano`, switch_inline_query_current_chat: `help it` +}, { + text: `๐Ÿ‡ฎ๐Ÿ‡ฉ Bahasa Indonesia`, + switch_inline_query_current_chat: `help id` }]] bot.onText(/^[\/!#]start$/, msg => { @@ -84,10 +90,13 @@ bot.on('callback_query', msg => { } if (lang == `ar`) { lang = locale.ar - } + } if (lang == `it`) { lang = locale.it - } + } + if (lang == `id`) { + lang = locale.id + } bot.answerCallbackQuery(msg.id, `๐Ÿ‘`); if (msg.data == `help_${langCode}`) { bot.editMessageText(`${lang.start}`, { @@ -145,10 +154,13 @@ bot.on('callback_query', msg => { } if (lang == `ar`) { lang = locale.ar - } + } if (lang == `it`) { lang = locale.it - } + } + if (lang == `id`) { + lang = locale.id + } bot.answerCallbackQuery(msg.id, `๐Ÿ‘`); if (msg.data == `banhammer_help_${langCode}`) { bot.editMessageText(`${lang.banhammerinfo}`, { @@ -175,7 +187,7 @@ bot.on('callback_query', msg => { }]] } }) - } + } }); bot.on('callback_query', msg => { @@ -201,10 +213,13 @@ bot.on('callback_query', msg => { } if (lang == `ar`) { lang = locale.ar - } + } if (lang == `it`) { lang = locale.it - } + } + if (lang == `id`) { + lang = locale.id + } bot.answerCallbackQuery(msg.id, `๐Ÿ‘`); if (msg.data == `globaladmin_help_${langCode}`) { bot.editMessageText(`${lang.globaladmininfo}`, { @@ -218,7 +233,7 @@ bot.on('callback_query', msg => { }]] } }) - } + } }); bot.on('callback_query', msg => { @@ -244,10 +259,13 @@ bot.on('callback_query', msg => { } if (lang == `ar`) { lang = locale.ar - } + } if (lang == `it`) { lang = locale.it - } + } + if (lang == `id`) { + lang = locale.id + } bot.answerCallbackQuery(msg.id, `๐Ÿ‘`); if (msg.data == `ingroup_help_${langCode}`) { bot.editMessageText(`${lang.ingroupinfo}`, { @@ -300,10 +318,13 @@ bot.on('callback_query', msg => { } if (lang == `ar`) { lang = locale.ar - } + } if (lang == `it`) { lang = locale.it - } + } + if (lang == `id`) { + lang = locale.id + } bot.answerCallbackQuery(msg.id, `๐Ÿ‘`); if (msg.data == `about_help_${langCode}`) { bot.editMessageText(`${lang.aboutinfo}`, { @@ -317,7 +338,7 @@ bot.on('callback_query', msg => { }]] } }) - } + } }); bot.on('callback_query', msg => { @@ -346,7 +367,10 @@ bot.on('callback_query', msg => { } if (lang == `it`) { lang = locale.it - } + } + if (lang == `id`) { + lang = locale.id + } bot.answerCallbackQuery(msg.id, `๐Ÿ‘`); if (msg.data == `banhammer_help_${langCode}`) { bot.editMessageText(`${lang.banhammerinfo}`, { @@ -400,10 +424,13 @@ bot.on('callback_query', msg => { } if (lang == `ar`) { lang = locale.ar - } + } if (lang == `it`) { lang = locale.it - } + } + if (lang == `id`) { + lang = locale.id + } bot.answerCallbackQuery(msg.id, `๐Ÿ‘`); if (msg.data == `recycle_help_${langCode}`) { bot.editMessageText(`*Help Menu*`, { @@ -464,7 +491,10 @@ bot.on('inline_query', function(msg) { } if (lang == `it`) { lang = locale.it - } + } + if (lang == `id`) { + lang = locale.id + } let opts = []; if (msg.query == `help ${langCode}`) { opts = [ @@ -507,7 +537,7 @@ bot.on('inline_query', function(msg) { message_text: lang.aboutinfo, parse_mode: `Markdown`, thumb_url: `http://emojipedia-us.s3.amazonaws.com/cache/a3/88/a3881d9895bfa74d5f8c6acea0953c3d.png` - + }, { type: `article`, @@ -516,7 +546,7 @@ bot.on('inline_query', function(msg) { message_text: lang.creditsinfo, parse_mode: `Markdown`, thumb_url: `http://emojipedia-us.s3.amazonaws.com/cache/51/5b/515b0cff9d179c6b7fa14d5ee54deebb.png` - } + } ] } else { @@ -535,4 +565,5 @@ bot.on('inline_query', function(msg) { ] } bot.answerInlineQuery(msg.id, opts); -}); \ No newline at end of file +}); + diff --git a/core/locale.json b/core/locale.json index 36dd39c..c23906b 100644 --- a/core/locale.json +++ b/core/locale.json @@ -88,5 +88,20 @@ "ingroupinfo": "Coming Soon!", "aboutinfo": "Coming Soon!", "creditsinfo": "Coming Soon!" + }, + "id": { + "start": "*Pengenalan\n\n*ThorsHammer adalah sebuah bot moderasi sederhana yang melengkapi _Group Butler/GroupThor_. Siapapun dapat menggunakan bot ini di dalam grupnya untuk mengerjakan tugas sederhana seperti:\n1๏ธโƒฃ๏ธ _Kick_ dan _Ban_\n*dan yang terpenting*,\n2๏ธโƒฃ๏ธ Mencegah para _spammer_, yang telah di_ban_ secara global, agar tidak masuk ke dalam grup!\n\nUntuk memulai, jadikan bot ini sebagai administrator grup.\n\nUntuk keterangan lebih lanjut, gunakan perintah /help.\n\n*Menu Bantuan*\n\n๐Ÿ’ก Saran: Gunakan _Inline Mode_!\n\nDalam grup, ketik `@thorshammerbot` kemudian spasi diikuti perintah.", + "banhammer_help": "Banhammer", + "superuser_help": "Superuser", + "globaladmin_help": "Admin Global", + "ingroup_help": "Dalam Grup", + "about_help": "Tentang", + "credits_help": "Kredit", + "banhammerinfo": "*Perintah Banhammer*\n\nAwali perintah dengan `/`, `!`, atau `#`\n\nโ€ข `/hammer [menggunakan reply|username|id]`: _ban user_ secara global dari seluruh grup.\nโ€ข `/unhammer [menggunakan reply|username|id]`: _unban user_ secara global dari seluruh grup.", + "superuserinfo": "*Perintah Superuser*\n\nAwali perintah dengan `/`, `!`, atau `#`\n\nโ€ข `/promote [menggunakan reply|username|id]`: angkat _user_ menjadi admin global.\nโ€ข `/demote [menggunakan reply|username|id]`: turunkan _user_ dari jabatan admin global.", + "globaladmininfo": "*Perintah Admin Global*\n\nAwali perintah dengan `/`, `!`, atau `#`\n\nAdmin global dapat sepenuhnya menggunakan banhammer, seorang admin global hanya bisa diangkat oleh _superuser_.\n\nโ€ข `/banlist`: kirim daftar _ban_ ke kanal _log_ (pencatat).", + "ingroupinfo": "*Perintah dalam grup*\n\nAwali perintah dengan `/`, `!`, atau `#`\n\nโ€ข `/kick [menggunakan reply]`: keluarkan _user_ dari grup.\nโ€ข `/ban [menggunakan reply]`: _ban user_ dari grup.\nโ€ข `/admins`: daftar administrator grup.\nโ€ข `/globaladmins`: daftar admin global yang dapat menggunakan banhammer.", + "aboutinfo": "*Keterangan*\n\n_Lisensi:_ AGPL-v3.0\n_Ditulis oleh:_ @kamikazechaser\n_Kode sumber:_ [ThorsHammer](https://github.com/kamikazechaser/ThorsHammer)", + "creditsinfo": "*Penerjemah*\n\n๐Ÿ‡ช๐Ÿ‡ธ - {Insert Name Here}\n๐Ÿ‡ง๐Ÿ‡ท - {Insert Name Here}\n๐Ÿ‡ฎ๐Ÿ‡ท - {Insert Name Here}\n๐Ÿ‡ธ๐Ÿ‡ฆ - {Insert Name Here}\n๐Ÿ‡ฎ๐Ÿ‡น - {Insert Name Here}\n๐Ÿ‡ฎ๐Ÿ‡ฉ - Sahri Riza Umami" } -} \ No newline at end of file +} From 65f9097354c1b710c9efd5066c763f16fd751c50 Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Wed, 22 Mar 2017 14:02:17 +0530 Subject: [PATCH 4/5] [Doc] Add credits to Readme --- README.md | 5 +++-- controllers/menu.js | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f5c6e2e..3a2e6cb 100644 --- a/README.md +++ b/README.md @@ -192,11 +192,12 @@ Star and Fork the repository and submit a pull request for whatever change you w Translations are welcome. Languages given priority are: -- ๐Ÿ‡ช๐Ÿ‡ธ Espaรฑol +- ๐Ÿ‡ช๐Ÿ‡ธ Espaรฑol - Translated by [@keijodputt](https://github.com/keijodputt) - ๐Ÿ‡ง๐Ÿ‡ท Portuguรชs - ๐Ÿ‡ฎ๐Ÿ‡ท Farsi -- ๐Ÿ‡ธ๐Ÿ‡ฆ Arabic +- ๐Ÿ‡ธ๐Ÿ‡ฆ Arabic - Translated by [@rix4r](https://github.com/claydev) - [full arabic fork](https://github.com/claydev/ThorsHammer) - ๐Ÿ‡ฎ๐Ÿ‡น Italiano +- ๐Ÿ‡ฎ๐Ÿ‡ฉ Bahasa Indonesia - Transalted by [@rizaumami](https://github.com/rizaumami) - [full bahasa indonesia fork](https://github.com/rizaumami/TGramIndoBot) Edit the respective fields in `core/locale.json` and submit a pull request. be careful of Markdown elements and `\n`, they are important! diff --git a/controllers/menu.js b/controllers/menu.js index 481d763..36478ed 100644 --- a/controllers/menu.js +++ b/controllers/menu.js @@ -566,4 +566,3 @@ bot.on('inline_query', function(msg) { } bot.answerInlineQuery(msg.id, opts); }); - From 7c09982f40324a10163ffd39971a40a5ef7f4764 Mon Sep 17 00:00:00 2001 From: Mohammed Sohail Date: Wed, 22 Mar 2017 14:12:46 +0530 Subject: [PATCH 5/5] [Fix] to master --- README.md | 1 - core/config.js | 2 +- core/telegram.js | 12 +++++------- package.json | 6 +++--- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3a2e6cb..ed36df1 100644 --- a/README.md +++ b/README.md @@ -204,4 +204,3 @@ Edit the respective fields in `core/locale.json` and submit a pull request. be c ## License Released under AGPL-v3.0, see the [LICENSE](https://github.com/kamikazechaser/ThorsHammer/blob/master/LICENSE) file. - diff --git a/core/config.js b/core/config.js index a70d29b..c6a851f 100644 --- a/core/config.js +++ b/core/config.js @@ -1,5 +1,5 @@ module.exports = { - MONGO_URI: process.env.MONGODB_URL || '', + MONGO_URI: process.env.MONGO_URI || '', BOT_TOKEN: process.env.BOT_TOKEN || '', SUDO: process.env.SUDO || '', LOG_CHANNEL: process.env.LOG_CHANNEL || '' diff --git a/core/telegram.js b/core/telegram.js index a6b7803..12bf424 100644 --- a/core/telegram.js +++ b/core/telegram.js @@ -1,19 +1,17 @@ 'use strict'; -const Tgfancy = require('tgfancy'); +const Tg = require('node-telegram-bot-api'); const config = require('./config'); const moment = require('moment'); const rangi = require('rangi'); -const bot = new Tgfancy(config.BOT_TOKEN, { - tgfancy: { - openshiftWebHook: true, - }, -});; +const bot = new Tg(config.BOT_TOKEN, { + polling: true +}); bot.getMe().then(me => { console.log(rangi.cyan(`Bot Is Running => ${me.username}`)); bot.sendMessage(config.SUDO, `Bot Started!\n${moment().format('MMMM Do YYYY, h:mm:ss a')}`, {parse_mode: 'Markdown'}); }); -module.exports = bot; \ No newline at end of file +module.exports = bot; diff --git a/package.json b/package.json index 32dec48..79a7e9c 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "keywords": [ "telegram", "banhammer" - ], + ], "repository": { "type": "git", "url": "https://github.com/kamikazechaser/ThorsHammer" @@ -20,8 +20,8 @@ "moment": "^2.17.1", "mongoose": "^4.7.8", "node-cron": "^1.1.2", + "node-telegram-bot-api": "^0.26.0", "rangi": "^1.0.1", - "tg-resolve": "^1.3.1", - "tgfancy": "^0.8.0" + "tg-resolve": "^1.3.1" } }