here is the code to create a mother bot and create hand ids
and how do i add the pm@message command for the bot in room not the main mother bot?
- Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using agsXMPP;
using agsXMPP.protocol.client;
using agsXMPP.Xml.Dom;
using agsXMPP.protocol.x.muc;
namespace khuram_server_bot
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Control.CheckForIllegalCrossThreadCalls = false;
}
XmppClientConnection x = new XmppClientConnection();
private void button1_Click(object sender, EventArgs e)
{
x = new XmppClientConnection {Show = agsXMPP.protocol.client.ShowType.chat, Server = "nimbuzz.com", ConnectServer = "o.nimbuzz.com",Status="send help to know how to use" };
x.Open( id.Text, password.Text, resource.Text);
x.OnLogin += new ObjectHandler(x_OnLogin);
x.OnMessage += new MessageHandler(x_OnMessage);
x.OnAuthError += new XmppElementHandler(x_OnAuthError);
x.OnError +=new ErrorHandler(x_OnError);
x.OnPresence += new PresenceHandler(x_OnPresence);
}
public void x_OnPresence(object sender, Presence prs)
{
if (prs.Type == PresenceType.subscribe)
{
x.Send(new Presence { To = prs.From, Type = PresenceType.subscribe });
x.Send(new Presence { To = prs.From, Type = PresenceType.subscribed });
((XmppClientConnection)sender).Send(new agsXMPP.protocol.client.Message { To =prs.From, Body = "send help", Type = MessageType.chat });
}
}
public void x_OnLogin(object sender)
{
id.BackColor = Color.Green;
password.BackColor = Color.Green;
x.SendMyPresence();
}
public void x_OnError(object sender,Exception ex)
{
id.BackColor = Color.Yellow;
password.BackColor = Color.Yellow;
x.Open( id.Text, password.Text, resource.Text);
}
public void x_OnAuthError(object sender, Element el)
{
id.BackColor = Color.Red;
password.BackColor = Color.Red;
}
public void x_OnMessage(object sender, agsXMPP.protocol.client.Message msg)
{
try
{
if (msg.Body == null)
{
return;
}
else
{
msg.Body = msg.Body.ToLower().Trim();
}
if (msg.Body == "help")
{
((XmppClientConnection)sender).Send(new agsXMPP.protocol.client.Message { To = msg.From, Body = "send con#id#password#resource#room#roompassword ", Type = MessageType.chat });
}
if (msg.Body.StartsWith("con#"))
{
string[] arr = new string[]{};
arr = msg.Body.Split('#') ;
freebuzz.botz b = new freebuzz.botz();
if (arr.Length == 5)
{
b.Connect(msg.From.User, arr[1], arr[2], arr[3], arr[4]);
}
else if (arr.Length == 6)
{
b.Connect(msg.From.User, arr[1], arr[2], arr[3], arr[4], arr[5]);
}
else
{
((XmppClientConnection)sender).Send(new agsXMPP.protocol.client.Message { To = msg.From, Body = "wrong command send con#id#password#resource#room#roompassword", Type = MessageType.chat });
return;
}
((XmppClientConnection)sender).Send(new agsXMPP.protocol.client.Message { To = msg.From, Body = "hale", Type = MessageType.chat });
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void button2_Click(object sender, EventArgs e)
{
if(x.XmppConnectionState!= XmppConnectionState.Disconnected)
{
x.Close();
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
and how do i add the pm@message command for the bot in room not the main mother bot?