本文整理汇总了C#中Bot.Join方法的典型用法代码示例。如果您正苦于以下问题:C# Bot.Join方法的具体用法?C# Bot.Join怎么用?C# Bot.Join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bot
的用法示例。
在下文中一共展示了Bot.Join方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: evt_login
public static void evt_login(Bot bot, dAmnPacket packet)
{
if (packet.Arguments["e"] != "ok")
{
ConIO.Warning("dAmn", String.Format("Failed to login as {0} [{1}]", packet.Parameter, packet.Arguments["e"]));
if (packet.Arguments["e"] == "authentication failed")
{
ConIO.Write("Attempting to renew authtoken...");
if (Program.RenewToken())
{
Program.ForceReconnect = true;
Program.wait_event.Set();
return;
}
}
Program.Running = false;
Program.wait_event.Set();
}
else
{
ConIO.Write(String.Format("Logged in as {0} [{1}]", packet.Parameter, packet.Arguments["e"]));
bot.Join("chat:DSGateWay");
foreach (String channel in bot.Config.Channels)
{
bot.Join(channel);
}
}
}
示例2: cmd_cycle
public static void cmd_cycle(Bot bot, String ns, String[] args, String msg, String from, dAmnPacket packet)
{
var chan = "";
if (args.Length > 1 && args[1].StartsWith("#"))
{
chan = args[1];
}
else
{
chan = ns;
}
String cpns = Tools.FormatNamespace(chan, Types.NamespaceFormat.Packet).ToLower();
if (!Core.ChannelData.ContainsKey(cpns))
{
bot.Say(ns, "<b>» It doesn't look like I'm in that channel.</b>");
return;
}
lock (CommandChannels["part"])
{
CommandChannels["part"].Add(ns);
}
lock (CommandChannels["join"])
{
CommandChannels["join"].Add(ns);
}
bot.Part(cpns);
bot.Join(cpns);
}
示例3: BotHostModule
public BotHostModule(Bot bot)
: base("bot")
{
_bot = bot;
Get["/start"] = _ =>
{
try
{
StartBot();
return "Bot Started";
}
catch (Exception e)
{
return e.Message;
}
};
Get["/stop"] = _ =>
{
try
{
ShutDownBot();
return "Bot Shut Down";
}
catch (Exception e)
{
return e.Message;
}
};
// This is for ensuring that the process doesn't die permanently --
// We create a task with MomentApp (TBD whether we will use this permanently
Get["/keepalive"] = _ =>
{
ScheduleKeepAlive(Request.Url.ToString());
return "OK";
};
Post["/launch"] = _ =>
{
//TODO: verify there is an auth token
return "";
};
Post["/join"] = _ =>
{
_bot.Join(Request.Form.Room);
return Response.AsRedirect("/Rooms");
};
Get["/leave"] = _ =>
{
_bot.Leave(Request.Query.Room);
return Response.AsRedirect("/Rooms");
};
}
示例4: cmd_chat
public static void cmd_chat(Bot bot, String ns, String[] args, String msg, String from, dAmnPacket packet)
{
String pcns = Tools.FormatPCNS(from, bot.Config.Username);
lock (CommandChannels["join"])
{
CommandChannels["join"].Add(ns);
}
bot.Join(pcns);
}
示例5: JoinRooms
private static void JoinRooms(Bot bot)
{
foreach (var room in _botRooms.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(r => r.Trim()))
{
Trace.Write("Joining {0}...", room);
if (TryCreateRoomIfNotExists(room, bot))
{
bot.Join(room);
Trace.WriteLine("OK");
}
else
{
Trace.WriteLine("Failed");
}
}
}
示例6: Main
static void Main()
{
using (var bot = new Bot())
{
bot.AddPlugin(new TriviaPlugin());
bot.Connect("irc.quakenet.org", "GinnTrivia", "GinnTrivia", "GinnTrivia");
Console.WriteLine("Connected...");
bot.Join("#ginnunga");
bot.Message +=
(channel, sender, text) => Console.WriteLine(string.Format("{0}/{1}: {2}", channel.Name, sender, text));
Console.ReadKey();
}
}
示例7: evt_kicked
public static void evt_kicked(Bot bot, dAmnPacket packet)
{
// Don't display DataShare messages.
if (!Program.NoDisplay.Contains(Tools.FormatNamespace(packet.Parameter.ToLower(), Types.NamespaceFormat.Channel)))
{
if (packet.Body.Length > 0)
ConIO.Write(String.Format("*** Kicked by {0}: {1}", packet.Arguments["by"], packet.Body), Tools.FormatChat(packet.Parameter));
else
ConIO.Write(String.Format("*** Kicked by {0}", packet.Arguments["by"]), Tools.FormatChat(packet.Parameter));
}
// In the event that we cannot (or will not) rejoin, remove channel data.
lock (ChannelData)
{
if (ChannelData.ContainsKey(packet.Parameter.ToLower()))
ChannelData.Remove(packet.Parameter.ToLower());
}
// Rejoin!
if (bot.AutoReJoin)
bot.Join(packet.Parameter);
}
示例8: BotHostModule
public BotHostModule(Bot bot, SprocketManager sprockets, IEnumerable<ISprocketInitializer> sprocketInitializers)
: base("bot")
{
_bot = bot;
_sprockets = sprockets;
_sprocketInitializers = sprocketInitializers;
Get["/start"] = _ =>
{
try
{
StartBot();
return "Bot Started";
}
catch (Exception e)
{
return e.Message;
}
};
Get["/stop"] = _ =>
{
try
{
ShutDownBot();
return "Bot Shut Down";
}
catch (Exception e)
{
return e.Message;
}
};
// This is for ensuring that the process doesn't die permanently --
// We create a task with MomentApp (TBD whether we will use this permanently
Get["/keepalive"] = _ =>
{
ScheduleKeepAlive(Request.Url.ToString());
return "OK";
};
Get["/launch"] = _ =>
{
//TODO: verify there is an auth token
LoadCoffeeScript();
return "";
};
Post["/join"] = _ =>
{
_bot.Join(Request.Form.Room);
return Response.AsRedirect("/Rooms");
};
Get["/leave"] = _ =>
{
_bot.Leave(Request.Query.Room);
return Response.AsRedirect("/Rooms");
};
Post["/send/{room}"] = _ =>
{
_bot.Say(Request.Form.Message, _.Room);
return Response.AsRedirect("/");
};
Post["/attach"] = _ =>
{
AttachScript(Request.Form.script);
return Response.AsRedirect("/");
};
Post["/disable/{sprocket}"] = _ =>
{
var sprocket = sprockets[_.Sprocket];
_bot.DisableSprocket(sprocket);
return Response.AsRedirect("/");
};
Post["/enable/{sprocket}"] = _ =>
{
var sprocket = sprockets[_.Sprocket];
_bot.EnableSprocket(sprocket);
return Response.AsRedirect("/");
};
}
示例9: Update
public void Update()
{
if (_connectStarted.Elapsed.TotalSeconds > 120)
{
if (_bot != null)
_bot.Disconnect();
Status = ConnectionStatus.Disconnected;
}
if (Status != ConnectionStatus.Disconnected)
return;
_hasConnected = false;
_connectStarted.Restart();
Program.Logger.Info("Connecting");
_bot = new Bot(Program.Settings.Username, Program.Settings.Password);
_bot.OnConnected += sender =>
{
_hasConnected = true;
_connectStarted.Stop();
_bot.PersonaName = Program.Settings.PersonaName;
_bot.PersonaState = EPersonaState.Online;
Status = ConnectionStatus.Connected;
Program.Logger.Info("Connected");
};
_bot.OnDisconnected += (sender, reason) =>
{
if (_hasConnected)
{
Program.Logger.Info("Disconnected");
_hasConnected = false;
}
Status = ConnectionStatus.Disconnected;
};
_bot.OnFriendRequest += (sender, user) => _bot.AddFriend(user.Id);
_bot.OnPrivateEnter += (sender, chat) =>
{
chat.OnMessage += (chatSender, messageSender, message) =>
Command.Handle(new CommandTarget(chatSender, messageSender.Id), message, "");
};
_bot.OnChatInvite += (sender, chat, @by) =>
{
if (chat.Id.IsIndividualAccount)
_bot.Join(chat.Id);
};
_bot.Connect();
Status = ConnectionStatus.Connecting;
}
示例10: cmd_autojoin
public static void cmd_autojoin(Bot bot, String ns, String[] args, String msg, String from, dAmnPacket packet)
{
String helpmsg = String.Format("<b>» Usage:</b><br/>{0}autojoin list<br/>{0}autojoin add/del #channel", " · " + bot.Config.Trigger);
if (args.Length < 2)
{
bot.Say(ns, helpmsg);
}
else
{
String arg = args[1];
if (arg == "list")
{
bot.Config.Channels.Sort();
bot.Say(ns, String.Format("<b>» Autojoined channels:</b><br/> · <b>[</b>{0}<b>]</b>", String.Join("<b>]</b>, <b>[</b>", bot.Config.Channels)));
}
else if (args.Length == 3)
{
String chan = args[2].ToLower();
if (!chan.StartsWith("#"))
{
bot.Say(ns, helpmsg);
return;
}
if (arg == "add")
{
if (!bot.Config.Channels.Contains(chan))
{
Program.AddChannel(chan);
bot.Say(ns, "<b>» Channel added to autojoin:</b> " + args[2]);
bot.Join(chan);
}
else
{
bot.Say(ns, "<b>» Channel already exists in autojoin:</b> " + args[2]);
}
}
else if (arg == "del")
{
if (bot.Config.Channels.Contains(chan))
{
Program.RemoveChannel(chan);
bot.Say(ns, "<b>» Channel removed from autojoin:</b> " + args[2]);
}
else
{
bot.Say(ns, "<b>» Channel is not in autojoin:</b> " + args[2]);
}
}
else
{
bot.Say(ns, helpmsg);
}
}
else
{
bot.Say(ns, helpmsg);
}
}
}
示例11: ParseBDS
//.........这里部分代码省略.........
if (data.Length < 4 || !data[2].Contains("/"))
return;
String who = data[0].ToLower();
String[] versions = data[2].Split('/');
String clientver = versions[0];
ulong ts = Bot.EpochTimestamp;
double bdsver = 0.0;
if (!Double.TryParse(versions[1], out bdsver))
bdsver = 0.2;
Types.ClientInfo client_info = new Types.ClientInfo(data[0], data[1], clientver, bdsver, ts);
if (!_clientinfo_database.ContainsKey(who))
_clientinfo_database.Add(who, client_info);
else
_clientinfo_database[who] = client_info;
if (Program.Debug)
ConIO.Write("Updated information for client: " + data[0], "BDS");
clients_synced++;
}
}
else if (bits.Length >= 3 && bits[1] == "LINK")
{
if (bits.Length == 4 && bits[3].ToLower() == username.ToLower())
{
if (bits[2] == "ACCEPT" && from.ToLower() == syncwith)
{
bot.Join(Tools.FormatPCNS(from, username));
}
else if (bits[2] == "REJECT" && from.ToLower() == syncwith)
{
syncwith = "";
syncing = false;
isrequester = false;
}
else if (bits[2] == "REQUEST" && !syncing && from.ToLower() == syncwith)
{
syncing = true;
bot.NPSay(ns, "BDS:LINK:ACCEPT:" + from);
bot.Join(Tools.FormatPCNS(from, username));
}
}
}
else if (bits.Length >= 4 && bits[1] == "SEEN" && IsPoliceBot(username, pboverride: true))
{
if (bits[2] == "REQUEST" && bits[3].Contains(','))
{
var payload = bits[3].Split(',');
if (payload.Length >= 2 && payload[0].ToLower() == username.ToLower())
{
var who = payload[1].ToLower();
if (!BDS._seen_database.ContainsKey(who))
bot.NPSay(ns, "BDS:SEEN:NODATA:" + from + "," + payload[1]);
else
{
var info = BDS._seen_database[who];
bot.NPSay(ns, String.Format("BDS:SEEN:RESPONSE:{0},{1},{2},{3},{4}", from, info.Name, info.Type, info.Channel, info.Timestamp));