Posted: Wed Mar 01, 2006 6:38 pm Post subject: Help with Chat
Hello
I'm a complete noob in what relates to bots and Perl.
I installed ActivePerl, and was able to run two bots, White Warrior v1.0 and MayaBot v4.0.
So far so good, but I still can't do what I wanted, and I'm would you could help me.
I wanted a chatroom, but I wanted it to be a "real" chatroom, with several contacts in the same conversation.
Whenever anyone would open a conversation with the Bot, and give the command !chat, the bot would then invite that user to a conversation already open and with several people in it already chatting.
If that conversation window doesn't exist yet, a separate one would be created...to where others would be invited, and keeping the initial conversation intact.
I don't know how difficult this is to do, but I sure was unable to do it.
I tried a MSN::SimChat that I found here, but could integrate it with either WW or Maya.
<Command> Executing chat command
ERROR : Need a handle to invite
Caller trace:
0: MSN::error (MSN/SwitchBoard.pm, line 79)
1: MSN::SwitchBoard::error (MSN/SwitchBoard.pm, line 339)
2: MSN::SwitchBoard::invite ((eval 17), line 1)
3: (eval) (MSN Bot\MayaBot\bot.pl, line 166)
4: main::Message (MSN.pm, line 750)
5: MSN::call_event (MSN/SwitchBoard.pm, line 604)
6: MSN::SwitchBoard::CMD_MSG (MSN/SwitchBoard.pm, line 438)
7: MSN::SwitchBoard::dispatch (MSN.pm, line 691)
8: MSN::do_one_loop (MSN Bot\MayaBot\bot.pl, line 61)
That command gives this error
Imagine this:
Quote:
The BOT is running
User A logs in, opens a chat with the BOT and executes !chatroom command.
The BOT assumes the current conversation as a CHATROOM if no CHATROOM exists
User B logs in, opens a chat with the BOT and executes !chatroom
The BOT invites user B into CHATROOM, started by user A
User C logs in, opens a chat with the BOT and executes !chatroom
The BOT invites user C into CHATROOM, started by user A, and where is also user B.
User D logs in, opens a chat with the BOT and executes !chatroom
The BOT invites user D into CHATROOM, started by user A, and where is also user B and C
I don't nedd kicking,and baning and other complicated stuff, so no need for a simulated chat.
Its just inviting people into the same conversation over and over again, I suppose its a lot easier to do than the other Chats I have seen in templates I have tried, and I have tried MayaBot 4, Aiden 0.2 , Evolution 1.3, White Warrior 1.
Leviathan, WhiteWarrior and blobsy I couln't set them running.
if (!exists $msn->{chatroom})
{
$msn->{chatroom} = $self;
&send($self, "Bem-vindo/a ao Chat, $username");
}
elsif ($self eq $msn->{chatroom})
{
&send($self, "Já está no Chat!");
}
else
{
$msn->{chatroom}->invite($username);
&send($self, "A convidá-lo/a para entrar no Chat...");
&send($msn->{chatroom}, "Bem-vindo/a ao Chat, $username");
}
I believe this code came from a thred in this forum, but I don't remember which one.
In that thread one of my problems was already mencionted.
When everyone leaves the chat, and someone tries to get in, the bo tries to connect to the previous chat instead of starting a new one.
This problem I think is very complicated, and I doubt I can solve it.
I will just have to get someone to be in the chat 24/7 (another bot perhaps?)
Another thing that happens is that when someone leaves the chat, and then tries to return, it gets invited...but the conversation only opens on their end when one someone says something on the chat.
This could be easily resolved, by getting the Bot to greet overyone that enters the Chat, and this way the conversation would always be opened for them.
But the problem is that the Bot greets the person before she gets in!
Despite the order of the code, the message gets to the chat greeting the user...before the user actually enters the chat!!
this should have a way around...I would aprecciate some help
To solve the problem of inviting the person back into chat you probably do not
Code:
delete $msn->{chatroom};
When the last Person has left. which should solve that problem
For your second problem, do you use the join handler (i think its the right one)which is called when a person enters a room that is already open with the bot, maybe if you make it check if it is chat and then send the greet message.
Hope this helps
JT _________________ "Help us, Help you" - BotDepot
To solve the problem of inviting the person back into chat you probably do not
Code:
delete $msn->{chatroom};
When the last Person has left. which should solve that problem
For your second problem, do you use the join handler (i think its the right one)which is called when a person enters a room that is already open with the bot, maybe if you make it check if it is chat and then send the greet message.
Hope this helps
JT
I tried doing what you said, but failed to do so.
My knowledge of Pearl is close to null.
Can you give an example of the apllication of your advice, please?