本文整理汇总了C#中Meebey.SmartIrc4net.IrcClient类的典型用法代码示例。如果您正苦于以下问题:C# IrcClient类的具体用法?C# IrcClient怎么用?C# IrcClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IrcClient类属于Meebey.SmartIrc4net命名空间,在下文中一共展示了IrcClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getQuiet
public static void getQuiet(string[] args, string Channel, string Nick, IrcClient irc)
{
if (args.Length > 2) { irc.SendMessage(SendType.Message, Channel, String.Format("({0}) Usage: " + Program.GlobalVar.bot_comm_char + "getQuiet [#channel]", Nick)); }
else
{
string quietChan = Channel;
bool chanCheck = false;
if (args.Length == 2) { quietChan = args[1]; }
if (quietChan.StartsWith("#"))
{
MySqlCommand command = Program.GlobalVar.conn.CreateCommand();
command.CommandText = "SELECT Channel,Quiet FROM channels WHERE Channel='" + quietChan.ToLower() + "'";
try { Program.GlobalVar.conn.Open(); }
catch (Exception e) { Console.WriteLine(e.Message); }
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
if (reader["Channel"].ToString() == quietChan.ToLower())
{
if (Convert.ToInt32(reader["Quiet"]) == 0) { irc.SendMessage(SendType.Notice, Nick, String.Format("{0} is currently set to Not Quiet", Channel)); }
else { irc.SendMessage(SendType.Notice, Nick, String.Format("{0} is currently set to Quiet", Channel)); }
chanCheck = true;
}
}
Program.GlobalVar.conn.Close();
if (chanCheck == false) { irc.SendMessage(SendType.Notice, Nick, String.Format("I don't have data on that channel sir")); }
}
else { irc.SendMessage(SendType.Message, Channel, String.Format("Please input a valid channel name sir")); }
}
}
示例2: command
//https://developers.google.com/youtube/2.0/developers_guide_dotnet
public static void command(string[] args, string Channel, string Nick, IrcClient irc)
{
if (args.Length == 1)
{
irc.SendMessage(SendType.Message, Channel, string.Format("{0}, Usage: $youtube [flag] <search term(s)>", Nick));
}
else
{
string strVideo = string.Empty;
string flag = string.Empty;
if (args[1].StartsWith("+"))
{
for (int i = 2; i < args.Length; i++)
{
strVideo += args[i] + ' ';
}
strVideo = strVideo.TrimEnd();
flag = args[1];
}
else
{
foreach (string ss in args)
strVideo += ss + ' ';
strVideo = strVideo.Substring(args[0].Length + 1);
strVideo = strVideo.TrimEnd(' ');
}
string videoOutput = YoutubeOutput(strVideo, flag);
irc.SendMessage(SendType.Message, Channel, string.Format("{0}: {1}", Nick, videoOutput));
}
}
示例3: RelayConsole
public RelayConsole(RadegastInstance instance)
: base(instance)
{
InitializeComponent();
Disposed += new EventHandler(RelayConsole_Disposed);
textPrinter = new RichTextBoxPrinter(rtbChatText);
irc = new IrcClient();
irc.SendDelay = 200;
irc.AutoReconnect = true;
irc.CtcpVersion = Properties.Resources.RadegastTitle;
irc.Encoding = Encoding.UTF8;
TC.OnTabAdded += new TabsConsole.TabCallback(TC_OnTabAdded);
TC.OnTabRemoved += new TabsConsole.TabCallback(TC_OnTabRemoved);
irc.OnError += new ErrorEventHandler(irc_OnError);
irc.OnRawMessage += new IrcEventHandler(irc_OnRawMessage);
irc.OnChannelMessage += new IrcEventHandler(irc_OnChannelMessage);
irc.OnConnected += new EventHandler(irc_OnConnected);
irc.OnDisconnected += new EventHandler(irc_OnDisconnected);
client.Self.IM += new EventHandler<InstantMessageEventArgs>(Self_IM);
RefreshGroups();
}
示例4: getInstance
public static IrcClient getInstance()
{
if (instance == null)
instance = new IrcClient();
return instance;
}
示例5: set
public static void set(string[] args, string Channel, string Nick, IrcClient irc)
{
DateTime tellTime = DateTime.Now;
string message = string.Empty;
if (args.Length == 1 || args.Length == 2) { irc.SendMessage(SendType.Message, Channel, String.Format("({0}) Usage: " + Program.GlobalVar.bot_comm_char + "tell <nick> <message>", Nick)); }
else
{
foreach (string s in args)
message += s + " ";
message = message.Substring(args[0].Length + args[1].Length + 2);
message = message.TrimEnd(' ');
MySqlCommand command = Program.GlobalVar.conn.CreateCommand();
Program.GlobalVar.conn.Open();
command.Connection = Program.GlobalVar.conn;
command.CommandText = "INSERT into tell VALUES(@to,@from,@message,@time)";
command.Prepare();
command.Parameters.AddWithValue("@to", args[1].ToLower());
command.Parameters.AddWithValue("@from", Nick);
command.Parameters.AddWithValue("@message", message);
command.Parameters.AddWithValue("@time", tellTime.ToString());
command.ExecuteNonQuery();
Program.GlobalVar.conn.Close();
try { Program.GlobalVar.tellList.Add(args[1].ToLower()); }
catch { }
Console.WriteLine("{0} has left a message for {1}", Nick, args[1]);
irc.SendMessage(SendType.Message, Channel, String.Format("I will pass that along sir"));
}
}
示例6: get
public static void get(string[] args, string Channel, string Nick, IrcClient irc)
{
DateTime time = DateTime.Now;
string message = string.Empty;
bool tellCheck = false;
MySqlCommand command = Program.GlobalVar.conn.CreateCommand();
command.CommandText = "SELECT Nick_To,Nick_From,Message,Time FROM tell where Nick_To='" + Nick.ToLower() + "'";
try { Program.GlobalVar.conn.Open(); }
catch (Exception e) { Console.WriteLine(e.Message); }
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
if (reader["Nick_To"].ToString() == Nick.ToLower())
{
tellCheck = true;
//Compose output
TimeSpan elapsed = time.Subtract(DateTime.Parse(reader["Time"].ToString()));
message = String.Format("({0:%d} days, {1:%h} hours, {2:%m} minutes) Sent from {3} -- {4}", elapsed, elapsed, elapsed, reader["Nick_From"].ToString(), reader["Message"].ToString());
//send output
irc.SendMessage(SendType.Message, Nick, message);
try { Program.GlobalVar.tellList.Remove(Nick); }
catch { }
}
}
Program.GlobalVar.conn.Close();
command.CommandText = "DELETE FROM tell WHERE Nick_To='" + Nick.ToLower() + "'";
Program.GlobalVar.conn.Open();
command.ExecuteNonQuery();
Program.GlobalVar.conn.Close();
if (tellCheck == false) { irc.SendMessage(SendType.Message, Nick, String.Format("I don't have any messages for you sir")); }
}
示例7: command
public static void command(string trigger, string Channel, string Nick, IrcClient irc)
{
//first make sure the trigger exists
bool remCheck = false;
bool global = false;
bool lck = false;
MySqlCommand command = Program.GlobalVar.conn.CreateCommand();
command.CommandText = "SELECT Trig,Channel,Nick,Time,lck FROM rem where Trig='" + trigger + "'";
try { Program.GlobalVar.conn.Open(); }
catch (Exception e) { Console.WriteLine(e.Message); }
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
if (reader["Trig"].ToString() == trigger && (reader["Channel"].ToString() == Channel.ToLower() || reader["channel"].ToString() == "global"))
{
remCheck = true;
if (reader["Channel"].ToString() == "global")
global = true;
if (Convert.ToInt32(reader["lck"]) == 1)
lck = true;
irc.SendMessage(SendType.Message, Channel, String.Format("{0} was set by {1} at {2} (G={3}/L={4})", trigger, reader["Nick"].ToString(), reader["Time"].ToString(), global, lck));
global = false;
lck = false;
}
}
Program.GlobalVar.conn.Close();
//get info
if (remCheck == false) { irc.SendMessage(SendType.Notice, Nick, String.Format("I don't have anything stored for {0} sir", trigger)); }
}
示例8: change
public static void change(string[] args, string Channel, string Nick, IrcClient irc)
{
if (args.Length != 2) { irc.SendMessage(SendType.Message, Channel, String.Format("({0}) Usage: " + Program.GlobalVar.bot_comm_char + "nick <new nick>", Nick)); }
{
irc.RfcNick(args[1]);
}
}
示例9: set
//addquote <name> <message>
public static void set(string[] args, string Channel, string Nick, IrcClient irc)
{
if (args.Length <= 2) { irc.SendMessage(SendType.Message, Channel, String.Format("({0}) Usage: " + Program.GlobalVar.bot_comm_char + "addquote <nick> <message>", Nick)); }
else
{
MySqlCommand command = Program.GlobalVar.conn.CreateCommand();
//rebuild message
string message = string.Empty;
foreach (string s in args)
message += s + " ";
message = message.Substring(args[0].Length + args[1].Length + 2);
message = message.TrimEnd(' ');
try
{
Program.GlobalVar.conn.Open();
command.Connection = Program.GlobalVar.conn;
command.CommandText = "INSERT into quote VALUES(@nick,@message)";
command.Prepare();
command.Parameters.AddWithValue("@nick", args[1]);
command.Parameters.AddWithValue("@message", message);
command.ExecuteNonQuery();
Program.GlobalVar.conn.Close();
irc.SendMessage(SendType.Message, Channel, String.Format("I have added the quote sir, I hope it is very embarrassing"));
}
catch (Exception e) { Botler.Utilities.TextFormatting.ConsoleERROR(e.Message + "\n"); }
}
}
示例10: SparkleListenerIrc
public SparkleListenerIrc(string server, string folder_identifier, NotificationServerType type)
: base(server, folder_identifier, type)
{
base.server = server;
// Try to get a uniqueish nickname
this.nick = SHA1 (DateTime.Now.ToString ("ffffff") + "sparkles");
// Most irc servers don't allow nicknames starting
// with a number, so prefix an alphabetic character
this.nick = "s" + this.nick.Substring (0, 7);
base.channels.Add ("#" + folder_identifier);
this.client = new IrcClient () {
PingTimeout = 180,
PingInterval = 90
};
this.client.OnConnected += delegate {
base.is_connecting = false;
OnConnected ();
};
this.client.OnDisconnected += delegate {
OnDisconnected ();
};
this.client.OnChannelMessage += delegate (object o, IrcEventArgs args) {
string message = args.Data.Message.Trim ();
string folder_id = args.Data.Channel.Substring (1); // remove the starting hash
OnRemoteChange (new SparkleAnnouncement (folder_id, message));
};
}
示例11: Ralph
public Ralph(String _channel,String _token,String _name)
{
this._token = "oauth:"+_token;
this._channel = _channel;
this._name = "AneleBot";
_client = new IrcClient()
{
Encoding = Encoding.UTF8,
ActiveChannelSyncing = true,
SendDelay = 5000,
AutoRejoin = true,
AutoRejoinOnKick = true,
AutoReconnect = true,
AutoRelogin = true,
AutoRetry = true,
AutoRetryLimit = 0
};
_client.OnChannelMessage+=onMessage;
_client.OnRawMessage += logMessage;
_handler = new RHandler(this);
DumberLogger.Log("Ralph: ralph got created");
}
示例12: command
public static void command(string[] args, string Channel, string Nick, IrcClient irc)
{
if (args.Length > 2) { irc.SendMessage(SendType.Message, Channel, String.Format("({0}) Usage: " + Program.GlobalVar.bot_comm_char + "chanop [#channel]", Nick)); }
else
{
string opChan = Channel;
bool chanCheck = false;
if (args.Length == 2) { opChan = args[1]; }
if (opChan.StartsWith("#"))
{
MySqlCommand command = Program.GlobalVar.conn.CreateCommand();
command.CommandText = "SELECT Channel,ChanOP FROM channels WHERE Channel='" + opChan.ToLower() + "'";
try { Program.GlobalVar.conn.Open(); }
catch (Exception e) { Console.WriteLine(e.Message); }
MySqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
if (reader["Channel"].ToString() == opChan.ToLower())
{
irc.SendMessage(SendType.Message, Channel, String.Format("The Channel Operator for {0} is {1}", opChan, reader["ChanOP"].ToString()));
chanCheck = true;
}
}
Program.GlobalVar.conn.Close();
if (chanCheck == false) { irc.SendMessage(SendType.Message, Channel, String.Format("I don't have data for that channel sir")); }
}
else { irc.SendMessage(SendType.Message, Channel, String.Format("Please input a valid channel name sir")); }
}
}
示例13: Connect
public void Connect()
{
IrcClient = new IrcClient();
IrcClient.OnConnected += OnConnected;
IrcClient.OnConnecting += OnConnecting;
IrcClient.OnDisconnected += OnDisconnected;
//IrcClient.OnReadLine += OnReadLine;
IrcClient.OnPing += OnPing;
IrcClient.OnRawMessage += OnRawMessage;
IrcClient.AutoRetry = Convert.ToBoolean(Connection.auto_retry);
IrcClient.AutoRetryDelay = Convert.ToInt32(Connection.auto_retry_delay);
IrcClient.AutoReconnect = Convert.ToBoolean(Connection.auto_reconnect);
IrcClient.AutoRelogin = Convert.ToBoolean(Connection.auto_relogin);
IrcClient.AutoRejoin = Convert.ToBoolean(Connection.auto_rejoin);
IrcClient.AutoRejoinOnKick = Convert.ToBoolean(Connection.auto_rejoin_on_kick);
IrcClient.AutoNickHandling = Convert.ToBoolean(Connection.auto_nick_handling);
try
{
IrcClient.Connect(Connection.hostname, Convert.ToInt32(Connection.port));
}
catch (Exception e)
{
Console.WriteLine("Failed to connect: " + e.Message);
}
}
示例14: set
//blacklist <nick> <host>
public static void set(string[] args, string Channel, string Nick, IrcClient irc)
{
if (args.Length != 3) { irc.SendMessage(SendType.Message, Channel, String.Format("({0}) Usage: " + Program.GlobalVar.bot_comm_char + "blacklist <nick> <host>", Nick)); }
else
{
MySqlCommand command = Program.GlobalVar.conn.CreateCommand();
try
{
Program.GlobalVar.conn.Open();
command.Connection = Program.GlobalVar.conn;
command.CommandText = "INSERT into blacklist VALUES(@nick,@host)";
command.Prepare();
command.Parameters.AddWithValue("@nick", args[1].ToLower());
command.Parameters.AddWithValue("@host", args[2]);
command.ExecuteNonQuery();
Program.GlobalVar.conn.Close();
irc.SendMessage(SendType.Message, Channel, String.Format("I have added {0}@{1} to the blacklist sir, we don't want naughty people using me", args[1].ToLower(), args[2]));
Console.WriteLine("{0} was added to the blacklist", args[1].ToLower());
}
catch (Exception e) { Botler.Utilities.TextFormatting.ConsoleERROR(e.Message + "\n"); }
}
}
示例15: ident
public static void ident(string[] args, string Channel, string Nick, IrcClient irc)
{
if (args.Length != 2) { irc.SendMessage(SendType.Message, Channel, String.Format("({0}) Usage: " + Program.GlobalVar.bot_comm_char + "ident <password>", Nick)); }
{
irc.SendMessage(SendType.Message, "NickServ", String.Format("identify {0}", args[1]));
}
}