![]() [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin - Printable Version -Shoutbox (https://shoutbox.menthix.net) +-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58) +--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4) +---- Forum: Scripting (/forumdisplay.php?fid=39) +----- Thread: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin (/showthread.php?tid=70921) [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by markee on 01-22-2007 at 03:05 AM
The rest of this post has been kept for understanding the flow of the thread, the code in it has some flaws and is recommended not to be used, sorry. A note to script developers: Because of the StuffPlug Chat Only names feature you will have to use a different method when checking the origin of a received message. Instead of using: code: You should use the following code: code: I do realise this is a little more complex to do, but it will fix this problem that may be effecting your scripts. Thanks Cookie and deAd for informing me about my mistakes RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by deAd on 01-22-2007 at 03:26 AM
First of all, Messenger.MyUserId is not going to equal the origin unless someone has set their name to it code:This code ignores the first message that's been received after you send one, which is almost always yours because messenger places your sent message into the textbox immediately after you press Send or Enter. RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by CookieRevised on 01-22-2007 at 03:36 AM
- 'Origin' is not equal to a user id, it is the nickname RE: RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by deAd on 01-22-2007 at 03:42 AM
quote:I never said it was perfect ![]() ![]() RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by markee on 01-22-2007 at 03:45 AM
@ deAd: Your code has a chance of not working properly. There is a chance that a contact sends a message between these events being called and that will cause problems. RE: RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by deAd on 01-22-2007 at 04:11 AM
quote:This is highly, highly, highly unlikely. Right from the Plus! documentation: quote: The code I posted works in a similar way to what Plus! describes. However, instead of using a timer, it simply checks the next message. In this way, it is susceptible to the same extremely rare problem that Plus!'s detection has, but also accounts for messenger hanging for any reason and the message being delivered after more than just a second. The way you are doing it is more prone to error and confusion because somebody can set their name/chat-only name to yours. The chance of this is much, much higher than the chance of a message being received between the time the Send button was pressed and the sent message is added to the history box. RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by CookieRevised on 01-22-2007 at 04:14 AM
quote:not at all... it will fail in many occasions... quote:it is worse though... ---------------------------- Code which checks upon the registry for StuffPlug's ChatOnly name: code:- will fail if contact has same chat name as user. Code without checking (maybe version dependant) registry settings: code: RE: RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by deAd on 01-22-2007 at 04:17 AM
quote:It will fail in the same occasions as Plus! does -- when a message is received between the press of the Send button/enter key and when it is entered to the history box. It does do what the documentation describes, except without a timer. This just accounts for one other potential (and unlikely) problem. RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by CookieRevised on 01-22-2007 at 04:22 AM
quote:No... it will fail in much more occasions... quote:The timer is there for a reason! But even without the timer and the issue of 'pending' messages, your code will still fail in many more occasions than Plus! does. --- For both, please see the codes I posted... sorry to be so short, but I haven't the time atm RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by markee on 01-22-2007 at 04:48 AM
Cookie, I changed your code because I still could not find that registry on my computer and so I would imagine other people would have the same problem as I am having if this was used. code: RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by CookieRevised on 01-22-2007 at 05:00 AM
'DisabledFor' is only created when you disable/enable StuffPlug. Before that it indeed doesn't exist... This is fixed (in a shorter/elegant way) in my code. RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by bigbob85 on 12-14-2007 at 10:49 PM CookieRevised, what sort of instances would it fail? RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by CookieRevised on 12-14-2007 at 11:52 PM
RegRead can return other stuff than integers. It depends on the registry key type. So, if the user (for whatever reason) had manually changed the reg key type to a string (which is VERY common actually in scripts made by newbies), then the string "1" is not the same as the number 1 when you use identity operators (===). RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by bigbob85 on 12-15-2007 at 12:16 AM
Ah ok. Makes sense. RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by markee on 12-15-2007 at 05:16 AM
The === is the same in all languages to the best of my knowledge. And I believe you still have to specify how the variable is stored in the registry, however you can make a fix with stuff like a function to do it for you and using typeOf method with a switch statement (but this can wait for another thread RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by Deco on 12-16-2007 at 11:30 AM
Cookie, RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by CookieRevised on 12-16-2007 at 01:18 PM
quote:You should, but you don't need to. And that is exactly what many new scripters forget to do. When you don't do it and depending on how you've set up the variable or what method you use to write to the registry, it can revert back to the default REG_SZ, a string, not REG_DWORD, a number, for example. And that is exactly why I didn't use an identity (===) operator, but a equality (==) operator, because you don't know what _other_ scripts have done with that value... Bottom line: When reading something from the registry: always use a equality operator, or use a similar function to handle unexpected types. When writing to the registry: always define the correct type of the value, and don't trust upon 'default' settings. quote:how? quote:His code, unfortunatly, will fail in more situations and should not be used, even not together with other methods (discussed before). Not only will it fail when a message is recieved between you sending a message and Messenger putting your message in the chat window (which is rare, but it CAN happen; the busier you are chatting with different people at the same time, the more chance you have this will happen). But the chance of failing will be extremely bigger when you have more than one chat going on (which is far from rare), since he used just 1 global variable for checking every possible chat window. If you want to use a simply, easy method, use the second snipped I posted. As you will see it is basically the exact same thing as what deAd did, but it handles individual chats properly and thus will work with multipe chats. Though, it still would fail if a message is recieved between you sending a message and Messenger putting it in the chat. (note: the snippet is just that: a snippet outlining the method. You do need to add some more things like removing the array items when a chat is closed, etc to implement it properly). RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by markee on 12-16-2007 at 01:49 PM
quote:I meant in other code languages.... ![]() quote:I advise you not to do that, the message check of Cookie's is reliable, whereas deAd's and the name check method can fail. Well Cookie's can too, but only when you and the contact in the message send the exact same message, but their's is recieved between your sent message and recieving it back. But that is a far more extreme case (and deAd's method woul also fail in these circumstances, plus more). As or the name checking, that can easily be fooled (if you contact steals your name or you use stuff plug for example). And you cannot combine these in any way either so there is no point, otherwise you just get conflicting ideas.... RE: [Fix] Problem with OnEvent_ChatWndRecieveMessage's Origin by bigbob85 on 12-16-2007 at 10:28 PM
What if you check contact name? Will the on recieve msg show their chat only name or the same name from the main messenger window? quote: code: |