Go Back   RunUO - Ultima Online Emulation > RunUO > General Discussion

General Discussion General discussion for the RunUO community, all off-topic posts will be deleted. This forum is NOT FOR SUPPORT!

Reply
 
Thread Tools Display Modes
Old 03-02-2006, 08:06 PM   #1 (permalink)
 
Join Date: Dec 2004
Location: Sweden
Posts: 117
Default mIRC Bot for RunUO?

i started to wonder how you check the current players online outside of game. ive seen a Bot that does this on a channel on Quakenet. but i dont know where the client checks the current players. any sugestions?
__________________
|
|
| Xibalba - The gates of Hell
|
|_________________________
Tobbe371 is offline   Reply With Quote
Old 03-02-2006, 08:57 PM   #2 (permalink)
Administrator
 
Zippy's Avatar
 
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,868
Default

Here's a PHP example of how to get this info. If you know enough about C/C++/C# you can write an app (or a plugin for an existing client like an mIRC dll) to connect to IRC and display this info.

Online status and players online
__________________
Zippy, Razor Creator and RunUO Core Developer
The RunUO Software Team

"Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal."
~The Cryptonomicon

Zippy is offline   Reply With Quote
Old 03-03-2006, 08:57 AM   #3 (permalink)
Forum Expert
 
Shadow1980's Avatar
 
Join Date: Mar 2005
Location: York, UK
Age: 28
Posts: 708
Default

Quote:
Originally Posted by Tobbe371
i started to wonder how you check the current players online outside of game. ive seen a Bot that does this on a channel on Quakenet. but i dont know where the client checks the current players. any sugestions?
Our shard has a bot that does exactly that and much much more. Like said earlier in this thread, code a class that connects to irc. For some servers you might need a form of authentication but if you don't know how to get around that the best advice is not starting in the first place.
You will need thorough knowledge of raw irc commands (not mIRC commands).

Either way when you get it done the possibilities are endless.

Unfortunatly our project is classed strictly private, and I am not at liberty to discuss the other functions of it. I can however assure you that succesfully coding this leads to a major improvement of your shards functionality.
I can also state with extreme confidence that there is no other shard out there that has a better irc bot running from the runuo code then ours does. (Little moment of pride, sorry )

Of course you could also dump data in an mysql database and extract it with another bot such as eggdrop from there. We chose coding it in c# inside the runuo code so that we could interact both ways, not just relay information to an irc channel.
__________________
Shadow1980
Game Reviews, Jokes and Rants from real People
Shadow1980 is offline   Reply With Quote
Old 03-03-2006, 09:14 AM   #4 (permalink)
Forum Novice
 
Join Date: Mar 2004
Location: Germany
Age: 23
Posts: 301
Default

http://thresher.sourceforge.net/

There are already C# classes for IRC connectivity. It's threaded so it should perfectly co-exists with RunUO and can simply be used in on of the scripts. It contains several examples, so it should be really easy to implement. Have fun
__________________
RunUO RemoteAdmin - Control your shard remotely and keep an eye on the page queue
MulEditor - Modify gump, art, tiledata, multimap, localization files and map/statics.
CentrED - A Client/Server based multi-user map editor.
floppydisc is offline   Reply With Quote
Old 03-03-2006, 09:36 AM   #5 (permalink)
Forum Expert
 
Manu's Avatar
 
Join Date: Jul 2005
Location: München/Deutschland (Munich/Germany)
Age: 27
Posts: 1,947
Send a message via ICQ to Manu Send a message via Skype™ to Manu
Default

Quote:
Originally Posted by Tobbe371
i started to wonder how you check the current players online outside of game.
There is a folder called "web". Inside theres the "status.html". I set up a cronjob that copies that file into our webserver directory every 5 minutes. That is, of course only doable if you have a ded-server w/ a webserver on it
Manu is offline   Reply With Quote
Old 03-03-2006, 03:00 PM   #6 (permalink)
Forum Novice
 
Evil Jason's Avatar
 
Join Date: Jan 2005
Location: The People's Republic of Massachusetts
Age: 33
Posts: 158
Angry Since I got yelled at for asking you to PM me...

