Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <onidev/network.h>
- #include <iostream>
- #include <cstdlib>
- std::string translate(std::string str)
- {
- while(str.find(' ') != -1)
- str.replace(str.find(' '), 1, "%20");
- std::string json = od::Http::download("http://translate.google.com/translate_a/t?client=p&text="+str+"&sl=fr&tl=en&sc=1&ssel=0&tsel=0");
- std::cout << json << std::endl;
- int p = json.find("\"trans\"");
- p += 9;
- return json.substr(p, json.find('\"', p) - p);
- }
- int main()
- {
- using namespace od;
- using namespace std;
- string server = "irc.mibbit.net", chan = "#CBNA", username = "trans";
- //std::cin >> username;
- Irc irc(server, 6667, true);
- irc.connect();
- irc.nick(username);
- irc.user(username, "host", server, server);
- irc.join(chan, "");
- while(true)
- {
- irc.getMessage();
- if(irc.messageType() == Irc::Message || irc.messageType() == Irc::PrivateMessage)
- {
- string msg = irc.messageString();
- irc.privmsg(chan, translate(msg.substr(0, msg.length()-1))+"\n");
- }
- else if(irc.messageType() == Irc::Kick)
- {
- cout << "You have been kicked by " << irc.messageUsername() << endl;
- irc.join(chan, "");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment