Spore finally has a release date!!!

Computers, Gaming 1 Comment »

A date for every gamers diary: 7th September

A day when the most incredible, most sophisticated, most complex game in the entire history of gaming will be released. Spore has been in development since early 2000, and 8 years of work can really be felt in all the video demos that have been released. Will Wright has used procedural generating, and taken it to a whole new level. He has made his career off of so called “God games”, but I think Spore will be the ultimate achievement. You actually play God to an entire universe of life, creating, maintaining, and destroying.

All I need now is a time machine so I can actually play it…

Popularity: 3% [?]

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • NewsVine
  • Slashdot
  • Netscape
  • Technorati
  • blogmarks
  • Spurl
  • YahooMyWeb
  • BlinkList
  • Reddit
  • TailRank
  • feedmelinks
  • Furl

The Atheist Blogger

Atheism No Comments »

Since my favourite atheist quotes became such a success through StumbleUpon (even making it to one of their featured pages), I decided to create a new blog devoted entirely to atheism.

This blog is called “The Atheist Blogger” and can be found at http://atheistblogger.com or http://theatheistblogger.com.

Hopefully I will be able to make this site a successful blog about atheism!

Popularity: 3% [?]

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • NewsVine
  • Slashdot
  • Netscape
  • Technorati
  • blogmarks
  • Spurl
  • YahooMyWeb
  • BlinkList
  • Reddit
  • TailRank
  • feedmelinks
  • Furl

Yahoo will stay well away from Microsoft…

Internet 1 Comment »

Ever since the news came that Microsoft were offering to buy out Yahoo, I was waiting for the day when Yahoo would turn round and say (albeit quite politely) “fuck off”. Although that day has yet to come, it seems that the outcome of the proposal will be negative (for Microsoft obviously).

A lot of people said they were a match made in heaven, especially in the battle to take down Google, but they obviously failed to realise that a buyout of Yahoo worth $44.6bn is akin to going to a Ferrari car dealership and trying to get a top range model for a few thousand. Yahoo have a massive presence on the web, maybe not in terms of searching, but they have a whole range of services available, including mail, stock exchange, news, weather, and many many more. A deal worth $44.6bn is, in all fairness, an insult to a company like Yahoo, who are one of the oldest companies on the web.

So, assuming Yahoo reject the offer (which is the current likelihood), what will the next move be? Well, the offer has already increased the share price of Yahoo, possibly due to the large percentage of people who thought they would accept, and on the other side of the court, Microsoft’s shares have dropped by a staggering 12%, a drop that is thought to have been caused by the amount of Microsoft supporters who rejected the initial bid, saying that the company offered too much money.

Essentially, we have Yahoo on one side wanting more for their company, and Microsoft on the other, with most of their supporters saying they should have offered less. I can’t see a viable business solution any time soon, so it’s probably accurate to say that Yahoo won’t be going anywhere with Microsoft yet.

Popularity: 3% [?]

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • NewsVine
  • Slashdot
  • Netscape
  • Technorati
  • blogmarks
  • Spurl
  • YahooMyWeb
  • BlinkList
  • Reddit
  • TailRank
  • feedmelinks
  • Furl

MyBB 1.4 Admin Control Panel Revealed!

MyBB No Comments »

Yesterday, Chris Boulton (the project leader of MyBB) posted the first part of a “Complete Overview” series of blogs on the new ACP. It is very detailed, and contains a load of screenshots of the new features.

Check it out at the Official MyBB Blog

Popularity: 6% [?]

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • NewsVine
  • Slashdot
  • Netscape
  • Technorati
  • blogmarks
  • Spurl
  • YahooMyWeb
  • BlinkList
  • Reddit
  • TailRank
  • feedmelinks
  • Furl

Removing Google’s hold on Firefox

Internet 1 Comment »

If you are a Firefox user, you will undoubtedly know that Google has paid Mozilla for precedence in both the Search Box, and the Location Bar Search. Google is the default search engine used if you just type a bunch of keywords in the Location Bar instead of a URL. Firefox takes those keywords, sends them to Google, and if the top result has a high enough page rank, it sends you to the page itself (much like I’m feeling lucky).

Since I’ve switched to Yahoo as my main search engine, mainly due to Google’s recent privacy scandals and coupled with the research which tends towards Yahoo results as being more reliable (Google bombing anyone?), I’ve been trying to look for a way of switching the default search engine to Yahoo. After a bit of searching, I found the answer:

1) Type about:config in a new tab.

2) Filter the configuration variables by “keyword.URL“, there should be one result by the same name.

