Git Product home page Git Product logo

bostrot / telegram-support-bot Goto Github PK

View Code? Open in Web Editor NEW
394.0 18.0 147.0 1.09 MB

A Telegram ticketing/supporting system.

Home Page: https://botspace.bostrot.com

License: GNU General Public License v3.0

JavaScript 0.37% Dockerfile 0.31% TypeScript 93.81% HTML 5.51%
telegram-bot bot support-bot telegraf-framework ticket telegram-support-bot telegram staff-groups ticketing ticketing-system

telegram-support-bot's Introduction

Welcome to Telegram Support Bot πŸ‘‹

Bot API Version NPM Version node js-google-style Documentation

TSB is a support bot for telegram bots, using the grammY Framework. It lets users create tickets which will be send to a staff group and can be answered by a reply.

πŸš€ Hosted solution: Get it here at botspace!

✨ Features

When a user sends a message to the support chat it will create a ticket which will be forwarded to the staff group. Any admin in the staff group may answer that ticket by just replying to it. Salutation is added automatically. Photos will be forwared too.

  • File forwarding from and to user
  • Database for handling open and closed tickets
  • Restrict users
  • Simple anti spam system
  • Send tickets to different staff groups
  • Private reply to user
  • Anonymize users
  • Auto reply based on keywords [beta]
  • Web chat [beta]]

πŸ“œ Commands

Currently the support chat offers these commands (staff commands):

  • /open - lists all open tickets (messages where noone has replied yet)
  • /reopen - reopen a closed ticket
  • /close - close a ticket manually (in case someone writes 'thank you')
  • /ban - ban a person from writing to your chat

User commands:

  • /start - tells the user how to use this bot
  • /help - an overview over the commands or some explanation for the user
  • /faq - shows the FAQ
  • /id - returns your telegram id and the group chat id (1234567 -1234567890)

πŸ“¦ Install

See the wiki for more detailed instructions.

mv config/config-sample.yaml config.yaml
docker-compose up -d

πŸ“ Upgrading from older versions

There are some breaking changes in the new versions. Please read the following instructions carefully when updating.

click here to show

Since version v4 this bot uses the grammY Telegram Bot Framework instead of the telegraf framework for various reasons.

Upgrading to v4.0.0

Make sure you add the new settings strings to your config.yaml file. Check the config-sample.yaml for all configs. Here are some of the new settings that you should add when migrating:

parse_mode: 'Markdown' # DO NOT CHANGE!
autoreply: (see config-sample.yaml for an example)

The config-sample.yaml settings now all use markdown instead of HTML so you have to adjust that. e.g. instead of
line break use \n instead. For a full list check the telegram bot API docs.

Upgrade to the new version. e.g. by pulling the main branch from GitHub or using the docker image bostrot/telegram-support-bot:4.0.0.

Start it.

The old database should work with the new version without changing anything.

Upgrading to v3.0.0

The latest version uses a new config file in YAML format which would break old versions.

In order to make old versions work with the master you would need to use the new config.yaml file instead of the config.ts file from before. The easiest would be if you copy the config-sample.yaml to config.yaml (both in the config folder) and edit the settings similar to your old config.ts file. There is no need to delete the database file so old tickets can be kept open.

You might also want to check out the wiki for more info.

Author

πŸ‘€ Eric Trenkel

πŸ‘₯ Contributors

Contributors

🀝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ⭐️ if this project helped you!

πŸ“ License

Copyright Β© 2023 Eric Trenkel.
This project is GPL-3.0 licensed.


Not found what you were looking for? Check out the Wiki

If you need help or need a hosted solution of this check out Botspace for a one-click setup.

telegram-support-bot's People

Contributors

2naive avatar bostrot avatar dependabot[bot] avatar handymenny avatar in80 avatar jaydi85 avatar maslomeister avatar shape6253 avatar urboom avatar vlaabra avatar youaresofunny avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