Here is the LINK to a script that is a mIRC client for RunUO.

mIRC Bot for RunUO?


~Jason
__________________
So long and thanks for all the fish. :D

時々私poop
Quote:
Welcome to Thunderdome, Bitch.
Evil Jason is offline   Reply With Quote
Old 03-03-2006, 03:57 PM   #7 (permalink)
Forum Expert
 
stormwolff's Avatar
 
Join Date: Nov 2003
Location: The Internet
Age: 28
Posts: 3,510
Default

Quote:
Originally Posted by Evil Jason
Here is the LINK to a script that is a mIRC client for RunUO.

mIRC Bot for RunUO?


~Jason
Your link points back to this topic :P
stormwolff is offline   Reply With Quote
Old 03-03-2006, 04:46 PM   #8 (permalink)
Forum Expert
 
Join Date: Sep 2002
Age: 23
Posts: 1,472
Default

Here's a very basic bot that will listen for commands to be sent over an IRC channel, and reply with things like usercount. It's an early-on modification of a script by Mark called PageBot.

Code:
using System;
using Server;
using System.IO;
using System.Net;
using Server.Network;
using System.Threading;
using System.Net.Sockets;

namespace Server.Misc
{
	public class StatusBot
	{
		public static string Nickname = "StatusBot";
		public static string Username = "StatusBot";
		public static string Realname = "StatusBot";
		public static string Channel  = "#shard";

		public static string Server   = "irc.serveraddress.net";
		public static int    Port     = 6667;

		public static string NickservPassword = null; // If you want to register StatusBot with nickserv, enter the password you registered the nickname to here.
		public static bool   ReconnectOnDisc  = true;
		public static bool   Connected        = false;
	
		public static TimeSpan SpamDelay = TimeSpan.FromSeconds( 5.0 ); // StatusBot only accepts one command every 5 seconds, so users won't spam it.
		public static DateTime LastCommand;

		public static string Message = "";


		public static void Initialize()
		{
			Thread t = new Thread( new ThreadStart( Connect ) );
			t.Start();
		}

		private static StreamReader SR;
		private static StreamWriter SW;

		public static string FormatTimeSpan( TimeSpan ts )
		{
			return String.Format( "{0:D2} Days, {1:D2} Hours, {2:D2} Minutes, and {3:D2} Seconds", ts.Days, ts.Hours % 24, ts.Minutes % 60, ts.Seconds % 60 );
		}

		public static void Connect()
		{
			try
			{
				TcpClient C = new TcpClient( Server, Port );
				NetworkStream S = C.GetStream();
				SW = new StreamWriter( S );
				SR = new StreamReader( S );
			}
			catch
			{
				Thread.Sleep(60000);
				Connect();
			}

			Connected = true;

			SendRaw( "USER "+Username+" 0 * :"+Realname );

			SetNick( Nickname );

			if (NickservPassword != null)
				Identify( NickservPassword );

			JoinChannel( Channel );

			GetInput();
		}

		public static void Stop()
		{
			Connected = false;
			SR.Close();
			SW.Close();
		}


		private static void GetInput()
		{
			try
			{
				while ( Connected && ParseIncoming( SR.ReadLine() ) );
			}
			catch( Exception )
			{
				// Something's Wrong... Probably Disconnected
				Connected = false;
			}
			if ( ReconnectOnDisc )
			{
				Thread.Sleep(60000);
				Connect();
			}
		}

		private static bool ParseIncoming( string inputLine )
		{		
			if ( inputLine == null )
				return false;

			string[] parts = inputLine.Split(':');

			if ( parts.Length == 3 )
				Message = parts[2]; 
			else
				Message = "";

			if( inputLine.StartsWith( "PING" ) )
				SendRaw("PONG "+ inputLine.Substring(6));

			if ( Message.StartsWith( "!" ) && LastCommand + SpamDelay <= DateTime.Now )
				ReadCommand( Message );
		
			return true;
		}

		private static void ReadCommand( string inputLine )
		{
			int userCount = NetState.Instances.Count;
			string uptime = FormatTimeSpan( DateTime.Now - Clock.ServerStart );

			LastCommand = DateTime.Now;

			switch( inputLine.ToLower() )
			{
				case "!status":
				{
					SendMessage( Channel, String.Format( "Users Online: {0} .:. Uptime {1} .:. -[StatusBot]-", userCount, uptime ) );				
					break;
				}
			}
		}

		private static void SendRaw( string Message )
		{
			try
			{
				if ( Connected )
				{
					SW.WriteLine( Message );
					SW.Flush();
				}
			}
			catch
			{
				// Something's Wrong... Probably Disconnected
				Connected = false;
			}
		}

		private static void Identify( string Password )
		{
			SendMessage("Nickserv", "Identify " + Password );
		}

		private static void JoinChannel( string C )
		{
			SendRaw( "JOIN "+C );
		}

		private static void PartChannel( string C )
		{
			SendRaw( "PART "+C );
		}

		private static void PartChannel( string C, string Message )
		{
			SendRaw( "PART "+C+" :"+Message  );
		}

		private static void Quit()
		{
			SendRaw( "QUIT" );
			Stop();
		}

		private static void Quit( string Message )
		{
			SendRaw( "QUIT :"+Message );
			Stop();
		}

		private static void SendMessage( string Target, string Message )
		{
			SendRaw( "PRIVMSG "+Target+" :"+Message );
		}

		private static void SendNotice( string Target, string Message )
		{
			SendRaw( "NOTICE "+Target+" :"+Message );
		}

		private static void SetMode( string Target, string Modes )
		{
			SendRaw( "MODE "+Target+" :"+Modes );
		}

		private static void SetNick( string N )
		{
			SendRaw( "NICK "+N );
		}
	}
}
I'm not even sure how well it works anymore, but feel free to learn from it.
Ravatar is offline   Reply With Quote
Old 03-03-2006, 05:18 PM   #9 (permalink)
xir
Forum Newbie
 
Join Date: Jul 2004
Posts: 59
Default

Doesn't the UOG packet reveal how many players etc. that a shard currently has online? If it does you can just create a mIRC or eggdrop script that connects to your shard and grabs the information.
xir is offline   Reply With Quote
Old 03-03-2006, 11:36 PM   #10 (permalink)
Forum Novice
 
Evil Jason's Avatar
 
Join Date: Jan 2005
Location: The People's Republic of Massachusetts
Age: 33
Posts: 158
Default CRAP.. Sorry

Quote:
Originally Posted by stormwolff
Your link points back to this topic :P
IRC Client in Ultima Online!





~Jason
__________________
So long and thanks for all the fish. :D

時々私poop
Quote:
Welcome to Thunderdome, Bitch.
Evil Jason is offline   Reply With Quote
Old 03-04-2006, 06:30 AM   #11 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
Default

Well along with all the other crap I am working on, I am also working on a IRC bot based off of PHP that works for the most part. Currently though it is just a hacked together version that is kind of hard to understand and I am in the process of rewriting it. However, the most efficient way to use it (since it is based off a webserver) is if you are able to use cron jobs so that the script will restart once a day, in case it loses connection (or you can manually restart it). This way your RunUO server isnt wasting resources or bandwidth on an IRC bot. Ill release this eventually, so hopefully I get in a coding mood and get this and the online server status script done lol.

