import QtQml 2.0
import Communi 3.0
QtObject {
id: bot
property string channel: "#communi"
property Irc irc: Irc { id: irc }
id: model
id: connection
host: "irc.freenode.net"
userName: "communi"
nickName: "QmlBot" + Math.round(Math.random() * 9999)
realName: qsTr("Communi %1 QML bot example").arg(irc.version())
Component.onCompleted: {
sendCommand(command.createJoin(channel))
open()
}
onMessageReceived: {
parser.target = message.private ? message.
nick : message.target
var command = parser.parse(message.content)
if (command) {
sendCommand(command)
close()
Qt.quit()
}
}
}
}
}
}
id: parser
triggers: connection.network.isChannel(target) ? ["!", connection.nickName + ":"] : ["!", ""]
Component.onCompleted: {
parser.addCommand(
IrcCommand.
Part,
"PART (<#channel>) (<message...>)");
}
}
}