Chat bot functions

June 28, 2009 by paulhenry
Filed under: Developement Projects 

So in this post, I would like to give you a description of each function in the chat bot, and the way each function works.

First we will go over the 2 simple functions.
!say : This function causes the bot to print out whatever is in message, like it is talking in the channel, if you where to type “/msg kk !say “, the bot would just print the message out to the channel, but your message would not appear in the channel.
!is : This is the equivalent of /is , it is like a status update.

Now we have about 6 functions that allow conversion between value representation.
!decbin : This simply converts number to a binary representation, like the binary representation of 3 is 11.
!dechex : This gives you the hexadecimal representation of number.
!hexdec : Outputs the decimal equivalent of number.
!hexbin : Gives you the binary representation of number.
!bindec : Gives you the decimal representation of number.
!binhex : Gives you the hexadecimal representation of number.

Now, here are the 2 “coolest” functions.
!calc : This is a fascinating function. It will evaluate expression as a mathematical expression. How does is it do it? The bot will actually take expression, processes the text, and then actually puts it into C# code, compiles the code, then runs the code natively, on the host machine, instead of just the classic string parsing method. This means that you can put your own C# code into it. while loops, if statements, etc. Now it does have a timer, where if it has been running longer than 10 seconds, then it will kill itself, as that normally means that it is in an infinite loop. Here are the list of functions you can have in the expression

  • Abs(number): Gives the absolute value of number.
  • Acos(number): Returns the angle whose cosine is the specified number.
  • Asin(number): Returns the angle whose sine is the specified number.
  • Atan(number): Returns the angle whose tangent is the specified number.
  • Atan2(number1, number2): Returns the angle whose tangent is the quotient of two specified numbers.
  • BigMul(number1, number2): Returns the angle whose tangent is the quotient of two specified numbers.
  • Ceiling(number): Overloaded. Returns the smallest integer greater than or equal to the specified number.
  • Cos(number): Returns the cosine of the specified angle.
  • Cosh(number): Returns the hyperbolic cosine of the specified angle.
  • Exp(number, power): Returns e raised to the specified power.
  • Floor(number): Returns the largest integer less than or equal to the specified number.
  • IEEERemainder(number1, number2): Returns the remainder resulting from the division of a specified number by another specified number.
  • Log(number): Returns the logarithm of a specified number.
  • Log10(number): Returns the base 10 logarithm of a specified number.
  • Max(number1, number2): Returns the larger of two specified numbers.
  • Min(number1, number2): Returns the smaller of two numbers.
  • Pow(number, power): Returns a specified number raised to the specified power.
  • Round(number, [decimalplaces]): Rounds a value to the nearest integer or specified number of decimal places.
  • Sign(number): Returns a value indicating the sign of a number.
  • Sin(number): Returns the sine of the specified angle.
  • Sinh(number): Returns the hyperbolic sine of the specified angle.
  • Sqrt(number): Returns the square root of a specified number.
  • Tan(number): Returns the tangent of the specified angle.
  • Tanh(number): Returns the hyperbolic tangent of the specified angle.

These are the values you can use.

  • E: Represents the natural logarithmic base, specified by the constant, e.
  • PI: Represents the ratio of the circumference of a circle to its diameter, specified by the constant, π.

!factor : This simply takes number, and outputs the prime factorization of that number. Now in order to do that, it must calculate the number to see if it is prime, and that can take a very very long time. I have actually implemented some caching, where it will cache prime numbers. The caching can decrease the time it takes to calculate the prime factorization by nearly half!! It is really simple really…

That is all the current functions for right now, I will definitely add more functions, including an actually chat engine. Stay tuned! :)

Comments

One Comment on Chat bot functions

  1. Zashkaser on Wed, 5th Aug 2009 8:41 pm
  2. Very interesting site. Hope it will always be alive!