Code Monkey home page Code Monkey logo

irssi-tcl's Introduction

irssi-tcl is a module for the Irssi IRC client. It lets Irssi support scripting with Tcl.

Why? Irssi supports Perl scripting in its core. However I am a fan of the Tcl language, and I've written many IRC related scripts for the Eggdrop IRC bot. With some effort, you can even update Eggdrop scripts to run on Irssi.

It also solved a particular problem I had where I wanted to easily use non-blocking I/O, such as for HTTP requests. Tcl supports this pattern very easily through its event loop. This makes using Tcl through this module an easy way to talk to HTTP servers.

The module works by loading a Tcl interpreter into Irssi. You can use th /tcl command to interact with this interpreter. The module also supports loading scripts.

Available scripts

I've written a number of scripts using this module. You can find them in this repository.

Another is irssi-strava.

Requirements

To build the module you need:

  • Irssi and Irssi development files
    • Debian packages: irssi irssi-dev
  • glib2 and glib2 development files
    • Debian packages: libglib2.0-0 libglib2.0-dev
  • Tcl 8.5+ and Tcl 8.5+ development files (8.5 and 8.6 both work).
    • Debian packages: tcl8.5-dev tcl8.5
  • GNU Make (gmake)
    • Debian packages: build-essential (well this will get Make among other things)

It's possible it will work with older Tcl versions, but I haven't tested this.

Building

These commands must be run in the src directory.

Linux:

make

FreeBSD:

gmake -f Makefile.FreeBSD

Didn't work? If building fails, check the included (-I) directories listed in the Makefile actually exist. They may be at a different location on your system (such as in /usr/local/include and /usr/local/lib). You will need to alter them until they are all correct if they are not. Feel free to ask me for help.

Building with debug (which only really alters script/module paths right now):

make -e DEBUG=-DDEBUG

Installation

Linux:

make install

FreeBSD:

make -f Makefile.FreeBSD install

The install will place libtcl.so in ~/.irssi/modules and Tcl scripts into ~/.irssi/tcl.

Alternatively you can manually copy libtcl.so where you would like it. However, the module always looks in ~/.irssi/tcl for scripts.

Usage

To load the module in Irssi:

/load tcl

To autoload the module at startup of Irssi:

echo "load tcl" >> ~/.irssi/startup

The scripts that are loaded automatically are listed in ~/.irssi/tcl/scripts.conf.

Alternatively, a script in ~/.irssi/tcl/ can be loaded via

/tcl load_script name_of_script.tcl

Commands

Run a command in the Tcl interpreter:

/tcl <command ...>

Reload Tcl scripts:

/tcl reload

Examples

/tcl set a [expr 5+5]
13:53 -!- Tcl: Running /tcl: 'set a [expr 5+5]'
13:53 -!- Tcl: Result: 10

/tcl set a
13:53 -!- Tcl: Running /tcl: 'set a'
13:53 -!- Tcl: Result: 10

See the "tcl" section in Irssi's /set for individual Tcl script settings.

Scripting

See docs/scripting.md.

Using (edited) Eggdrop scripts

See docs/eggdrop_scripts.md.

irssi-tcl's People

Contributors

horgh avatar nugget avatar tbalboa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

irssi-tcl's Issues

implementation of an "abi check" in irssi 0.8.18

Hi, we added some compile-time constant to stop irssi from crashing with modules compiled into different irssi versions. To use it, please include

#ifdef IRSSI_ABI_VERSION
/*
 * Irssi abi check
 */
void
tcl_abicheck(int *version) {
    *version = IRSSI_ABI_VERSION;
}
#endif

next to your _init and _deinit functions. sorry for the inconvenience!

Compilation error due to generic signal functions

lots of these:

CC module.o
In file included from irssi/src/irc/core/irc.h:52,
                 from irssi_includes.h:20,
                 from module.c:9:
module.c: In function ‘init_commands’:
module.c:18:28: error: cast between incompatible function types from ‘void (*)(const char *, void *, WI_ITEM_REC *)’ {aka ‘void (*)(const char *, void *, struct _WI_ITEM_REC *)’} to ‘void (*)(const void *, const void *, const void *, const void *, const void *, const void *)’ [-Werror=cast-function-type]
  command_bind("tcl", NULL, (SIGNAL_FUNC) cmd_tcl);
                            ^
irssi/src/core/commands.h:73:97: note: in definition of macro ‘command_bind’
 #define command_bind(a, b, c) command_bind_full(MODULE_NAME, SIGNAL_PRIORITY_DEFAULT, a, -1, b, c, NULL)
                                                                                                 ^

due to the high warnings settings. Can be overwritten with -Wno-error=cast-function-type

Building on Debian Wheezy 64bit

Hi. Would you please tell me how to build your module on debian wheezy 64bit?
I use ActiveTcl from ActiveState.com.

I was able to edit the Makefile to build on ActiveTcl 8.6 , but it looks like , after running make, I get :
cc1: error: /usr/lib/i386-linux-gnu/glib-2.0/include: No such file or directory [-Werror]
cc1: all warnings being treated as errors
I don't really consider it a problem or a major issue.. It's just a matter of compilation and usage.
I can install the 32bit version of glib-2.0 . but that's redundant.
Thanks.

[feature] global loading

it would be nice if /usr/share/irssi/tcl/irssi.tcl could be loaded, when ~/.irssi/tcl/irssi.tcl does not exist. useful when you install the tcl module system wide

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.