telegram-support-bot's Issues

Sending back images in a reply is producing an error

Describe the bug
When replying to a ticket with an image/video/etc. an error occurs

To Reproduce
Steps to reproduce the behavior:

  1. Go in the staff chat
  2. Click on 'reply' and add an image or gif or video
  3. See error

Expected behavior
The user should receive the picture

Additional context
undefined
(node:11764) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'id' of undefined
at C:\Users\mb\Desktop\telegram-support-bot\src\ticket_handler.js:231:14
at Object.exports.check (C:\Users\mb\Desktop\telegram-support-bot\src\dbhandler.js:13:3)
at C:\Users\mb\Desktop\telegram-support-bot\src\ticket_handler.js:227:15
at C:\Users\mb\Desktop\telegram-support-bot\src\ticket_handler.js:293:11
at C:\Users\mb\Desktop\telegram-support-bot\src\ticket_handler.js:324:7
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:11764) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

Files are not sent to user

Describe the bug
Files are not sent to user

To Reproduce
Steps to reproduce the behavior:

  1. While replying to user from admin group send him a file as an attachment to your message
  2. In admin group it looks like file is sent
  3. User doesn't see your message with file attached

Expected behavior
User should receive a message with attachment

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Current version of bot script

several owners of the bot

it would be cool to make several owners of the bot, and then not always one person can answer, and so your bot is very cool and simple πŸ‘ŒπŸ˜Š

Ascending ticket ID

Describe the solution you'd like
Ticket ID should start with e.g. 1 and increase per opened ticket.

Additional context
Every ticket open-event increases the total ticket number by 1. If a ticket is not closed the number will stay the same.

Non-latin characters in config.js and response to a message with an attachment

Hello! Thank you for this project! I use it for our support chat and find very convenient. But still there are things I'd like to see improved. First, I can't use non-latin (cyrillic in my case) characters for greetings and etc. declared in config.js. In this case I get no response from the support chat. You've already been asked about this case but there is still no fix.

Secondly, when somebody sends a picture or a video along with the question the reply message to the attachment isn't returned to the bot. This fix would be very helpful.

Is message localization planned?

I can localize messages in Russian, but bot support is required.
The ability to localize will help to use the bot in different languages

Error: 403: Forbidden: bot was kicked from the supergroup chat

Describe the bug
Simliar to #65 unhandled rejections occur when the bot was kicked from a supergroup while trying to reply to a message.

Additional context

=== UNHANDLED REJECTION ===
'Thu Sep 16 2021 12:42:54 GMT+0200 (Central European Summer Time): Error: 403: Forbidden: bot was kicked from the supergroup chat\n' +
  '    at /home/bostrot/proj/telegram-support-bot/node_modules/telegraf/core/network/client.js:281:17\n' +
  '    at processTicksAndRejections (internal/process/task_queues.js:95:5)'

CanΒ΄t respond to tickets on raspbian lite

IΒ΄m running this on a rPi3b with a raspbian lite distro (openhabian), node v7.10.1 and npm v5.7.1 installed - had to update npm to the latest version and installed the needed mysql module.

I can run the support.js without problems and receiving user input as a ticket - via admin-chat and console output. Commands like /start and /faq are also working flawlessly - in the admin-chat as well as in the direct bot-communication.

If I reply (defined as the owner) to one of those tickets, there is no response from the bot - neither in the admin-chat nor to the user directly.

Also I canΒ΄t use the /open, /close or /root command. The bot stays silent.... any ideas?

Turn automatic tickets closing off

Unfortunately I can't understand from the code, how can I turn automatic tickets closing off. Is there a way to close tickets using "\close" command only?

Cant pull docker image

Hello!
I'm trying start bot by docker-compose but your image is private:

[root@node1 telegram-support-bot]# docker-compose up -d
Pulling supportbot (bostrot/telegram-support-bot:latest)...
ERROR: The image for the service you're trying to recreate has been removed. If you continue, volume data could be lost. Consider backing up your data before continuing.