If you are going to do it yourself though, make sure you know a bit about IRC protocol cause I dont think it is quite uniform for every command, which makes it annoying when processing commands (although it might be easier in C#, cause i noticed that inputLine.StartsWith function)...

Here are some useful websites though:
http://www.mirc.net/raws/
http://www.irchelp.org/irchelp/rfc/rfc.html

[edit]
Quote:
Originally Posted by xir
Doesn't the UOG packet reveal how many players etc. that a shard currently has online? If it does you can just create a mIRC or eggdrop script that connects to your shard and grabs the information.
You dont really want to do it this way because then you will be pinging the server everytime someone asks the bot for the number of players online, which may not seem like a big problem, but its just that much more lag for the players. Thats why my script caches it in a flat file (and in the next release a database if needed). However, if you want to go the route of the bot connecting directly, you could just set the bot up to check every 15-30 minutes automatically and then save the result and send that when comeone asks. Again though, if you display the number of users online on your website (such as with my script) you are going to be connecting that many more times, instead of using the same result....


Just my two cents...

Last edited by mordero; 03-04-2006 at 06:34 AM.
mordero is offline   Reply With Quote
Old 03-04-2006, 07:13 AM   #12 (permalink)
Forum Expert
 
Greystar's Avatar
 
Join Date: Mar 2004
Location: NorthCentral IL, USA
Age: 35
Posts: 3,848
Default

Quote:
Originally Posted by mordero
Well along with all the other crap I am working on, I am also working on a IRC bot based off of PHP that works for the most part. Currently though it is just a hacked together version that is kind of hard to understand and I am in the process of rewriting it. However, the most efficient way to use it (since it is based off a webserver) is if you are able to use cron jobs so that the script will restart once a day, in case it loses connection (or you can manually restart it). This way your RunUO server isnt wasting resources or bandwidth on an IRC bot. Ill release this eventually, so hopefully I get in a coding mood and get this and the online server status script done lol.

If you are going to do it yourself though, make sure you know a bit about IRC protocol cause I dont think it is quite uniform for every command, which makes it annoying when processing commands (although it might be easier in C#, cause i noticed that inputLine.StartsWith function)...

Here are some useful websites though:
http://www.mirc.net/raws/
http://www.irchelp.org/irchelp/rfc/rfc.html

[edit]


You dont really want to do it this way because then you will be pinging the server everytime someone asks the bot for the number of players online, which may not seem like a big problem, but its just that much more lag for the players. Thats why my script caches it in a flat file (and in the next release a database if needed). However, if you want to go the route of the bot connecting directly, you could just set the bot up to check every 15-30 minutes automatically and then save the result and send that when comeone asks. Again though, if you display the number of users online on your website (such as with my script) you are going to be connecting that many more times, instead of using the same result....


Just my two cents...

OR just check when someone asks the bot if there is any users online like says !Users or /msg Bot !Users
__________________
Quote:
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
Killable Guards (GS Version)
Just a Simple Staff Tool
You can leave me messages.
Ernest Gary Gygax - Quote "I would like the world to remember me as the guy who really enjoyed playing games and sharing his knowledge and his fun pastimes with everybody else."
Greystar is offline   Reply With Quote
Old 03-04-2006, 08:11 AM   #13 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
Default

Quote:
Originally Posted by Greystar
OR just check when someone asks the bot if there is any users online like says !Users or /msg Bot !Users
No, because if you have idiots in the channel or even people just asking everytime they join the channel, etc you will over ping the server. Everytime you check the status, that is a connection that must be opened up for the server and another thing that the server must do. So it is better to cache the results for a certain time limit. This will make the results off by 15-30 minutes, but it will also allow the response to be generated faster and waste less resources.
mordero is offline   Reply With Quote
Old 03-04-2006, 09:00 AM   #14 (permalink)
Forum Novice
 
Join Date: Jan 2006
Location: Illinios
Age: 25
Posts: 162
Send a message via ICQ to viront
Default

Quote:
Originally Posted by Tobbe371
i started to wonder how you check the current players online outside of game. ive seen a Bot that does this on a channel on Quakenet. but i dont know where the client checks the current players. any sugestions?
You could use WatchUO on the machine running the server. It runs seperatly from UO and displays accounts/online clients and lets you fiddle with some properties and options.
__________________
Meh.
viront is offline   Reply With Quote
Old 03-04-2006, 03:02 PM   #15 (permalink)
Forum Expert
 
Greystar's Avatar
 
Join Date: Mar 2004
Location: NorthCentral IL, USA
Age: 35
Posts: 3,848
Default

Quote:
Originally Posted by mordero
No, because if you have idiots in the channel or even people just asking everytime they join the channel, etc you will over ping the server. Everytime you check the status, that is a connection that must be opened up for the server and another thing that the server must do. So it is better to cache the results for a certain time limit. This will make the results off by 15-30 minutes, but it will also allow the response to be generated faster and waste less resources.
that's why you make it OP only command
__________________
Quote:
(\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.
Killable Guards (GS Version)
Just a Simple Staff Tool
You can leave me messages.
Ernest Gary Gygax - Quote "I would like the world to remember me as the guy who really enjoyed playing games and sharing his knowledge and his fun pastimes with everybody else."
Greystar is offline   Reply With Quote
Old 03-04-2006, 04:27 PM   #16 (permalink)
Forum Expert
 
mordero's Avatar
 
Join Date: Nov 2003
Location: Illinois, USA
Age: 22
Posts: 2,911
Default

That would also work because that is what we currently use. However, then you have the problem of people asking the ops to see how many people are online. To avoid this you could make the op only for the channel but also allow people to PM the bot and have the number sent by PM to the user.
mordero is offline   Reply With Quote
Old 10-21-2006, 04:50 AM   #17 (permalink)
Forum Novice
 
Join Date: May 2005
Age: 36
Posts: 220
Default

Here's a question regarding to this. I'm just wondering... Why an IRC bot? Isn't there any way possible to create a script that can log into a designated account an admin creates on a shard, that can perform the same functions?
seanandre is offline   Reply With Quote
Old 10-21-2006, 11:47 AM   #18 (permalink)
Account Terminated
 
Join Date: Jun 2004
Location: Cincinnati, Ohio
Age: 20
Posts: 3,954
Default

seanandre: That's exactly what Knives' Chat System does. It's simply an end-user preference.
WarAngel is offline   Reply With Quote
Old 10-21-2006, 05:45 PM   #19 (permalink)
Administrator
 
Zippy's Avatar
 
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,868
Default

If you are interested in displaying the current number of players online VIA your website, this information is now available free from ConnectUO.com.

All you have to do is register your shard (like UOgateway and/or TopShards).

Www.ConnectUO.com for more info.
__________________
Zippy, Razor Creator and RunUO Core Developer
The RunUO Software Team

"Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal."
~The Cryptonomicon

Zippy is offline   Reply With Quote
Old 10-24-2006, 01:06 PM   #20 (permalink)
Forum Newbie
 
Shanira's Avatar
 
Join Date: Jul 2004
Age: 25
Posts: 48
Default

Correct me if I'm wrong but can't you just publish your status.html page that RunUO generates and put the link in an IRC topic? >_> That's what I did.
Shanira is offline   Reply With Quote
Old 10-24-2006, 06:57 PM   #21 (permalink)
Administrator
 
Zippy's Avatar
 
Join Date: Aug 2002
Location: Baltimore, MD
Age: 25
Posts: 4,868
Default

I always found it a big pain to upload the status page to the webserver. I think most other people find that a PITA or just don't know how.
__________________
Zippy, Razor Creator and RunUO Core Developer
The RunUO Software Team

"Intuition, like a flash of lightning, lasts only for a second. It generally comes when one is tormented by a difficult decipherment and when one reviews in his mind the fruitless experiments already tried. Suddenly the light breaks through and one finds after a few minutes what previous days of labor were unable to reveal."
~The Cryptonomicon

Zippy is offline   Reply With Quote
Old 10-24-2006, 07:12 PM   #22 (permalink)
Forum Novice
 
Join Date: Dec 2005
Posts: 206
Default

I have the status.html in my webserver w/ no problem.. I have an script which copies it to my webserver (from the server who holds runuo) every some minutes.
__________________
11010101 me.
the nico is offline   Reply With Quote
Old 10-24-2006, 08:45 PM   #23 (permalink)
Forum Newbie
 
Shanira's Avatar
 
Join Date: Jul 2004
Age: 25
Posts: 48
Default

Well for those who want to publish their status.html file and don't know how, here's how, provided you run your UO server on the same machine as your webpage. Open WebStatus.cs and search for the following line:

Code:
			using ( StreamWriter op = new StreamWriter( "web/status.html" ) )
Then you can change that to whatever path holds the root for your website, so for instance (made up )

Code:
			using ( StreamWriter op = new StreamWriter( @"D:\webroot\uo\status.html" ) )
Shanira is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off