Skip to content

Commit

Permalink
Fixed tickets /close
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-kotorov committed Dec 16, 2019
1 parent 86a9d41 commit 0b58435
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ typings/
.env

config.js
config.js
6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/telegram-support-bot.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

194 changes: 194 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file removed bin/support.db
Binary file not shown.
29 changes: 18 additions & 11 deletions bin/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ bot.command('open', (ctx) => {

for (let i in userList) {
if (userList[i]['userid'] !== null && userList[i]['userid'] !== undefined) {
openTickets += '<code>#t' + userList[i]['userid'].toString() + '</code>\n';
openTickets += '#t' + userList[i]['userid'].toString() + '\n';
}
}
setTimeout(function() {
Expand All @@ -268,18 +268,25 @@ bot.command('close', (ctx) => {
ctx.getChatAdministrators().then(function(admins) {
admins = JSON.stringify(admins);
if (
ctx.message.reply_to_message !== undefined &&
admins.indexOf(ctx.from.id) > -1
) {
let replyText = ctx.message.reply_to_message.text;
let userid = replyText.match(new RegExp('#t' + '(.*)' + ' ' + config.lang_from));

dbhandler.add(userid[1], "closed")
bot.telegram.sendMessage(
chat.id,
'Ticket <code>#t'+userid[1]+'</code> closed',
cache.noSound
);
let replyText = ctx.update.message.text;
let userid = replyText.match(/(\d+)/);

if (userid[1] !== undefined) {
dbhandler.add(userid[1], "closed")
bot.telegram.sendMessage(
chat.id,
'Ticket #t'+userid[1]+' closed',
cache.noSound
);
} else {
bot.telegram.sendMessage(
chat.id,
'Unable to close ticket',
cache.noSound
);
};
}
});
}
Expand Down

0 comments on commit 0b58435

Please sign in to comment.