Cheddar

From Botdom Wiki

Jump to: navigation, search
Cheddar
Developer(s): plaguethenet
Programming language: C#
Minimum requirements: .NET Framework 2.0
Development state: Gold
Source model: Open Source
Last stable release: 1.2 (05/23/2008)
License type: GPL


Website


Cheddar is a bot written by plaguethenet in C#. The main goal of this bot is to run on GNU/Linux and and have a simple, yet powerful API.

Contents

Requirements

GNU/Linux

  • Mono 1.2.5.1 or later.

Windows

  • .NET Framework 2.0 or later

Features

  • Dynamic loading and unloading of plugins and their respective commands.
  • Runs on GNU/Linux (Mono) and windows (.NET framework 2.0).
  • XML Based configuration files.
  • Extremely fast and lightweight dAmn connection library.
  • Room and user properties tracking.
  • Simple API to develop plugins.
  • XML Plugin metadata.
  • Plugins may include their own references.
  • Plugins can be split across multiple files.
  • Extremely fast and lightweight event system.
  • Easy user setup.

Known Bugs

  • Cheddar fails to properly load plugins under mono 1.2.x, please update to 1.9.
  • Cheddar runs poorly (Very slowly) under mono 1.2.x, please update to 1.9.
  • Cheddar sees warnings as errors when compiling C# Plugins under mono, no known workaround is available other then to fix the source of the warnings.

Downloads

Change Log

1.2 Stable

  • Added a new profile command that allows multiple bot-profiles
  • This change breaks compatibility with existing bots, If you want to keep your existing settings, Please move the Config folder into Proifles\Default
  • Modified the plugin loading system to allow for assembly metadata in the cache files. A new XML Tag has been added to the .plugin file format as well, Check out plugins\system\system.plugin to see the change.
  • The new XML tag is NOT required and will default to true.
  • Fixed a small bug where plugins not written in C# had to have the <AutomaticAssemblyInfo> tag set to False or they would not compile.
  • Fixed a bug in 1.1 where if channels were specified to autojoin, the bot would fail to join any rooms at all.

1.1

  • Fixed several issues involving failures to handshake and get an authtoken
  • Modified the internal event system yet again to squeeze more speed out.
  • Added an embedded web server, Disabled by default.
  • Cheddar now GZip's old log files, and renames them to *.log.gz
  • Fixed some, but not all, issues with the console formatting.
  • Several plugins were using the console formatter to write directly to the console, Ignoring a hidden option to silence plugins. This has been fixed.
  • Added a new method of adding commands to plugins, Have not migrated current commands to the new method, But Overriding OnCommand should be considered depreciated and the function will be removed in future relases.
  • Added an LUA eval command (e). Working on implementing LUA as a module language.
  • Added a new module WSM, This module controls the web-server's behavior, Check it out if you want to add URL handlers for cheddar.

0.9rc3

  • Moved some of the bots internals to external files in the Modules directory.
  • Implemented several new API's to modify the way the bots core works.
  • Fixed several issues in the plugin loader, Plugins and modules should now compile much faster.
  • Implemented an asynchronous pattern in events, Resulting in less internal latency.

0.9rc2

  • Added an away module.
  • Fixed an issue where a disconnect would not be properly detected.

0.9rc1

  • Moved some code to a separate assembly, Anything wishing to use the Tree class must now reference StrangeSoft.Data.dll and import the namespace StrangeSoft.Data, The tree class remains mostly the same, Although binary incompatible, the api is still compatible.
  • Most of the changes were to aid in debugging. Bot is stable enough for day to day use.

Plugins

Sample Module

// Author:
//   Jason Couture, plaguethenet@gmail.com
//
// Copyright (c) 2007, Jason Couture
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
//    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
//    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
//    * Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Collections.Generic;
using System.Text;
using dAmned;
using XMLSettings;
using System.IO;
 