Continue with the new image? [yN]y
Pulling supportbot (bostrot/telegram-support-bot:latest)...
ERROR: pull access denied for bostrot/telegram-support-bot, repository does not exist or may require 'docker login': denied: requested access to the resource is denied

Best regards, Sergey.

cannot find module extra

Hello Bostrot,

My host (Heroku.com) works with procfiles and package.json files. This means if i want to use your support bot (what i definitly want to use) i need to have the scripts, dependencies ect.

I now have:
https://github.com/Flintstone2020/telegram-support-bot/blob/master/bin/support.js
and this:
https://github.com/Flintstone2020/telegram-support-bot/blob/master/package.json

And that almost works.
I currently have the following output:

2017-12-18T21:01:49.186666+00:00 heroku[web.1]: State changed from crashed to starting
2017-12-18T21:01:51.344000+00:00 heroku[web.1]: Starting process with command `npm start`
2017-12-18T21:01:56.250763+00:00 app[web.1]: 
2017-12-18T21:01:56.250786+00:00 app[web.1]: > [email protected] start /app
2017-12-18T21:01:56.250787+00:00 app[web.1]: > node bin/support.js
2017-12-18T21:01:56.250787+00:00 app[web.1]: 
2017-12-18T21:01:56.595197+00:00 app[web.1]: module.js:557
2017-12-18T21:01:56.595220+00:00 app[web.1]:     throw err;
2017-12-18T21:01:56.595221+00:00 app[web.1]:     ^
2017-12-18T21:01:56.595222+00:00 app[web.1]: 
2017-12-18T21:01:56.595223+00:00 app[web.1]: Error: Cannot find module 'extra'
2017-12-18T21:01:56.595224+00:00 app[web.1]:     at Function.Module._resolveFilename (module.js:555:15)
2017-12-18T21:01:56.595224+00:00 app[web.1]:     at Function.Module._load (module.js:482:25)
2017-12-18T21:01:56.595225+00:00 app[web.1]:     at Module.require (module.js:604:17)
2017-12-18T21:01:56.595226+00:00 app[web.1]:     at require (internal/module.js:11:18)
2017-12-18T21:01:56.595226+00:00 app[web.1]:     at Object.<anonymous> (/app/bin/support.js:30:15)
2017-12-18T21:01:56.595227+00:00 app[web.1]:     at Module._compile (module.js:660:30)
2017-12-18T21:01:56.595227+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:671:10)
2017-12-18T21:01:56.595228+00:00 app[web.1]:     at Module.load (module.js:573:32)
2017-12-18T21:01:56.595229+00:00 app[web.1]:     at tryModuleLoad (module.js:513:12)
2017-12-18T21:01:56.595229+00:00 app[web.1]:     at Function.Module._load (module.js:505:3)
2017-12-18T21:01:56.603586+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2017-12-18T21:01:56.603911+00:00 app[web.1]: npm ERR! errno 1
2017-12-18T21:01:56.604980+00:00 app[web.1]: npm ERR! [email protected] start: `node bin/support.js`
2017-12-18T21:01:56.605102+00:00 app[web.1]: npm ERR! Exit status 1
2017-12-18T21:01:56.605256+00:00 app[web.1]: npm ERR! 
2017-12-18T21:01:56.605393+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script.
2017-12-18T21:01:56.605482+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2017-12-18T21:01:56.611406+00:00 app[web.1]: 
2017-12-18T21:01:56.611611+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2017-12-18T21:01:56.611698+00:00 app[web.1]: npm ERR!     /app/.npm/_logs/2017-12-18T21_01_56_606Z-debug.log
2017-12-18T21:01:56.704770+00:00 heroku[web.1]: Process exited with status 1
2017-12-18T21:01:56.716577+00:00 heroku[web.1]: State changed from starting to crashed

