Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Riina Antikainen
/
Moya
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 306df88c
authored
Dec 13, 2014
by
Tuukka Kivilahti
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'botmsg' into 'master'
Update irc bot message format See merge request !162
2 parents
9faddab0
f3c4c041
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
10 deletions
code/moya-beans/ejbModule/fi/codecrew/moya/beans/moyamessage/IrcBotMoyaEventTopicListener.java
code/moya-beans/ejbModule/fi/codecrew/moya/beans/moyamessage/IrcBotMoyaEventTopicListener.java
View file @
306df88
...
@@ -11,7 +11,11 @@ import org.slf4j.LoggerFactory;
...
@@ -11,7 +11,11 @@ import org.slf4j.LoggerFactory;
import
fi.codecrew.moya.beans.BotBean
;
import
fi.codecrew.moya.beans.BotBean
;
import
fi.codecrew.moya.facade.EventFacade
;
import
fi.codecrew.moya.facade.EventFacade
;
import
fi.codecrew.moya.facade.EventUserFacade
;
import
fi.codecrew.moya.facade.UserFacade
;
import
fi.codecrew.moya.model.EventUser
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.LanEvent
;
import
fi.codecrew.moya.model.User
;
import
fi.codecrew.moya.utilities.moyamessage.MoyaEventMessage
;
import
fi.codecrew.moya.utilities.moyamessage.MoyaEventMessage
;
/**
/**
...
@@ -27,6 +31,10 @@ public class IrcBotMoyaEventTopicListener implements MessageListener {
...
@@ -27,6 +31,10 @@ public class IrcBotMoyaEventTopicListener implements MessageListener {
@EJB
@EJB
private
EventFacade
eventfacade
;
private
EventFacade
eventfacade
;
@EJB
private
UserFacade
userfacade
;
@EJB
private
EventUserFacade
eventuserfacade
;
/**
/**
* @see MessageListener#onMessage(Message)
* @see MessageListener#onMessage(Message)
...
@@ -40,19 +48,30 @@ public class IrcBotMoyaEventTopicListener implements MessageListener {
...
@@ -40,19 +48,30 @@ public class IrcBotMoyaEventTopicListener implements MessageListener {
if
(
e
!=
null
)
if
(
e
!=
null
)
event
=
e
.
getName
();
event
=
e
.
getName
();
}
}
botbean
.
getBot
().
say
(
toString
(
event
,
" "
,
msg
.
getEventtype
(),
" msg: "
,
msg
.
getDescription
()));
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
event
).
append
(
" "
);
sb
.
append
(
msg
.
getEventtype
()).
append
(
" "
);
if
(
msg
.
getCurrentUserId
()
!=
null
)
{
User
user
=
userfacade
.
find
(
msg
.
getCurrentUserId
());
if
(
user
!=
null
)
{
sb
.
append
(
"user: "
).
append
(
user
.
getLogin
()).
append
(
" "
);
}
}
if
(
msg
.
getEventUserId
()
!=
null
)
{
EventUser
eu
=
eventuserfacade
.
find
(
msg
.
getEventUserId
());
if
(
eu
!=
null
&&
!
eu
.
getUser
().
getId
().
equals
(
msg
.
getCurrentUserId
()))
{
sb
.
append
(
"for user: "
).
append
(
eu
.
getUser
().
getLogin
()).
append
(
": "
);
}
}
sb
.
append
(
msg
.
getDescription
());
//botbean.getBot().say(toString(event, " ", msg.getEventtype(), " User ", msg.getDescription()));
botbean
.
getBot
().
say
(
sb
.
toString
());
logger
.
warn
(
"Received moya event message for irc bot {}"
,
message
);
logger
.
warn
(
"Received moya event message for irc bot {}"
,
message
);
}
catch
(
JMSException
e
)
{
}
catch
(
JMSException
e
)
{
logger
.
warn
(
"Exception while getting jms message for IRCbot"
);
logger
.
warn
(
"Exception while getting jms message for IRCbot"
,
e
);
botbean
.
getBot
().
say
(
"Caught exception while logging message"
+
e
.
getCause
());
}
}
}
}
private
static
String
toString
(
Object
...
string
)
{
StringBuilder
sb
=
new
StringBuilder
();
for
(
Object
s
:
string
)
{
sb
.
append
(
s
);
}
return
sb
.
toString
();
}
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment