mirror of
https://github.com/vishapoberon/vipak.git
synced 2026-04-05 20:42:26 +00:00
sending message type to the callback procedures as well.
commented out simple callback, looks like it's redundant.
This commit is contained in:
parent
d94bf140dc
commit
898bab4509
2 changed files with 17 additions and 14 deletions
16
IRC.Mod
16
IRC.Mod
|
|
@ -29,17 +29,17 @@ CONST
|
||||||
chn* = ARRAY 32 OF CHAR;
|
chn* = ARRAY 32 OF CHAR;
|
||||||
chnlist* = POINTER TO ARRAY OF chn;
|
chnlist* = POINTER TO ARRAY OF chn;
|
||||||
msg* = ARRAY msgLen OF CHAR;
|
msg* = ARRAY msgLen OF CHAR;
|
||||||
cbMessage* = PROCEDURE(VAR msg : ARRAY OF CHAR); (* cb stands for callback *)
|
(*cbMessage* = PROCEDURE(VAR msg : ARRAY OF CHAR);*) (* cb stands for callback *)
|
||||||
cbPrivateMessage* = PROCEDURE (VAR msg, user, ident, host: ARRAY OF CHAR);
|
cbPrivateMessage* = PROCEDURE (VAR msg, msgtype, user, ident, host: ARRAY OF CHAR);
|
||||||
cbPublicMessage* = PROCEDURE (VAR msg, user, ident, rcpt, host: ARRAY OF CHAR);
|
cbPublicMessage* = PROCEDURE (VAR msg, msgtype, user, ident, rcpt, host: ARRAY OF CHAR);
|
||||||
cbPublicMessageWithMention* = PROCEDURE(VAR msg, user, ident, rcpt, host: ARRAY OF CHAR); (* rcpt is usually the room in case of public messages *)
|
cbPublicMessageWithMention* = PROCEDURE(VAR msg, msgtype, user, ident, rcpt, host: ARRAY OF CHAR); (* rcpt is usually the room in case of public messages *)
|
||||||
|
|
||||||
|
|
||||||
instance* = RECORD
|
instance* = RECORD
|
||||||
owner*, user*, nick*, host*, port*: chn;
|
owner*, user*, nick*, host*, port*: chn;
|
||||||
connection*: Internet.Socket;
|
connection*: Internet.Socket;
|
||||||
channelList*: chnlist;
|
channelList*: chnlist;
|
||||||
callbackSimple*: cbMessage;
|
(*callbackSimple*: cbMessage;*)
|
||||||
callbackPrivate*: cbPrivateMessage;
|
callbackPrivate*: cbPrivateMessage;
|
||||||
callbackPublic*: cbPublicMessage;
|
callbackPublic*: cbPublicMessage;
|
||||||
callbackPublicMention*: cbPublicMessageWithMention;
|
callbackPublicMention*: cbPublicMessageWithMention;
|
||||||
|
|
@ -398,14 +398,14 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
|
|
||||||
IF rcpt = inst.nick THEN (* private message *)
|
IF rcpt = inst.nick THEN (* private message *)
|
||||||
inst.callbackPrivate(message, username, identname, host);
|
inst.callbackPrivate(message, messagetype, username, identname, host);
|
||||||
ELSE
|
ELSE
|
||||||
mn := isMention(inst.nick, message);
|
mn := isMention(inst.nick, message);
|
||||||
IF mn THEN
|
IF mn THEN
|
||||||
cutMentionFromMessage(inst.nick, message);
|
cutMentionFromMessage(inst.nick, message);
|
||||||
inst.callbackPublicMention(message, username, identname, rcpt, host);
|
inst.callbackPublicMention(message, messagetype, username, identname, rcpt, host);
|
||||||
ELSE
|
ELSE
|
||||||
inst.callbackPublic(message, username, identname, rcpt, host);
|
inst.callbackPublic(message, messagetype, username, identname, rcpt, host);
|
||||||
END;
|
END;
|
||||||
END;
|
END;
|
||||||
END parse;
|
END parse;
|
||||||
|
|
|
||||||
15
test.Mod
15
test.Mod
|
|
@ -2,7 +2,7 @@ MODULE test; (* noch 13.4.2017 / 18.5.2017*)
|
||||||
|
|
||||||
IMPORT IRC, Out, Strings := ooc2Strings;
|
IMPORT IRC, Out, Strings := ooc2Strings;
|
||||||
|
|
||||||
|
(*
|
||||||
PROCEDURE onMessage(VAR msg : ARRAY OF CHAR);
|
PROCEDURE onMessage(VAR msg : ARRAY OF CHAR);
|
||||||
BEGIN
|
BEGIN
|
||||||
Out.String("callback procedure is running, youhoo!"); Out.Ln;
|
Out.String("callback procedure is running, youhoo!"); Out.Ln;
|
||||||
|
|
@ -10,21 +10,23 @@ BEGIN
|
||||||
Out.String(msg); Out.String("|"); Out.Ln;
|
Out.String(msg); Out.String("|"); Out.Ln;
|
||||||
Out.Ln;
|
Out.Ln;
|
||||||
END onMessage;
|
END onMessage;
|
||||||
|
*)
|
||||||
PROCEDURE onPrivateMessage(VAR msg, user, ident, host: ARRAY OF CHAR);
|
PROCEDURE onPrivateMessage(VAR msg, msgtype, user, ident, host: ARRAY OF CHAR);
|
||||||
BEGIN
|
BEGIN
|
||||||
Out.String("*** private message ***"); Out.Ln;
|
Out.String("*** private message ***"); Out.Ln;
|
||||||
Out.String("message: '"); Out.String(msg); Out.Char("'"); Out.Ln;
|
Out.String("message: '"); Out.String(msg); Out.Char("'"); Out.Ln;
|
||||||
|
Out.String("message type: '"); Out.String(msgtype); Out.Char("'"); Out.Ln;
|
||||||
Out.String("user: '"); Out.String(user); Out.Char("'"); Out.Ln;
|
Out.String("user: '"); Out.String(user); Out.Char("'"); Out.Ln;
|
||||||
Out.String("ident: '"); Out.String(ident); Out.Char("'"); Out.Ln;
|
Out.String("ident: '"); Out.String(ident); Out.Char("'"); Out.Ln;
|
||||||
Out.String("host: '"); Out.String(host); Out.Char("'"); Out.Ln;
|
Out.String("host: '"); Out.String(host); Out.Char("'"); Out.Ln;
|
||||||
Out.String("*** that's it ***"); Out.Ln;
|
Out.String("*** that's it ***"); Out.Ln;
|
||||||
END onPrivateMessage;
|
END onPrivateMessage;
|
||||||
|
|
||||||
PROCEDURE onPublicMessage(VAR msg, user, ident, rcpt, host: ARRAY OF CHAR);
|
PROCEDURE onPublicMessage(VAR msg, msgtype, user, ident, rcpt, host: ARRAY OF CHAR);
|
||||||
BEGIN
|
BEGIN
|
||||||
Out.String("*** public message ***"); Out.Ln;
|
Out.String("*** public message ***"); Out.Ln;
|
||||||
Out.String("message: '"); Out.String(msg); Out.Char("'"); Out.Ln;
|
Out.String("message: '"); Out.String(msg); Out.Char("'"); Out.Ln;
|
||||||
|
Out.String("message type: '"); Out.String(msgtype); Out.Char("'"); Out.Ln;
|
||||||
Out.String("user: '"); Out.String(user); Out.Char("'"); Out.Ln;
|
Out.String("user: '"); Out.String(user); Out.Char("'"); Out.Ln;
|
||||||
Out.String("ident: '"); Out.String(ident); Out.Char("'"); Out.Ln;
|
Out.String("ident: '"); Out.String(ident); Out.Char("'"); Out.Ln;
|
||||||
Out.String("recipient: '"); Out.String(rcpt); Out.Char("'"); Out.Ln;
|
Out.String("recipient: '"); Out.String(rcpt); Out.Char("'"); Out.Ln;
|
||||||
|
|
@ -32,10 +34,11 @@ BEGIN
|
||||||
Out.String("*** that's it ***"); Out.Ln;
|
Out.String("*** that's it ***"); Out.Ln;
|
||||||
END onPublicMessage;
|
END onPublicMessage;
|
||||||
|
|
||||||
PROCEDURE onPublicMessageWithMention(VAR msg, user, ident, rcpt, host: ARRAY OF CHAR);
|
PROCEDURE onPublicMessageWithMention(VAR msg, msgtype, user, ident, rcpt, host: ARRAY OF CHAR);
|
||||||
BEGIN
|
BEGIN
|
||||||
Out.String("*** public message, bot name mentioned ***"); Out.Ln;
|
Out.String("*** public message, bot name mentioned ***"); Out.Ln;
|
||||||
Out.String("message: '"); Out.String(msg); Out.Char("'"); Out.Ln;
|
Out.String("message: '"); Out.String(msg); Out.Char("'"); Out.Ln;
|
||||||
|
Out.String("message type: '"); Out.String(msgtype); Out.Char("'"); Out.Ln;
|
||||||
Out.String("user: '"); Out.String(user); Out.Char("'"); Out.Ln;
|
Out.String("user: '"); Out.String(user); Out.Char("'"); Out.Ln;
|
||||||
Out.String("ident: '"); Out.String(ident); Out.Char("'"); Out.Ln;
|
Out.String("ident: '"); Out.String(ident); Out.Char("'"); Out.Ln;
|
||||||
Out.String("recipient: '"); Out.String(rcpt); Out.Char("'"); Out.Ln;
|
Out.String("recipient: '"); Out.String(rcpt); Out.Char("'"); Out.Ln;
|
||||||
|
|
@ -55,7 +58,7 @@ BEGIN
|
||||||
inst.nick := "vocbot";
|
inst.nick := "vocbot";
|
||||||
inst.host := "irc.freenode.net";
|
inst.host := "irc.freenode.net";
|
||||||
inst.port := "6667";
|
inst.port := "6667";
|
||||||
inst.callbackSimple := onMessage;
|
(*inst.callbackSimple := onMessage;*)
|
||||||
inst.callbackPrivate := onPrivateMessage;
|
inst.callbackPrivate := onPrivateMessage;
|
||||||
inst.callbackPublic := onPublicMessage;
|
inst.callbackPublic := onPublicMessage;
|
||||||
inst.callbackPublicMention := onPublicMessageWithMention;
|
inst.callbackPublicMention := onPublicMessageWithMention;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue