Build your MSN bot with DotMSN - PowerPoint PPT Presentation

1 / 13
About This Presentation
Title:

Build your MSN bot with DotMSN

Description:

msnbot: the web-crawling robot of MSN search (now Live search) ... tasks over the internet and is accessible with a MSN/Live messenger screen name. ... – PowerPoint PPT presentation

Number of Views:658
Avg rating:3.0/5.0
Slides: 14
Provided by: cha52
Category:
Tags: dotmsn | msn | bot | build | live | search

less

Transcript and Presenter's Notes

Title: Build your MSN bot with DotMSN


1
Build your MSN bot with DotMSN
  • SEG3510 Tutorial 5 (Feb 14)
  • 2007 Spring Semester
  • Prepared by Kelvin Chan (chansk_at_se.cuhk.edu.hk)

2
Contents
  • Preliminaries
  • DotMSN API
  • Case Study - A Simple automated MSN client
  • References

3
Preliminaries
  • MSN bot? Msnbot?
  • msnbot the web-crawling robot of MSN search (now
    Live search)
  • MSN bot (MSN chat bot/MSN chatterbot) refers to
    any application which runs automated tasks over
    the internet and is accessible with a MSN/Live
    messenger screen name.

4
Preliminaries
  • Examples of MSN bots (or bots in general)
  • HKTour Robot (the Tour Robot developed in HCCI)
    hktour.robot_at_gmail.com
  • Loads of bots out there
  • China Live bot competition http//contest.xiaoi.c
    om/index.html

5
DotMSN API
  • http//www.xihsolutions.net/dotmsn/
  • An open-source stand-alone class library to
    provide connectivity with the MSN Messenger
    service
  • Built in C and can therefore be used by all
    languages the .NET environment supports.
  • Easy to use and implement Flexible, robust and
    lightweight
  • Can be used for creating messaging robots to
    creating custom clients
  • (According to the project homepage)

6
DotMSN API
  • Download to old version DotMSN.dll(1.2)
  • Sample code in C is available
  • Tutor has translated the code to VB.NET, made
    some slight modifications and put onto the course
    webpage

7
Case Study A simple automated MSN client
  • Get dotmsn.dll
  • Remember how to link it to your project?

8
Case Study A simple automated MSN client
  • Event Handling
  • Define yourself how the program should response
    when something happens
  • Format
  • AddHandler Event, AddressOf HandlingFunction
  • Alternatively Private Sub FunctionName (args)
    Handles Event

9
Case Study A simple automated MSN client
  • Create a new instance of Messenger with the
    WithEvent modifier, make it a global variable
  • Public WithEvents messenger As New
    DotMSN.Messenger
  • Associate events with self-defined handlers,
    enclosed by Try Catch End Try
  • Try
  • AddHandler messenger.ContactOnline, AddressOf
    ContactOnline
  • AddHandler messenger.ConversationCreated,
    AddressOf ConversationCreated
  • AddHandler messenger.SynchronizationCompleted,
    AddressOf OnSynchronizationCompleted
  • Connect and Synchronize List
  • messenger.Connect(textUser.Text, textPass.Text)
  • messenger.SynchronizeList()
  • Catch Exception
  • Catch ex As MSNException
  • MessageBox.Show("Connecting failed "
    ex.ToString())
  • End Try

10
Case Study A simple automated MSN client
  • In the ConversationCreated Handler
  • Private Sub ConversationCreated(ByVal sender As
    messenger, ByVal e As ConversationEventArgs)
  • AddHandler e.Conversation.ContactJoin, AddressOf
    ContactJoined
  • AddHandler e.Conversation.ConnectionEstablished,
    AddressOf ConnectionEstablished
  • AddHandler e.Conversation.UserTyping, AddressOf
    ContactTyping
  • AddHandler e.Conversation.FileTransferHandler.Invi
    tationReceived, AddressOf FileTransferHandler_File
    TransferInvitation
  • AddHandler e.Conversation.MessageReceived,
    AddressOf MessageReceived
  • End Sub
  • For the detailed implementation of each handler,
    please refer to the sample program

11
Case Study A simple automated MSN client
  • Set Status to online
  • Messenger.SetStatus(MSNStatus.Online)
  • Status includes Away/BRB/Busy/Hidden/Idle/Lunch/O
    ffline/Online/Phone/Unknown
  • Receive Message
  • Add handler for ConversationEventArgs.Conversation
    .MessageReceived handler in the
    ConversationCreated handler

12
Case Study A simple automated MSN client
  • Send message
  • Conversation.SendMessage(s As String)
  • Send file
  • SendFile(v As Messenger.Conversation, c As
    Contact, filename As String)

13
References
  • Xiaoi(?I) Chinese bots portal
  • http//www.xiaoi.com/
  • DotMSN homepage
  • http//www.xihsolutions.net/dotmsn/
  • MSN Messegner Protocol
  • http//www.hypothetic.org/docs/msn/index.php
Write a Comment
User Comments (0)
About PowerShow.com