Can you help me solve this problem?

Kind regards,
Ruben

Video Support

Can you add Video Support? like forwarding ( or downloading and sending ) the video from the supportee to staff chat.
I think this would be helpful.

Source folder mistake in package.json

When run "npm run prod" I get an error:
cp: cannot stat './src/web': No such file or directory

I saw that "web" folder exists in the "addons" folder, so we need to change source from "cp -r ./src/web ./build/src/web" to "cp -r ./src/addons/web ./build/src/addons/web"

TypeError: Cannot open database because the directory does not exist at new Database

Describe the bug
Support.db cannot be found when starting support.js from root directory

/root/telegram-support-bot/node_modules/better-sqlite3/lib/database.js:31
throw new TypeError('Cannot open database because the directory does not exist');
^

TypeError: Cannot open database because the directory does not exist
at new Database (/root/telegram-support-bot/node_modules/better-sqlite3/lib/ database.js:31:9)
at Object. (/root/telegram-support-bot/bin/dbhandler.js:2:12)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (/root/telegram-support-bot/bin/ticket_handler.js:3:17 )

To Reproduce
Steps to reproduce the behavior:
At root directory start support.js, e.g. "node /root/telegram-support-bot/bin/support.js"

Expected behavior
support.db should not only be accessible from inside /telegram-support-bot/
/bin/dbhandler.js may needs changes in regards to db path

Desktop (please complete the following information):
CentOS 7

Tickets don't close properly sometimes

Describe the bug
Some tickets don't close properly when they include the whole tickets text instead of the ID only.
They are shown as closed in the DB, but the /open command shows them as open tickets.

To Reproduce
This only happens happens to some tickets, can't figure out what is causing the whole ticket text to end up in the DB instead of the ticket ID only.

Expected behavior
Avoid whole ticket text to be put into DB.

Error: 403: Forbidden: bot was blocked by the user

I encountered the following errors

  • The bot only works with nodejs v10. 24. 1 (npm v6. 14. 12)

  • If the user deletes the bot and checks "stop bot", the bot crashes with errors:

    Error:
    Failed to process updates. Error: Telegraf: "reply" isn't available for "undefined::"
        at TelegrafContext.assert (/root/telegram-support-bot/node_modules/telegraf/context.js:172:13)
        at TelegrafContext.reply (/root/telegram-support-bot/node_modules/telegraf/context.js:314:10)
        at Telegraf.bot.catch [as handleError] (/root/telegram-support-bot/src/index.ts:94:7)
        at middleware.catch (/root/telegram-support-bot/node_modules/telegraf/telegraf.js:171:55)
        at process._tickCallback (internal/process/next_tick.js:68:7)
    

Make ticket IDs clickable under "Open Tickets:"

Is your feature request related to a problem? Please describe.
Ticket IDs are not clickable when shown by /open command, but they are in the actual request message (tg://search_hashtag?hashtag=).

Describe the solution you'd like
Make ticket IDs clickable under "Open Tickets:"

Bad Request: can't parse entities

I'm sorry that I'm providing information out of form. In addition, I am still using the version from 11 Jul.

  1. It seems that the problem is an unclosed tag in the name

Fri Sep 03 2021 19:17:25 GMT+0000 (Coordinated Universal Time): consultation #T000386 для <a href=""><3</a> : ru

A message has been received from the user, but it is impossible to respond to it

An error occured, please report this to your admin: Error: 400: Bad Request: can't parse entities: Unsupported start tag "3</a" at byte offset 52

  1. The message from the user did not reach the chat, but I see it in the log. I think that the problem is in the long dash in the name
Sat Sep 04 2021 21:12:05 GMT+0000 (Coordinated Universal Time): SqliteError: near "for": syntax error
    at Object.getOpen (/telegram-support-bot/src/db.ts:23:23)
    at Object.chat (/telegram-support-bot/src/staff.ts:91:8)
    at ticketHandler (/telegram-support-bot/src/text.ts:47:11)
    at Object.handleText (/telegram-support-bot/src/text.ts:28:5)
    at /telegram-support-bot/src/index.ts:89:33
    at /telegram-support-bot/node_modules/telegraf/composer.js:143:56
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    An error occured, please 
          report this to your admin:
SqliteError: near "for": syntax error

Issues with latest comnit

I just tried out the lastest commit and I found a couple of issues with it.

The first problem is that I am unable to respond to tickets with a picture attached to them. There was no error an in the console about this.

The second is that when someone sends a video it says in the this in the console:

UnhandledPromiseRejectionWarning:
TypeError: Cannot read property '0' of undefined
at /mnt/Telegram Bots/TestTelegramSupportBot/bin/ticket_handler.js:164:66
at /mnt/Telegram Bots/TestTelegramSupportBot/bin/ticket_handler.js:198:7
at /mnt/Telegram Bots/TestTelegramSupportBot/bin/ticket_handler.js:232:7
at
at process._tickCallback (internal/process/next_tick.js:188:7)
(node:13333) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().

comments

All answers to this post will be shown on my website. More infos soon.

Webhook mode

Is it possible to run this bot in a Webhook mode?

Error after reply to group member

When I reply to another group member in staff_group I got an error:

An error occured, please report this to your admin:
TypeError: Cannot read property '1' of null

Does it affect something and can it be fixed somehow?

Root command bugged

Hi Bostrot,

I'm hosting the 'normal' version of your bot on my ubuntu vm but when I use /root (I entered all the values) the bot spams "Restarted bot. See log." (but I can't find a log anywhere).

Kind regards,
Ruben

/faq no webPreview

Hello again,

I was wondering if I can turn off webpage preview in /faq? A while ago you mentioned to replace cache.html with Extra.webPreview(false) however after the update that is breaking markdown. Is there any other way to archive that?

I tried to add:
cache.webPreview = Extra.webPreview(false); in support.js and:
webPreview: '', in cache.js however that does nothing lol

Thanks for your help!

If bot is blocked by user infinite app crash and flood happens

Describe the bug
Bad error and reptry handling.

greensms_bot    | Failed to process updates. Error: Telegraf: "reply" isn't available for "undefined::"
greensms_bot    |     at TelegrafContext.assert (/bot/node_modules/telegraf/context.js:172:13)
greensms_bot    |     at TelegrafContext.reply (/bot/node_modules/telegraf/context.js:314:10)
greensms_bot    |     at Telegraf.handleError (/bot/build/src/index.js:81:60)
greensms_bot    |     at /bot/node_modules/telegraf/telegraf.js:171:55
greensms_bot    |     at processTicksAndRejections (node:internal/process/task_queues:94:5)
greensms_bot    |     at async Promise.all (index 0)
greensms_bot exited with code 0

To Reproduce
Steps to reproduce the behavior:

  1. Start new question as user
  2. Click on Delete and leave
  3. Answer on question in Support group
  4. You will see endless "Message sent to user" attempts.
  5. If you click Start as user again you will get endless messages too
    ! No messages from Telegrams getUpdates queue will be flushed, so they will be received again and again.

Expected behavior

  1. Error on reply
  2. No flood
  3. getUpdates flushes
  4. Correct error handling

Screenshots

image
image

Cannot read property 'length' of undefined

Thank you very much for all the new updates! There are small errors.

  1. When the user clicks "Start" and receives the contents of "start Command Text" of any content and language, an error arrives to the admin:
An error occured, please report this to your admin:
TypeError: Cannot read property 'length' of undefined

Messages are not sent to the chat

I ran into a problem again. The app is running in dev mode. After some long time of work, I see a message from the user in the console, but there is no message in the chat. There are no error messages. Restarting the app - new messages are sent to the chat again. So far, there are no ideas on how to quickly reproduce the problem.

