aMSN Forums
May 21, 2013, 10:26:30 pm *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: New forum for aMSN !!
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: integrating buttons/functions with chat windows ?  (Read 6034 times)
number-g
Newbie

Offline Offline

Posts: 17


View Profile
« on: May 14, 2009, 10:53:59 pm »

hi,

i have been working on a plugin for amsn; i managed to figure out how to set the configuration variables in account/select plugins/configure, but i would like to know how to change variables on a per-chatwindow basis, using radio buttons and a dropdown menu.

is this possible? i can't seem to find any documentation regarding this ...

cheers,

g
Logged
kakaroto
Administrator
Super Power User
*****
Offline Offline

Posts: 9428


View Profile WWW
« Reply #1 on: May 15, 2009, 06:59:09 pm »

Hi, you won't find any docs because there aren't any... When you set the config array you set a type (string, boolean, etc..) you would have to set a config as 'frame' and the value would be the name of a proc to be called to fill the frame.. look at how the pop3, music or gnotify plugin does it and copy the method used by these plugins...
Logged

KaKaRoTo
number-g
Newbie

Offline Offline

Posts: 17


View Profile
« Reply #2 on: May 15, 2009, 09:18:16 pm »

thanks for the swift response Smiley

i will look at the plugins you mentioned
Logged
number-g
Newbie

Offline Offline

Posts: 17


View Profile
« Reply #3 on: May 16, 2009, 08:09:26 pm »

hi,

i've managed to integrate a couple of comboboxes and a checkbox with the top of chat windows.

however, i need the checkbox to work on a per-chatid basis.

the buttons are added using the new_chatwindow event which doesn't give me any info about who the window was opened to ...

is there a function i can use to return the chatid of the person to whom i have opened the window? or some other way of achieving this?

thanks,

g
Logged
kakaroto
Administrator
Super Power User
*****
Offline Offline

Posts: 9428


View Profile WWW
« Reply #4 on: May 16, 2009, 09:59:32 pm »

wouldn't it be simpler to put a checkbox menu item in the chatwindow ? you could also listen to new_conversation  that would give you the chatid....
you can get the chatid from the window with [::ChatWindow::Name $window]...  You could also call [::ChatWindow::getAllChatIds] to get all the chatids and use [::ChatWindow::For $chatid] to get the window for each chatid...
I suggest you read the code, look into chatwindow.tcl, that file is well documented so ...
Logged

KaKaRoTo
number-g
Newbie

Offline Offline

Posts: 17


View Profile
« Reply #5 on: May 17, 2009, 12:26:47 am »

hi,

using [::ChatWindow::Name $window] is just returning 0 ... i guess because the conversation hasn't started at the time this is called.

i had a look at new_conversation, but i can't see a way of sending the chatid returned from that to my new_chatwindow proc ...

the checkbox is in the chatwindow ... not sure if that is what you meant so here is a screenshot:




Logged
kakaroto
Administrator
Super Power User
*****
Offline Offline

Posts: 9428


View Profile WWW
« Reply #6 on: May 17, 2009, 07:45:28 pm »

humm.. using new_conversation would replace new_chatwindow, you won't send the chatid from new_conversaton to the new_chatwindow proc... you replace it...
You could also listen to the user_joins_chat event (grep for PostEvent for the list of all events)... and in your config, you could have the list of all contacts instead...
Logged

KaKaRoTo
number-g
Newbie

Offline Offline

Posts: 17


View Profile
« Reply #7 on: May 18, 2009, 07:06:00 pm »

hi,

thanks for your help, it works now!

i used new_conversation and [::ChatWindow::For $chatid]

a couple of screenshots:


(showing original text)


(hiding original text)

i will upload it to my webspace and add a link on my original thread once i have commented the code and tidied up any loose ends...
Quote


i found something interesting when writing the part to translate incoming messages (using chat_msg_receive).

i am using chat_msg_send to read the msg, send it to google, and replace it with the translation (and some formatting). this adds a slight delay in the translated message appearing in the window.

i found that amsn interprets these delayed messages as having originated from the person with whom i am chatting, not myself. this caused the script to interpret my text as having came from the other person, and activated my chat_msg_receive script, which caused a double translation to appear on my window (though the outgoing text to their window was fine).

i had to create a $chatid.lastmsg element in the config array and use
Code:
if {$msg!=$::myscript::config($chatid.lastmsg)} {code}
to get around this.

anyway, thanks again for your help!

g
Logged
kakaroto
Administrator
Super Power User
*****
Offline Offline

Posts: 9428


View Profile WWW
« Reply #8 on: May 18, 2009, 11:22:32 pm »

Hi,
cool, the plugin looks awesome!
However, if you search the forum you'll realize that amsn isn't interpreting things the wrong way.. the chat_msg_receive event will always be sent for your sent and received messages.. the event basically means "a msg will be written to the chat", the normal way to check is to do :
if {$user != [::config::getKey login] }
look at other plugins to see how they do it.
Logged

KaKaRoTo
number-g
Newbie

Offline Offline

Posts: 17


View Profile
« Reply #9 on: May 19, 2009, 12:36:36 am »

hi,

i tried using
Code:

if {$chatid != [::config::getKey login] }  {mycode}


instead of the $chatid.lastmsg thing above ... it behaves the same as if i remove the clause altogether.

if i set up a plugins_log myplugin "$chatid - $message" to view what is actually happening, my messages are definitely interpreted as being sent by the other person!

or have i misunderstood something?
Logged
kakaroto
Administrator
Super Power User
*****
Offline Offline

Posts: 9428


View Profile WWW
« Reply #10 on: May 19, 2009, 01:58:33 am »

no, the $chatid will *always* be the email of the other contact (or "::MSN::SBXXX" in a multiuser chat).. do not use $chatid as if it was an email address, you can't be guaranteed of that... the $chatid is just an "id" for a chat, it shouldn't mean anything...
You should use the evpar to get the 'user' variable.. the $user var contains the email of the user who is writing that message (you, or the peer).. like I said, take example on other plugins...
Logged

KaKaRoTo
number-g
Newbie

Offline Offline

Posts: 17


View Profile
« Reply #11 on: May 19, 2009, 02:32:15 am »

oh!

thanks Smiley

i have now uploaded the plugin to my webspace (with my bodged workaround for the problem). check my edit above if you would like to try it.

i will change it later and reupload using your suggestion

thanks,

g
Logged
number-g
Newbie

Offline Offline

Posts: 17


View Profile
« Reply #12 on: May 19, 2009, 03:24:41 am »

done
Logged
number-g
Newbie

Offline Offline

Posts: 17


View Profile
« Reply #13 on: May 19, 2009, 10:07:21 pm »

hi again,

i don't know whether this should be a new thread or not but:

you may have noticed in using the plugin that the ui isn't drawn when the remote person starts the conversation; also (not as important), the text in the notification popups (i don't know the term you use for them) is in the original language if translate incoming is enabled.

little things like this would make 0.4 i guess

cheers,

g
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!