Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restrict user #15

Closed
bitog opened this issue Apr 9, 2019 · 11 comments
Closed

restrict user #15

bitog opened this issue Apr 9, 2019 · 11 comments
Assignees
Labels

Comments

@bitog
Copy link

bitog commented Apr 9, 2019

Are we able to ban/restrict user?

@bostrot
Copy link
Owner

bostrot commented Apr 9, 2019

Something like this is not yet implemented in the public version. You can however restrict a user in the code itself by changing some lines:

Wrap everything from line 101 to 157:

ticket_handler.js (line 101):

var bannedUsers = [ // ticket numbers of users to be banned
                                '907093210', // banned user 1
                                '422589730', // banned user 2
                                '521741214' // banned user 3
                                 ];
if (
  JSON.stringify(bannedUsers).indexOf(ctx.from.id) > -1
) {
  cache.tickedID = ctx.message.from.id;

[ ... ] (keep everything from line 101 to 157 as it is and wrap it in the if-statement)

  console.log(
    'Ticket: ' +
    ' #' +
    cache.tickedID +
    userInfo.replace('\n\n', ': ') +
    ctx.message.text
  );
};

Where you can define the banned users with their ticket ids. Please report back how this works.

EDIT: updated the above example. Here is the full code if you need it: https://gist.github.com/bostrot/d48b8951d0cb0bcf808616feb03251cd

@bostrot bostrot self-assigned this Apr 9, 2019
@bostrot bostrot added the feature label Apr 9, 2019
@bitog
Copy link
Author

bitog commented Apr 10, 2019

Hi there,

Thanks for your reply.

I did update it and replaced it with my test accounts ID however the message keeps being forwarded. I just attached a snipped of my code https://imgur.com/vMYd0Eh.png.

I was also wondering, am I able to use markdown in startCommandText;faqCommandText;lang_contactMessage;lang_blockedSpam?

Thanks again for your help, much appreciated!

@bitog
Copy link
Author

bitog commented Apr 10, 2019

Oh! I just think we misunderstood each other. In terms of restricting I meant to restrict a user from being able to contact the support / communicate with the bot. So I can ban/restrict spammers lets say.

@bostrot
Copy link
Owner

bostrot commented Apr 10, 2019

My mistake, I sent you the wrong section where to implement it. Wrap everything from line 101 to 157 into the statement. See updated reply #15 (comment)

Also you currently cannot use markdown in those variables you mentioned. You can however use something like \n for line breaks e.g. I plan to include the markdown support in an upcoming version.

@bitog
Copy link
Author

bitog commented Apr 10, 2019

No worries, thanks for the update will try that out.

Alright, yes I was using \n already was just hoping to hide links behind text / make text bold. But thats is ok. Looking forward for the update ;)

I was also wondering - the user first name, username (or undefined) can simply be a tag/mention so that I am also able to click on the telegrams profile of a user which did not setup a username. That would prob help a lot.

Anyways, great working bot!

@bostrot
Copy link
Owner

bostrot commented Apr 11, 2019

The latest commit ef08eea adds the ability to use the /ban option (just like you use /close) to restrict users from not being able to write to your staff chat anymore. I also included the way to mention users as you proposed. So there is no username anymore, instead you can click on the users name and see the profile with its id.
Some more minor things are included too. Spam filter is down from 6 messages to 5 per [time you define in config]. Reply how it goes.

@bitog
Copy link
Author

bitog commented Apr 11, 2019

Ok wow! You implemented everything. Awesome man! Also love the new ticket number option #tID. Sleek! Love it!

I just tried the /ban command by reply. Also getting the User with ticket #t646148857 banned however my the user is still being able to use the support bot / messages are being forwarded...

I was also wondering is there a command like /unban?

Also, am I able to turn off webpage preview in the /faq command?

I also noticed that lang_contactMessage seems to pop up more frequently now, is that the case?

Thanks for your continuous help!

@bostrot
Copy link
Owner

bostrot commented Apr 12, 2019

Done e147f48.

Yes, initially I intended to use the Telegram hashtag system to find older tickets of that user. I didn't expect that a Telegram hashtag has to begin with a normal character and not a number though. Fixed that by putting t in front of it.

You can disable webpage preview by changing l. 192 from:

ctx.reply(config.faqCommandText, cache.html);

to

ctx.reply(config.faqCommandText, Extra.webPreview(false));

I couldn't verify the lang_contactMessage popping up more often than before. Should only popup first time a user writes a message and after the staff has replied to a message.

About the unban command. Thats a nice idea although I have no plans to implement it right now as you can unban a user by /close ing their ticket. I think that should be enough for now.

@bitog
Copy link
Author

bitog commented Apr 12, 2019

Awesome, it's all working now perfectly. Didnt know that the /close would unban a user. Thats totally fine, good to know.

Was prob something on my end then, as lang_contactMessage works just fine now.

I was wondering, how do I trigger the lang_acceptedBy message? I haven't seen that being used, yet.

@bostrot
Copy link
Owner

bostrot commented Apr 12, 2019

The lang_acceptedBy message is triggered by replying me to a ticket. This was useful back then when there was no staff chat and staff members wrote directly to the bot. Kind of redundant now.

@bostrot bostrot closed this as completed Apr 13, 2019
@bitog
Copy link
Author

bitog commented Apr 13, 2019

Alright, cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants