justdmitry / NetTelegramBotApi

C# client library for building Telegram bot
MIT License
74 stars 28 forks source link

Related to issue #71 #73

Closed newRedCrown closed 3 years ago

newRedCrown commented 6 years ago

Hi in continue of Issue #71 I have this problem with conditions and its really bothering... I search whole github for using these in "if" and I found nothing useful.. how should I put this into if or else? I mean check if id is one of the channel member ==> do this else ==> do something else Can you guys help me with that? plz.. tnx

justdmitry commented 6 years ago

It's unclear what you are asking for

newRedCrown commented 6 years ago

I mean look this:

string channel = "@channelname";
long id = item.Message.Chat.Id;
GetChatMember checkUser = new GetChatMember(channel, id);
var chatMember = await mybot.SendAsync(checkUser);
                    //Until Here, There is no problem..

Now I wanne put these into if and else and won't work?? :

 if (checkUser != null && chatMember != null){
await Bot.SendTextMessageAsync(r.Message.Chat.Id, "hi member"); }
else {
await Bot.SendTextMessageAsync(r.Message.Chat.Id, "not member! join @Channel");}

I have 2 problems.. 1- Everytime in reply to /proxy It is giving me one answer.. 2- I cannot use "SendAsync" in chatMember varriable.. hlp...hlp.. plz

justdmitry commented 6 years ago

1- Everytime in reply to /proxy It is giving me one answer..

Hmm. Why you think answers must be different? And what about other message texts?

2- I cannot use "SendAsync" in chatMember varriable..

Don't understands. Seems like compilation error...

newRedCrown commented 6 years ago

I don't know how put all these together.. I mean I want to compile that part if (chatmember == checkuser.UserId){ //do something and text somthing } else { //do something diffrent that if-part does and text somthing diffrent.. } get user from @channel and check if user exists => message this.. else message something else... and I can't compile it whatever I write.. and thats why I wanna text be diffrent.

justdmitry commented 6 years ago

You need read GetChatMember docs and understand what return value(s) are "true" and "false" for your task. I'm not sure that comparing return value to null is enough