Profile picture Schedule a Meeting
c a n d l a n d . n e t

Building an AIM Bot in .Net using boo

Dusty Candland | |

I’ve been working on a AIM Bot using the aimcc sdk. After signing up and downloading the sdk from developer.aim.com I found the documentation for .net lacking and found just getting up and running to be a long process. Below are some of the issues I ran into.

**Application.Run()

To start with I needed to create a class which extends Control. Then add a method to start the application, at the beginning of the method call CreateControl() at the end of the method you need to call Application.Run() to setup the message loop. I’m working in boo but this should work fine in c#.

class Bot(Control):
def Start():
CreateControl()
#AccSession setup to go here
Application.Run()

PInvoke

Next pinvoke is required to creat the AccSession instance. This is in some of the SDK samples, but it wasn’t obvious looking at the java and c++ sample bots. It only calls acccore.dll, but other dll’s in the accsdk/dist/release/ are needed I’m just using the full path, but should copy the required dll’s to my project file.


    [DllImport(“C:\accsdk\dist\release\acccore.dll”, EntryPoint:“#111”, PreserveSig:false, SetLastError:true)] 
    private static def AccCreateSession(
    [MarshalAs(UnmanagedType.LPStruct)] riid as Guid,
    [MarshalAs(UnmanagedType.IDispatch)] ref session as object) as IntPtr:
        pass

Calling the method is pretty strait forward, just pass in an object and then cast the object to a AccSession.


CreateControl()
o as object
AccCreateSession(typeof(IAccSession).GUID, o)
session = o as AccSession

Login

The next step was to wire up the events I wanted to get catch, I choose to wire up all the events for logging. You need to provide your API key and then login.


handler = AccSessionEventHandler(BoxesImResponder())
handler.WireSession(</em>session)
session.ClientInfo.Property[AccClientInfoProp.AccClientInfoProp_Description] = key
session.Identity = username
session.SignOn(password)
Application.Run()

That’s finally all I needed to get the bot running. I fought with setting preferences for a long while like the java example shows, but I ended up following the c++ example to filter which messages get accepted. More to follow in later posts. In addition, I plan on posting the full source code when the application is working.

Webmentions

These are webmentions via the IndieWeb and webmention.io. Mention this post from your site: