Skip to content

Commit

Permalink
更新telegrambot
Browse files Browse the repository at this point in the history
  • Loading branch information
estea8968 committed Dec 15, 2024
1 parent 2ba719f commit 481c9ac
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 73 deletions.
2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google" value="notranslate">
<link rel="shortcut icon" href="static/favicon.ico">
<title>OSEP_scratch 1131214</title>
<title>OSEP_scratch 1131215</title>

</head>
<body>
Expand Down
87 changes: 34 additions & 53 deletions app/lib.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -445872,7 +445872,7 @@ var Scratch3TelegramBot = /*#__PURE__*/function () {
message: '',
imageFile: '',
chat_id: '',
stickerPackageId: ''
stickerPackage: ''
};
this.exec = 'https://script.google.com/macros/s/AKfycbyPMsaLgEEcia39_vcK1AmSGfpAi2YViAUcZFMbmKdYJ5niqDVui9Rgb4241Zdwca5d/exec';
}
Expand Down Expand Up @@ -445934,24 +445934,24 @@ var Scratch3TelegramBot = /*#__PURE__*/function () {
defaultValue: ' '
}
}
}, {
opcode: 'sendsticker',
blockType: BlockType.COMMAND,
text: msg.Sendsticker[the_locale],
arguments: {
STICKER: {
type: ArgumentType.NUMBER,
defaultValue: '😀',
menu: 'sticker_list'
}
}
}],
menus: {
sticker_list: {
acceptReporters: true,
items: ['😀', '😕', '😁', '😅', '🤣', '😍', '🤫', '🤔', '🤥', '😪', '😵‍💫', '🥳', '😭', '💓', '💔', '👋', '👌', '💩']
}
}
/*
{
opcode: 'sendstickerId',
blockType: BlockType.COMMAND,
text: msg.SendstickerId[the_locale],
arguments: {
STICKERId: {
type: ArgumentType.NUMBER,
defaultValue: 1,
},
StickerPackageId:{
type: ArgumentType.NUMBER,
defaultValue: 1,
}
},
},*/
]
};
} // command blocks

Expand Down Expand Up @@ -445991,7 +445991,7 @@ var Scratch3TelegramBot = /*#__PURE__*/function () {
},
body: JSON.stringify({
chat_id: this.payload.chat_id,
text: this.payload.message
text: this.payload.sticker + this.payload.message
})
});

Expand All @@ -446015,21 +446015,22 @@ var Scratch3TelegramBot = /*#__PURE__*/function () {
case 13:
// 成功發送後再清空
this.payload.message = '';
this.payload.sticker = '';
this.payload.imageFile = '';
_context.next = 20;
_context.next = 21;
break;

case 17:
_context.prev = 17;
case 18:
_context.prev = 18;
_context.t0 = _context["catch"](0);
console.error('Error sending message:', _context.t0);

case 20:
case 21:
case "end":
return _context.stop();
}
}
}, _callee, this, [[0, 17]]);
}, _callee, this, [[0, 18]]);
}));

function sendmessage(_x) {
Expand Down Expand Up @@ -446108,30 +446109,10 @@ var Scratch3TelegramBot = /*#__PURE__*/function () {
return sendimagefile;
}()
}, {
key: "sendstickerId",
value: function () {
var _sendstickerId = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(args) {
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
this.payload.stickerID = args.STICKERId;
this.payload.stickerPackageId = args.StickerPackageId;

case 2:
case "end":
return _context3.stop();
}
}
}, _callee3, this);
}));

function sendstickerId(_x3) {
return _sendstickerId.apply(this, arguments);
}

