Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
*Bump* After staying up successfully for well over 24 hours, Decbot3 is now live in the channel. !calc is now in Python instead of Javascript.
And after a week of not cooperating, DecBot3 is back down. I think I'm going to give up on that library, it's being way too clever for its own good.
merthsoft wrote:
And after a week of not cooperating, DecBot3 is back down. I think I'm going to give up on that library, it's being way too clever for its own good.
What seems to be the problem with the library? Does it not recover well from error conditions (as was the case with the Python IRC library that I very heavily modified for SaxJax) or does it have some other flaw?
It stops responding to (or, so it seems, getting at all) pings from the server, so it times out. Once it does that, I can make it reconnect, but it won't output anything after that (though it continues to keep track of ++s).
merthsoft wrote:
It stops responding to (or, so it seems, getting at all) pings from the server, so it times out. Once it does that, I can make it reconnect, but it won't output anything after that (though it continues to keep track of ++s).


That seems weirdly reminiscent of oldschool saxjax behavior (one-way relays and all that stuff). Which library are you using?
IRC.NET
Huh, so obviously not the same library saxjax is based on, but it still apparently has the same sorts of errors?
In case any one wants to do some data processing (or they just don't want a fancy table), here's a TSV of the scores:
http://merthsoft.com/DecBotTab.php
It goes:
place<\t>name<\t>score<\n>

Enjoy!
After much fighting, DecBot3 seems to be going now. Features include:
- Everything DecBot2 did
- !calc now driven through wolfram|alpha
- !karma without a user will now return the karma of the requesting user.

Also, I'm using my DynamicConfig library for server config and such, so it's at least getting some use Smile
merthsoft wrote:

- !calc now driven through wolfram|alpha


That's pretty cool, does wolfram|alpha have an API of some sort?
ElectronicsGeek wrote:
merthsoft wrote:

- !calc now driven through wolfram|alpha


That's pretty cool, does wolfram|alpha have an API of some sort?


I second this, I'd love to know how you got it to do calculations via wolfram|alpha. Could come in handy at some point in the future for me.
Not sure if im using the wrong notation or what, but

13:37:43 (C) Cemetech: Rhombus P.: !calc 2^2=22
13:36:45 (C) Cemetech: Rhombus P.: !calc 2*2=4
13:36:31 (C) Cemetech: Rhombus P.: !calc sqrt(4)=4

dosent seem right
ElectronicsGeek wrote:
That's pretty cool, does wolfram|alpha have an API of some sort?
http://products.wolframalpha.com/api/
(Yes.)
Rhombus P. wrote:
Not sure if im using the wrong notation or what, but

13:37:43 (C) Cemetech: Rhombus P.: !calc 2^2=22
13:36:45 (C) Cemetech: Rhombus P.: !calc 2*2=4
13:36:31 (C) Cemetech: Rhombus P.: !calc sqrt(4)=4

dosent seem right


!calc doesn't work in saxjax, you have to use !clac if you want to use DecBot from there. Note that the person responding to you in the log is Cemetech, not DecBot3.
Tari wrote:
ElectronicsGeek wrote:
That's pretty cool, does wolfram|alpha have an API of some sort?
http://products.wolframalpha.com/api/
(Yes.)


Ah, thanks, Tari. I will most certainly look into this. Especially the .NET bindings.
I didn't even bother with the binding--it's simple enough that I just called it directly:

Code:
   public class WolframAlpha {
      private const string WolframURL = "http://api.wolframalpha.com/v2/query?appid=<PUT YOUR APPID HERE>&input={0}&format=plaintext";

      public static string Calculate(string math) {
         math = Uri.EscapeDataString(math);
         HttpWebRequest req = (HttpWebRequest)WebRequest.Create(string.Format(WolframURL, math));
         XmlDocument doc = new XmlDocument();
         using (Stream s = req.GetResponse().GetResponseStream()) {
            doc.Load(s);
         }

         XmlNode root = doc.SelectSingleNode("//queryresult");
         bool success;
         if (!bool.TryParse(root.Attributes["success"].Value, out success) || !success) {
            return "Could not calculate. Perhaps try ~calc.";
         }

         StringBuilder ret = new StringBuilder();
         XmlNodeList pods;
         pods = root.SelectNodes("//pod[contains(@primary,'true')]");
         if (pods.Count == 0) {
            pods = root.SelectNodes("//pod[@id!='Input']"); // and position() < 6]");
         }

         if (pods.Count == 0) { return "Could not calculate. Perhaps try ~calc."; }

         if (pods.Count == 1) { return pods[0].ChildNodes[0].InnerText.Replace("\r\n", " / ").Replace("\n", " / "); }

         foreach (XmlNode pod in pods) {
            string title = pod.Attributes["title"].Value;
            string data = pod.ChildNodes[0].InnerText.Replace("\r\n", " / ").Replace("\n", " / ");
            if (string.IsNullOrWhiteSpace(data)) { continue; }
            string formattedString = string.Format("{0}: {1} \\ ", title, data);
            if (ret.Length + formattedString.Length > 150) { ret.Append("Rest of output too long \\ ");  break; }
            ret.AppendFormat(formattedString);
         }

         ret.Length -= 2;

         return ret.ToString();
      }
   }
Alright, I've added a couple things in !calc:
1. If there's only one solution for a problem, it does not preface it with the name.
2. If the output is too long, it now gives you a ling to the results.
before wrote:
<Merth> !calc 2+2
<Merth> !calc peter
<DecBot3> Merth: Result: 4
<DecBot3> Merth: Rest of output too long

after wrote:
<Merth> !calc 2+2
<Merth> !calc peter
<DecBot3> Merth: 4
<DecBot3> Merth: Rest of output too long: http://tny.im/kQ


I've also added command logging so I can keep track of what's been called when for debugging.
#cemetech wrote:
(2:29:54 PM) DecBot3: Don't greet the bots.
(2:30:13 PM) geekboy: CVSoft-L im probably gonna fasion something out of plywood and stuff and mount the tv to it
(2:30:26 PM) AHelper0: nikkybot: Should you greet DecBot3?
(2:30:30 PM) nikkybot: !karma your face
(2:30:41 PM) CVSoft-L: hmmm... I'm out of outlets too.
(2:31:10 PM) DecBot3: nikkybot I love you
(2:31:16 PM) AHelper0: oh god
(2:31:24 PM) nikkybot: sometimes it recovers, Sometimes IT will work BEFORE I become very annoyed when it seems you do love you Dan_Eng!
(2:31:31 PM) KermM: Um
(2:31:36 PM) AHelper0: what just happened?

I see that you made some nice features to work with nikkybot Smile
Hahaha, that was just me talking through him Smile
You should at least have DecBot talk back to nikkybot when it says '!karma your face' or something else with decbot in it, just for kicks. Razz
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3, 4, 5, 6, 7, 8, 9  Next
» View previous topic :: View next topic  
Page 6 of 9
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum