Konversation comes with some handy scripts you can run from the program. To run a script, in a channel, query, DCC, or server tab, type a command of the form
/exec
script
[parameters
]
which executes the script named
passing it (optional) script
.parameters
For example, type the following command in a channel tab
/sayversion
to send your Konversation, Qt™, KF5 and Plasma™ version numbers to the channel.
/exec cmd uname -a
executes the
script,
passing it cmd
. This sends your
Linux® version string to the channel.uname -a
To learn more about the scripts installed with Konversation please see the Script Reference Guide
To get a list of all available scripts, type the following command in a Konversation screen.
/exec --showpath media
Then browse to folder from the output to see the list.
You can write your own scripts. Scripts are shell scripts and can be written in any shell language, such as bash, perl, or python. When Konversation runs a script, the first two parameters sent to the script are:
The address of the server.
The channel name.
Here is a sample shell script (cmd).
#!/bin/sh # Executes a command and prints the output into Konversation. SERVER=$1; TARGET=$2; shift;shift; $@ | while read line; do qdbus org.kde.konversation /irc say $SERVER "$TARGET" "$@: $line"; done
Notice that the script uses qdbus to communicate with Konversation. The say
command causes
the output to be sent to the channel as a normal message. To display something
in the tab without sending it to other users, use info
instead. Look at the existing script files for more examples of writing scripts.
To be able to run a script you have written, you must install it by copying
it to $(qtpaths --paths GenericDataLocation)/konversation/scripts
. You must also give the file execute
privilege, for example
.chmod a+x myscript