return sendstickerId;
}() // end of block handlers
key: "sendsticker",
value: function sendsticker(args) {
this.payload.sticker = this.payload.sticker + args.STICKER;
} // end of block handlers

}, {
key: "_setLocale",
Expand Down Expand Up @@ -446164,7 +446145,7 @@ module.exports = Scratch3TelegramBot;
/*!************************************************************************************!*\
!*** ./node_modules/scratch-vm/src/extensions/scratch3_telegrambot/translation.js ***!
\************************************************************************************/
/*! exports provided: checkOut, Token, SendMessage, TokenNull, SendstickerId, chat_id, SendImageFile */
/*! exports provided: checkOut, Token, SendMessage, TokenNull, Sendsticker, chat_id, SendImageFile */
/***/ (function(module, __webpack_exports__, __webpack_require__) {

"use strict";
Expand All @@ -446173,7 +446154,7 @@ __webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Token", function() { return Token; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SendMessage", function() { return SendMessage; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TokenNull", function() { return TokenNull; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SendstickerId", function() { return SendstickerId; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sendsticker", function() { return Sendsticker; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chat_id", function() { return chat_id; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SendImageFile", function() { return SendImageFile; });
var checkOut = {
Expand All @@ -446192,9 +446173,9 @@ var TokenNull = {
'en': 'Token or Message is null',
'zh-tw': '權杖或傳送訊息錯誤'
};
var SendstickerId = {
'en': 'set Package ID [StickerPackageId] Sticker ID [STICKERId]',
'zh-tw': '設定表情主題[StickerPackageId]表情代號[STICKERId] '
var Sendsticker = {
'en': 'set Send Package image[STICKER]',
'zh-tw': '設定的送出表情圖[STICKER]'
};
var chat_id = {
'en': 'Chat ID: [ID] ',
Expand Down
2 changes: 1 addition & 1 deletion app/lib.min.js.map

Large diffs are not rendered by default.

36 changes: 21 additions & 15 deletions source/scratch-vm/src/extensions/scratch3_telegrambot/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const ml5 = require('ml5');
//const jqueryMin = require("./jquery.min.js");
//require('babel-polyfill');
//參考文件https://blog.sean.taipei/2016/10/telegram-bot


let the_locale = null;

class Scratch3TelegramBot {
Expand All @@ -27,7 +29,7 @@ class Scratch3TelegramBot {
message:'',
imageFile:'',
chat_id : '',
stickerPackageId : ''
stickerPackage : ''
};
this.exec = 'https://script.google.com/macros/s/AKfycbyPMsaLgEEcia39_vcK1AmSGfpAi2YViAUcZFMbmKdYJ5niqDVui9Rgb4241Zdwca5d/exec';
}
Expand Down Expand Up @@ -93,24 +95,27 @@ class Scratch3TelegramBot {
}
},
},
/*

{
opcode: 'sendstickerId',
opcode: 'sendsticker',
blockType: BlockType.COMMAND,
text: msg.SendstickerId[the_locale],
text: msg.Sendsticker[the_locale],
arguments: {
STICKERId: {
STICKER: {
type: ArgumentType.NUMBER,
defaultValue: 1,
defaultValue: '😀',
menu: 'sticker_list'
},
StickerPackageId:{
type: ArgumentType.NUMBER,
defaultValue: 1,
}
},
},*/
},

],
menus: {
sticker_list: {
acceptReporters: true,
items: ['😀', '😕','😁', '😅', '🤣', '😍', '🤫', '🤔', '🤥','😪','😵‍💫','🥳','😭','💓','💔','👋','👌','💩']
},
}

};
}
Expand Down Expand Up @@ -143,7 +148,7 @@ class Scratch3TelegramBot {
},
body: JSON.stringify({
chat_id: this.payload.chat_id,
text: this.payload.message
text: this.payload.sticker+this.payload.message
})
}
);
Expand All @@ -158,6 +163,7 @@ class Scratch3TelegramBot {

// 成功發送後再清空
this.payload.message = '';
this.payload.sticker = '';
this.payload.imageFile = '';

} catch (error) {
Expand Down Expand Up @@ -201,9 +207,9 @@ class Scratch3TelegramBot {
}
}

async sendstickerId(args){
this.payload.stickerID = args.STICKERId;
this.payload.stickerPackageId = args.StickerPackageId;
sendsticker(args){

this.payload.sticker = this.payload.sticker+args.STICKER;
}
// end of block handlers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export const TokenNull ={
'zh-tw': '權杖或傳送訊息錯誤',
};

export const SendstickerId ={
'en': 'set Package ID [StickerPackageId] Sticker ID [STICKERId]',
'zh-tw': '設定表情主題[StickerPackageId]表情代號[STICKERId] ',
export const Sendsticker ={
'en': 'set Send Package image[STICKER]',
'zh-tw': '設定的送出表情圖[STICKER]',
};
export const chat_id ={
'en': 'Chat ID: [ID] ',
Expand Down

0 comments on commit 481c9ac

Please sign in to comment.