Click here to Skip to main content
15,895,423 members

Create and impliment Aiml Custom Tag

Member 8183957 asked:

Open original thread
I am trying to create and impliment a Custom Tag using the steps below.
I am having trouble with # 8.
Could someone show me how and where to create a method and call the LoadCustomTagHandlers(string pathToDLL)
Any help will be greatly appreciated

(1) Create a new library project to contain your Custom tag Classes.
(2) Add the AIMLbot dll as reference to your project.
(3) Create a public class with the same name as the tag you wish to handle.
(4) Reference System.Xml and AIMLbot.Utils.
(5) Add the [CustomTag] attribute to the class.
(6) Create a default Constructor that puts something in the “this.inputString” attribute.
(7) Override the ProcessChance() method.
(8) Finally to load the dll into your bot call the loadCustomTagHandlers(string pathToDLL) method of the AIMLbot.bot object that is your bot. An exception will be raised if you attempt to duplicate tag handling.

(This is the Custom Tag)
using system;
using system.Xml;
using Aimlbot.utils;

namespace SearchWebTags
{
[CustomTag]
public class searchWeb : AIMLTagHandler
{
public searchWeb()
{
this.inputString = "searchWeb";
}
protected override string ProcessChange()
{
if (this.templateNode.Name.ToLower() == "searchWeb")
{

{
string uri;
string searchString = this.Text1.Text;
uri = "http://www.google.com/search?q=" + searchString;
{
System.Diagnostics.Process.Start(uri);
}
}
return String.Empty;
}
}
}


(The code below is my App)

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.IO;

using AIMLbot;
using AIMLbot.AIMLTagHandlers;
using AIMLbot.Normalize;
using AIMLbot.Utils;

using System.Speech.Synthesis;
using SpeechLib;
using SearchWebTags;

namespace MyAimlBot1
{

public partial class MyAimlBot1: System.Windows.Forms.Form
{
SpeechLib.SpVoice say;

private cBot myBot;


public MyAimlBot1()
{
InitializeComponent();
pictureBox1.Image = Properties.Resources.Mth_0;
say = new SpeechLib.SpVoice();

myBot = new cBot(false);


this.textBox1.KeyPress += new KeyPressEventHandler(this.textBox1_KeyPress);
}


private void MyAimlBot1_Load(object sender, EventArgs e)
{

}


private void textBox1_KeyPress(object sender,
System.Windows.Forms.KeyPressEventArgs e)
{
say = new SpeechLib.SpVoice();

if (e.KeyChar == 13)
{
this.richTextBox1.Text=this.richTextBox1.Text;

cResponse reply = myBot.chat(this.textBox1.Text, "user");
this.richTextBox1.Text= reply.getOutput();

say.Speak(this.richTextBox1.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync);
say.Viseme += new
SpeechLib._ISpeechVoiceEvents_VisemeEventHandler(say_Viseme);
this.textBox1.Text = "";
}
}
Tags: C# (C# 2.0)

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900