Messages not being sent after bot restart

Describe the bug
Messages are not being sent after the bot has restarted. Another reply fixes it.

To Reproduce
Steps to reproduce the behavior:

  1. Message bot
  2. Reply in staff chat
  3. Restart bot
  4. Reply in staff chat

Expected behavior
The message should be relayed to the user and there should be a message sent notification.

Unit Tests / Integration Tests

We need testing to check for breaking changes.

Here is some stuff that has to be tested to close this issue:

  • Start command
  • Other static commands (faq, ...)
  • Message to user
  • Message from user
  • Image from user
  • File from user
  • Video from user
  • Image from staff
  • File from staff
  • Video from staff
  • Video/File/Image from staff with text (caption)
  • Video/File/Image from user with text (caption)
  • Dynamic commands (open, close, ...)
  • No error in staff chat on start/stop/block/group block
  • add more here...

Getting compilation error when trying use categories

When I try to use categories I got a compilation error. After removing the lines:
/* <==== Remove this line if you want categories ====> */
I see these errors in the log:

4|TEST_TELEGRAM_FEEDBACK_BOT  | Compilation error in /opt/test/telegram-support-bot/config/config.ts
4|TEST_TELEGRAM_FEEDBACK_BOT  | [ERROR] 07:10:10 β¨― Unable to compile TypeScript:
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(48,3): error TS1117: An object literal cannot have multiple properties with the same name in strict mode.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,14): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,27): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,14): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,38): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,14): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,53): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,14): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(71,14): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,14): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(71,24): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,14): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(71,30): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,14): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(71,54): error TS2451: Cannot redeclare block-scoped variable '(Missing)'.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(66,7): error TS1005: ',' expected.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,15): error TS1003: Identifier expected.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,27): error TS1005: ':' expected.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(68,39): error TS1003: Identifier expected.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(69,7): error TS1005: ':' expected.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(71,15): error TS1003: Identifier expected.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(71,24): error TS1005: ':' expected.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(71,31): error TS1003: Identifier expected.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(72,7): error TS1005: ':' expected.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(73,5): error TS1128: Declaration or statement expected.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(73,6): error TS1128: Declaration or statement expected.
4|TEST_TELEGRAM_FEEDBACK_BOT  | config/config.ts(74,1): error TS1128: Declaration or statement expected.

Errors when executing "npm run prod"

Describe the bug
After executing "npm run prod" the process fails with the errors shown in the screenshot.

To Reproduce
git clone https://github.com/bostrot/telegram-support-bot.git
cd telegram-support-bot
npm i
mv config/config-sample.yaml config.yaml
I configure the file config.yaml, and,
npm run prod

Expected behavior
The process ran without any errors.

Screenshots
image

Additional context
Debian GNU/Linux 10 (buster)

newbie question - Cannot access /root interface

Hi,
And thank you for shraring this project,

When sending /root as admin, the bot / service is entering into some loop and keep sending me message in telegram:

Restarted bot. See log
Restarted bot. See log
Restarted bot. See log
Restarted bot. See log

While i can see this errors in the logs:

(node:30598) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: 400: Bad Request: there is no document in the request
node[30598]: (node:30598) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): Error: 400: Bad Request: there is no document in the request

node[30598]: (node:30598) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3): Error: 400: Bad Request: there is no document in the request

node[30598]: (node:30598) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): Error: 400: Bad Request: there is no document in the request

I feel like i miss something with /logs/ folder when installing or maybe this is a permission issue, (running on ubuntu) ,
I can't see this folder but i can see in my bin/support.js file that it sholud be exists.
We be glad for support,

Thank you.

Ubuntu 16.04.3 LTS
node --version v6.14.0
npm -v 3.10.10

which node /usr/bin/node
which npm /usr/bin/npm

Messages are lost on Exception