class SampleSimplePlugin : SimplePlugin
{
    //You must ALWAYS have this. Even if it does nothing.
    protected override void OnLoad()
    {
        //You are not required to change the event status because the bot can figure out on
        //its own which events you will need to use. It is however good programming pratice
        //to disable the ones you dont need.
 
        //Disable all events.
        UnsetEvent(Events.All);
        //Enable the message event, so that OnMessage() gets called.
        SetEvent(Events.Message);
        //This is where you would register your commands.
        //You use the HookCommand function for this.
        HookCommand("sample", privLevel.OWNER);
        //You can also use HookCommands which allows you to specify multiple
        //Commands with the same default priv.
        HookCommands(privLevel.OWNER, "sample1", "sample2");
    }
    //If you do not hook any commands, you do not need to override this function.
    protected override void OnCommand(string room, string cmd, string username, string param)
    {
        //Regardless of how many commands you actually have, ALWAYS implement
        //them inside a switch. This will allow you to add to it easily.
        //This is just a suggestion, not a requirement, but it will help you out in the long run.
        //
        //This function will only be called for commands you have registered in this module,
        //So if you have only one command, you can leave out the switch entirely, But i dont
        //Recommend it.
        switch (cmd)
        {
            case "sample":
                Say(room, "{0}: This is just the sample module.", username);
                //You ALWAYS need to supply a break, goto, or return
                //statement in C#. Its not legal to allow control to fall
                //Through to the next label (Like you can in C/C++)
                break;
            case "sample1":
                //Here is an example on how to use the goto statement.
                goto case "sample";
            case "sample2":
                FileInfo FI = new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location);
                Say(room, "{0}: Application Path: " + FI.FullName, username);
                break;
            default:
                //This should never happen unless you have a bug in your application.
                Say(room, "{0}: No definition for {1} in {2}. (BUG)", username, cmd, self.Name);
                //You need a break here too.
                break;
        }
    }
 
    protected override void OnMessage(string room, string from, string message, bool action)
    {
        //This function is called when someone says something in a room.
        //The message is RAW Tablump format. And you need to parse it down.
        //Thankfully this is easily acheived with the parse function.
        message = ParseTablumps(message);
        //You can now do whatever you want to do with message.
    }
}

API

Here is a list of methods you may override for different events on dAmn This list will expand, but will never get smaller. The only method that you HAVE to override is OnLoad(); The C# Syntax for overriding one of these methods is: protected override void On_____(params exactly as they appear below);

        void OnLoad();
	void OnLogin();
        void OnUserJoin(string room, string user, bool hidden);
        void OnUserPart(string room, string user, string reason, bool hidden);
        void OnKicked(string room, string who, string by, string reason);
        void OnPart(string room, string r);
        void OnJoin(string room, string r);
        void OnUserKicked(string room, string who, string by, string reason);
        void OnMessage(string room, string from, string message, bool action);
        void OnShutdown();

Plugin Metadata

<?xml version="1.0"?>
<root>
	<files>
		<!-- If you had more files you could include them here
			Just add another file entry on each line
			You can also reference directories
			using dirname/filename-->
		<file>SampleSimplePlugin.cs</file>
	</files>
	<references>
		<!-- These are files that all modules must include. -->
		<reference>dAmn.dll</reference>
		<reference>ScriptingSupport.dll</reference>
		<reference>dAmned.exe</reference>
		<reference>XMLSettings.dll</reference>
		<reference>Bot.Interfaces.dll</reference>
		<reference>PluginCore.dll</reference>
	</references>
	<!-- this can be CSharp, VB, Python, or boo (or 0, 1, 2 or 3 respectively)-->
        <!-- You can leave this tag out as well, if you do the language will default -->
        <!-- to C# -->
	<language>CSharp</language>
	<author>plaguethenet</author>
	<version>1.0</version>
	<about>This is a sample of a basic module. Feel free to use it as a skeleton</about>
	<extra>You can put whatever you want here.</extra>
	<name>Sample Plugin</name>
</root>
Personal tools