Python Plugin Wrapper
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md

README.md

Python Plugin Wrapper for AdiIRC

About:

This is a plugin wrapper for AdiIRC using IronPython and the new AdiIRC APIv2 to allow python scripting in AdiIRC.

Installation:

  • Download PyWrapper.zip
  • Unzip it to your config folder, usually C:\Users\username\AppData\Local\AdiIRC\Plugins
  • Go to Menubar -> File -> Plugins, select PyWrapper.dll, then click the Load button.

Using:

To create Python scripts, go to Menubar -> Tools -> Edit Plugin Scripts -> Python Wrapper.

APIv2 documentation can be found at https://adiirc.github.io/apiv2/generated/, all the python events uses the same names and parameters as in the docs,

Examples:

def OnLoad():
	# print a message when the script is loaded.
	pluginHost.ActiveIWindow.OutputText("Loaded script " + scriptFile)

	# add a hook for the command /testpy, notice it calls "plugin." instead of "pluginHost."
	plugin.HookCommand("/testpy")

	# add a hook for the command /testeval
	plugin.HookCommand("/testeval")

	# add a hook for the command /testcmd
	plugin.HookCommand("/testcmd")

	# add a hook for the command /listnicks
	plugin.HookCommand("/listnicks")    

def OnRegisteredCommand(e):
	parm = e.Command.split(" ")
	
	if parm[0] == "/testpy":
		 # if the typed command was /testpy, print a message.
        	    pluginHost.ActiveIWindow.OutputText("You typed /testpy " + " ".join(parm[1:]))

	elif parm[0] == "/testeval":
		# if the typed command was /testeval, try to evaluate "$me" 
		pluginHost.ActiveIWindow.OutputText("$me evaluates to " + pluginHost.ActiveIWindow.Evaluate("$me", ""))

	elif parm[0] == "/testcmd":
		# send a "/echo -ag Hello world" command to the active window.
		pluginHost.ActiveIWindow.ExecuteCommand("/echo -ag Hello World")

	elif parm[0] == "/listnicks":
		# if the typed command was /listnicks, print all nicks in the channel
		for value in pluginHost.ActiveIWindow.GetUsers:
			pluginHost.ActiveIWindow.OutputText(value.Nick)	
# set a global variable
joined = 0

def OnChannelJoin(e):
	# if this is my nick joining
	if e.User.Nick == e.Channel.Server.Nick:
			# update the global variable.
			global joined
			joined = joined + 1

			# print number of times joined a channel while the script was running.
			e.Channel.OutputText("I have joined a channel " + str(joined) + " times")
	else:
		# print a message to the server window.
		e.Channel.OutputText(e.User.Nick + " just joined " + e.Channel.Name)

	# don't do anything to the original message.
	return EatData.EatNone
def OnChannelPart(e):
	# eat/hide the part message.
	return EatData.EatText
import clr

clr.AddReference("System")
clr.AddReference("System.Windows.Forms")

from System import EventHandler
from System.Windows.Forms import ToolStripMenuItem

def OnMenu(e):
	if e.MenuType == MenuType.Channel:
		menuItem = ToolStripMenuItem("Example Menu Item")
		menuClickedHandler = EventHandler(MenuClicked)
		menuItem.Click += menuClickedHandler
		e.MenuItems.Add(menuItem)

def MenuClicked(source, args):
	pluginHost.ActiveIWindow.OutputText("Menu item clicked")