Describe the bug
If any error happens on sending message from/to user -> message just got lost and moderator/users receives reply that everything is fine https://github.com/bostrot/telegram-support-bot/blob/master/src/text.ts#L19

To Reproduce
Steps to reproduce the behavior:

  1. Send < to bot
  2. You will get Thank you for contacting us. We will answer as soon as possible.
  3. No message would be sent to support group due to error
  4. Send 1 to bot
  5. Reply to 1 with < from support group
  6. You will get Message sent to user Alexander but no message would be sent due to error

Expected behavior

  1. If ANY error happens -> catch it, reply with "Error happend" to sender, notify support group about an error.
  2. Special chars should be escaped
greensms_bot    | === UNHANDLED REJECTION ===
greensms_bot    | "Fri Apr 23 2021 00:31:56 GMT+0000 (Coordinated Universal Time): Error: 400: Bad Request: can't parse entities: Unclosed start tag at byte offset 60\n" +
greensms_bot    |   '    at /bot/node_modules/telegraf/core/network/client.js:281:17\n' +
greensms_bot    |   '    at processTicksAndRejections (node:internal/process/task_queues:94:5)'

Support tickets do not open again when new messages from the same ID arrive

Is your feature request related to a problem? Please describe.
It seems that once a ticket has been closed (after replying) it does not open again, when new messages arrive from the same ID.

Describe the solution you'd like
Either reopen closed tickets when new messages arrive from the same ID or keep them open until closed manually by a support agent.

Moving to Typescript

Non-breaking

  • Move .js files to src/, tsc, add { "exports": { "./": "./lib/" } } to package.json.
  • Change extension to .ts and add type annotations from .d.ts files.
  • index.ts
  • error.ts
  • db.ts
  • commands.ts
  • files.ts
  • cache.ts
  • inline.ts
  • permissions.ts
  • staff.ts
  • text.ts
  • users.ts
  • Configure formatting/linting of .ts files.
  • Update examples
  • Update Readme

Breaking

  • Forwarding images

Public version of the bot

Is your feature request related to a problem? Please describe.
An easy way to spin up a support bot instance could be to allow people without hosting to spin up their own instance on a public server.

Describe the solution you'd like
This could either work by spinning up a new instance every time a user "creates" a new bot (this would need #51) or let it create an extra configuration in the database to keep apart different bots (e.g. new table for every different instance)

Additional context

  1. If I want to run multiple versions of the bot I would have to spin up multiple instances which might not be as efficient as with just one.
  2. Getting a hosting solution just for a telegram bot seems a little overkill. Of course there are solutions like Heroku but they are not very cheap either.

autoreply on keywords

our clients send us many duplicated questions, for example, they want to hire us for a custom job, would be perfect if the bot automatically replies to these messages using a template.

for example:
client: Hello, are you available for a custom development?
bot: Sorry, but we not doing custom development. Only fixing bugs and helps with problems. Thanks

Daily status report

Is your feature request related to a problem? Please describe.
It is hard to tell whether the bot is running or not. It may stop unnoticed, e.g. when the server stops.

Describe the solution you'd like
Daily ticket reporting. Get a daily summary for opened, unanswered and closed tickets.

Bad Request: group chat was upgraded to a supergroup chat

installed with node.js and npm i, set config, and then ran for the first time. added bot to group and then messaged it... i get this error and nothing goes into the group. it said "supergroup id" in the config.. and with telegram's recent updatings, all groups are supergroups. so what do i do?

Ticket:  #t147394605 from Miss Moth Language: de: sdfsdf
(node:13964) UnhandledPromiseRejectionWarning: Error: 400: Bad Request: group chat was upgraded to a supergroup chat
    at buildConfig.then.then.then.then (/var/lib/pufferd/servers/f7ced3dd-1038-4cc4-b1dc-f83ebf60814c/node_modules/telegraf/core/network/client.js:263:17)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:13964) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:13964) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

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.