3) Change the value of keyword.URL from the Google URL (should be: http://www.google.com/search?ie=UTF-8&oe=UTF-8&sourceid=navclient&gfns=1&q=) to: http://search.yahoo.com/search?ei=UTF-8&p=

Bingo, typing keywords into the location bar will now make Firefox search using Yahoo.

Note: You can add other “attributes” to the search URL, as long as &p= is left at the end, since this is where Firefox adds the search keywords.

Popularity: 3% [?]

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • NewsVine
  • Slashdot
  • Netscape
  • Technorati
  • blogmarks
  • Spurl
  • YahooMyWeb
  • BlinkList
  • Reddit
  • TailRank
  • feedmelinks
  • Furl

Writing an IRC Bot in Ruby

Internet, Programming 4 Comments »

Many people use IRC (Internet Relay Chat) to communicate with others around the world, usually within a specific group or community (developer projects etc). During the years that IRC has been used, many people have written scripts that log into the IRC server and perform specific tasks. These are commonly referred to as “IRC Bots”. They appear as users in the channel, but are in fact just scripts running off a computer somewhere.

An IRC Bot can be used to manage channels (kicking members, banning members, making members OPs), or just to perform fun tasks (such as randomly generate quotes for members). Either way, a lot of people don’t realise just how easy making a bot is, so I’ve put together this tutorial which will walk you through the steps of building your very own IRC bot.

First Things First
Before you start programming in Ruby you will have to have it installed on your computer. I use Ubuntu Linux and so I used the command:

sudo apt-get install ruby ruby1.9

This will install ruby versions 1.8 through 1.9 onto your system. Another program that is useful to have when debugging ruby is the interactive version:

sudo apt-get install irb

If you use another Operating System (like Windows) you will have to look up how to install ruby on the internet.

Step 1
Create a new directory which will contain all your files associated with the Bot. I’ve created a directory “IRC Bot” in my home folder, and then a subdirectory “Ruby” in that.

Enter into the directory you have just created.

Step 2
Create a file called “config.rb”, open it in your favourite editor, and type the following:

$irc_server = ''
$irc_port = ''
$irc_nick = ''
$irc_host = ''
$irc_realname = ''
$irc_nickserv = ''
$irc_identify = ''
$irc_channel = ''
$irc_prefix = ''
$irc_password_prompt = '(This nickname is registered and protected|This nickname is owned by someone else)'
$irc_password_accepted = 'Password accepted \- you are now recognized'

These are the global configuration variables that we will use throughout the program. Here is a brief description of each:
$irc_server - The address where the IRC server is located, for example ‘irc.freenode.net’.
$irc_port - The port through which you can access the IRC server. Usually this is set to ‘6667′.
$irc_nick - The nickname your bot will use when it connects to the server.
$irc_host - The host of your bot (you can set this to any address you like, for instance ‘adrianhayter.com’).
$irc_realname - The “real name” of your bot (can be anything, but I usually set it to the same value as $irc_nick).
$irc_nickserv - The nickname of the NickServ bot on the IRC server (usually left as ‘NickServ’).
$irc_identify - The command used to identify users on the IRS server (usually set to ‘IDENTIFY {password}’, where {password} is the password associated with the Bot’s nickname).
$irc_channel - The name of the IRC channel you want the Bot to join (’#linux’ etc).
$irc_prefix - The prefix you want your bot to have which saves time when typing out commands (set it to something like ‘!’ or ‘%’).
$irc_password_prompt - This is a regular expression which matches the password prompt from the server (usually can be left as it is above).
$irc_password_accepted - This is a regular expression which matches the password accepted message from the server (usually can be left as it is above).

Save the config.rb with your new values.

Step 3
Create a file called “bot.rb” and open it in your favourite editor.

Add the lines:

require 'config.rb'
require 'socket'
require 'parse.rb'

$connect_log = ""
$joined = 0

def place(s)
strx = s.gsub(/\n/, "")
strx = strx.gsub(/\r/, "")
$con.send strx + "\n", 0
puts "--> " + strx
end

$con = TCPSocket.new($irc_server,$irc_port)
place("USER " + $irc_nick + " " + $irc_host + " blah :" + $irc_realname)
place("NICK " + $irc_nick)

I’ve written a lot here, and if you have never used Ruby before then it will appear confusing, so I’ll go through it in a bit more detail.

The first three lines are all “require” statements. These statements read the files into the current bot.rb program. The first reads the config.rb that we just created, the next loads the “socket” class which is a class already built into Ruby that allows the creation of sockets to access content on the internet. The last loads the file “parse.rb” which we will create later.

The next two lines are global variables, the first is a string to store the outputs of the server (which we will use later), and the second is a variable which we will set to 1 when the bot has joined the channel.

Then we get to our first functn ion, which is called “place”. It accepts a parameter “s”, and strips this parameter of all new lines and carriage returns, before sending it down the connection and outputting it to the terminal. You don’t have to use this function, but it is very useful this entire bot program is based around it.

Finally, we open a new TCP Socket connection to the IRC server using the details we gave in the config.rb file, and then send our user and nick information down it using the place function.

Step 4

Now that we have a connection to the server, we are going to have to create an infinite loop which continually gets data from the server and checks it to see if it is important.

Add this code below what you have already written:

while true do

$connect_log = $con.recv(512)

s = $connect_log.split("\r")
for i in s
puts i
if i =~ /PING\ / then
a = i.split("\:")
place("PONG #{$irc_host} :#{a[1]}")
end

if i =~ /#{$irc_password_prompt}/ then
place("PRIVMSG #{$irc_nickserv} \:#{$irc_identify}")
end

if i =~ /#{$irc_password_accepted}/ && $joined == 0 then
place("JOIN #{$irc_channel}")
$joined = 1
end

parse(i)

end

$connect_log = ''
puts "Log Cleared\n\n"
end

This code fetches 512 bytes of data from the server and splits it into an array (separated by a carriage return). It then goes through each of these lines and checks if it is a PING from the server (at which point it will PONG the message back). This stops your bot getting booted from the server due to a PING timeout. It also checks if the password prompt has been given by the server, at which point it will send back the relevant identify message. If the server accepts the identify, then the bot will detect the accepted message and will join the channel you set in the config.rb.

Since a lot of servers have different messages for identify / password accepted, you may have to do a little investigating to find the right one. Luckily, the line “puts i” at the start of the for loop outputs the server message to the terminal, so you can see what messages are being sent, and change the config.rb variables accordingly.

At the end, it sends “i” through the function parse() (which is in the file parse.rb) and clears the log.

Step 5

Finally, create a file called “parse.rb” and open it in your favourite editor.

Add this code:

def parse(x)

# INITIALIZE VARIABLES
upmynick = $irc_nick
mynick = upmynick.downcase
nick = ""
chan = ""
fullmsg = ""
upfullmsg = ""
msg = ""
upmsg = ""

# SPLIT CODE UP
s = x.split("\:",3)
if s[1] =~ /!/ then
nick = s[1].split("!")[0]
end
if s[1] =~ /\ / then
chan = s[1].split("\ ")[2]
end
if s[2] != nil then
puts s[2]
fullmsg = s[2].downcase
upfullmsg = s[2]
end
if s[3] != nil then
puts s[3]
fullmsg = fullmsg + s[3].downcase
upfullmsg = upfullmsg + s[3]
end

fullmsg = fullmsg.strip
upfullmsg = upfullmsg.strip

# CHECK IF MESSAGE IS DIRECTED AT BOT
if upfullmsg =~ /^(#{upmynick}\:|#{$irc_prefix})(\ )*/ then
direct = true
upmsg = upfullmsg.split(/^(#{upmynick}\:|#{$irc_prefix})*/, 2)
upmsg = upmsg[2].strip
msg = upmsg.downcase.strip
else
upmsg = upfullmsg.strip
msg = fullmsg.strip
end
end

This is a very complex parsing function, but will be your starting point in creating your own custom commands. The local variables “upmynick” and “mynick” are set to the normal case bot nickname, and the lowercase bot nickname respectively. This can be very useful, as you will want to check regular expressions against the lowercase nick, but output messages with the normal case nick.

The parse function then splits the message “i” up into sections, and gets information from those sections. The local variables “nick” and “chan” are set to the obvious (the nickname of the user who sent the message, and the channel they sent it to). The variables “fullmsg” and “upfullmsg” are simply the entire message the user has sent, in lowercase and normal case.

Most IRC bots only respond to commands if they are told directly to the bot, so the next part is very useful unless you want to piss a load of people off. If the variable “upfullmsg” begins with the bot nickname (and a colon), or the bot prefix (usually &, %, ., etc), then we know that the user is telling the bot directly. A new variable “direct” is set to true, and two new variables are created (upmsg, and msg). These variables are very similar to upfullmsg and fullmsg, but they don’t have the bot nickname or prefix at the start.

So, if the “fullmsg” was “IRC_BOT: hello!”, and the IRC bot’s nickname was set to “IRC_BOT”, then msg and upmsg would now be set to “hello!”. This simply means that everytime you check the regex of a command, you don’t need to include regex to check if the bot’s nickname is being referred to. You only need to see if direct is true.

Step 6

The final stage of an IRC Bot is to add some functions to it. I’m going to show you how to make one simple function (get the bot to flip a coin) and how to add it to the parse function.

At the end of the parse.rb, before the last “end”, add the following code:

if direct == true && msg =~ /^(flip|coin)/ then
if rand(2) == 1 then
flip = "Heads"
else
flip = "Tails"
end
place("PRIVMSG #{chan} :#{flip}")
end

Simply explained, this code checks that the variable “direct” is true (i.e. the command is being told directly to the bot), and that the message sent begins with either the word “flip” or “coin”. If both these conditions are met, then the code generates a random number between 0 and 2. If the number is 1, then the outcome is “Heads”, if it is not, the outcome is “Tails”. Note that a the random number in ruby can never be the number you set in the rand() function. So the only two numbers ever outputted by rand(2) will be 0 and 1.

The bot then uses the place() function we defined earlier in bot.rb to send a message back to the channel with whatever the variable “flip” has been set to.

Finally…

To run your IRC bot, simply run bot.rb using ruby.

Thanks very much for reading my tutorial. Please comment on things you think could be explained in more detail, and if something makes no sense. If you are having loads of trouble doing anything, then please feel free to download the complete files from this tutorial here:

http://adrianhayter.com/ircbot.release.1.0.tar.gz

Popularity: 5% [?]

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • StumbleUpon
  • NewsVine
  • Slashdot
  • Netscape
  • Technorati
  • blogmarks
  • Spurl
  • YahooMyWeb
  • BlinkList
  • Reddit
  • TailRank
  • feedmelinks
  • Furl
WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Login