It is currently October 21st, 2018, 10:37 am


All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: The worst fCraft mod that exists.
PostPosted: July 15th, 2012, 6:46 pm 

Joined: August 21st, 2011, 6:31 am
Posts: 280
Location: United Kingdom
This is an Omegle chat command. Use at your own risk, lol.

1. Make a new class
Show
Code:
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading;
using System.Collections;
using fCraft;

public class OmegleBot
{
    private string id;
    Player player;
    public string ID
    {
        get { return id; }
        set { id = value; }
    }

    private string lastMessage = String.Empty;
    public string LastMessage
    {
        get { return lastMessage; }
        set { lastMessage = value; }
    }

    private bool paired = false;
    public bool Paired
    {
        get { return paired; }
        set { paired = value; }
    }

    private Thread t;
    public Thread Thread
    {
        get { return t; }
        set { t = value; }
    }
    public OmegleBot()
    {

    }
    public OmegleBot(Player player_)
    {
        player = player_;
        // Logic
        Paired = true;
        ID = Connect();
    }

    public string Connect()
    {
        //gets your ID, Request() doesnt seem to work for this
        try
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://omegle.com/start");
            request.Method = "POST";
            WebResponse response = request.GetResponse();
            StreamReader reader = new StreamReader(response.GetResponseStream());
            ID = reader.ReadToEnd().Replace("\"", "");
            response.Close();
            reader.Close(); reader.Dispose();
            t = new Thread(EventWatcherThread);
            t.Start();
            return ID;
        }
        catch
        {
            player.Message(Color.Olive + "(Omegle)" + "&WCouldn't get a new chatter ID");
            return String.Empty;
        }
    }

    public void Disconnect()
    {
        Request("http://www.omegle.com/disconnect", "id=" + ID);
        player.OmBot = null;
        player.Message(Color.Olive + "(Omegle)You have disconnected");
        t.Abort();
    }

    public void Say(string what)
    {
        try
        {
            player.Message(Color.Olive + "(Omegle)You: " + what);
            Request("http://www.omegle.com/send", "id=" + ID + "&msg=" + what);
        }
        catch
        {
            player.Message(Color.Olive + "(Omegle)&WSomething went wrong with sending the /Om message");
        }
    }

    private void EventWatcherThread()
    {
        while (true)
        {
            if (Paired)
                GetEvents();
            else
                Disconnect();

            Thread.Sleep(1000);
        }
    }

    private void GetEvents()
    {
        string event_json = Request("http://www.omegle.com/events", "id=" + ID);

        if (event_json != "null")
        {
            Hashtable events = ParseJSON(event_json);
            HandleEvents(events);
        }
    }
    private void HandleEvents(Hashtable events)
    {
        IDictionaryEnumerator en = events.GetEnumerator();
        while (en.MoveNext())
        {
            switch (en.Key.ToString().Replace("[", "").Replace("]", ""))
            {
                case "typing":
                    //player.Message(Color.Olive + "(Omegle)" + "Stranger is typing");
                    break;

                case "waiting":
                    break;

                case "connected":
                    Paired = true;
                    player.Message(Color.Olive + "(Omegle)Found a new stranger!");
                    break;
                case "null":
                    Disconnect();
                    break;

                    //this was just laziness.
                default:
                        string message = en.Value.ToString().Replace("\"[[gotmessage\", ", "").Replace("]]", "");
                        player.Message(Color.Olive + "(Omegle)Stranger: " + message);
                        break;
                case "strangerDisconnected":
                    Paired = false;
                    player.Message(Color.Olive + "(Omegle)The stranger has disconnected.");
                    break;
            }

        }

    }

    private Hashtable ParseJSON(string json)
    {
        Hashtable result = new System.Collections.Hashtable();

        // [["connected"], ["gotMessage", "lol"]]
        json = json.Remove(0, 1);
        json = json.Remove(json.Length - 1, 1);
        string[] json_messages = json.Split(']');

        foreach (string message in json_messages)
        {
            string m = message;

            if (m == "")
                break;

            if (message.Substring(0, 2) == ", ")
                m = message.Remove(0, 2);

            m.Remove(0, 1); // Remove ["

            string[] split = m.Split(',');
            string key = "", value = "";

            if (split.Length == 1)
            {
                key = split[0];

                // Strip off " surrounding key
                key = key.Remove(0, 2);
                key = key.Remove(key.Length - 1, 1);
            }

            if (split.Length == 2)
            {
                value = split[1].Remove(0, 1);

                // Strip off " surrounding value
                value = value.Remove(0, 1);
                value = value.Remove(value.Length - 1, 1);
            }

            try
            {
                result.Add(key, value);
            }
            catch { }
        }

        return result;
    }

    private string Request(string url, string parameters)
    {
        try
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);
            request.Method = "POST";
            request.Host = "omegle.com";

            byte[] byteArray = Encoding.UTF8.GetBytes(parameters);

            request.ContentType = "application/x-www-form-urlencoded";
            request.ContentLength = byteArray.Length;

            Stream dataStream = request.GetRequestStream();
            dataStream.Write(byteArray, 0, byteArray.Length);
            dataStream.Close();

            WebResponse response = request.GetResponse();

            dataStream = response.GetResponseStream();
            StreamReader reader = new StreamReader(dataStream);
            string responseFromServer = reader.ReadToEnd();

            reader.Close();
            reader.Dispose();
            dataStream.Close();
            response.Close();
            return responseFromServer;
        }
        catch
        {
            player.Message(Color.Olive + "(Omegle)" + "&WFailed to send the request to Omegle.com :(");
            Disconnect();
            return String.Empty;
        }
    }
}


2. Make an instance of Omegle Chat, per player
in player.cs:
Show
Code:
 public OmegleBot OmBot;


3. Add the command - usually in chat commands
Show
Code:
static readonly CommandDescriptor CdOmegle = new CommandDescriptor
        {
            Name = "Om",
            Category = CommandCategory.Chat,
            IsConsoleSafe = false,
            Permissions = new[] { Permission.Chat },
            Usage = "/Om Message",
            Help = "Yes, help.",
            Handler = OmHandler
        };

        static void OmHandler(Player player, Command cmd)
        {
            if (player.OmBot == null)
            {
                player.OmBot = new OmegleBot(player);
            }
            else
            {
                string Message = cmd.NextAll();
                if (Message == null)
                {
                    player.Message("Your message cannot be zero length");
                    return;
                }
                player.OmBot.Say(Message);
            }
        }

_________________
You cannot use certain BBCodes: [img].


Top
Offline Profile  
Reply with quote  
 Post subject: Re: The worst fCraft mod that exists.
PostPosted: July 15th, 2012, 6:55 pm 
User avatar

Joined: June 28th, 2012, 10:58 pm
Posts: 118
Location: Indiana
I'm by no means an expert with C#.... What exactly does this do?

_________________
<FCB2> carlos32123: permissiin to deny the deny of the permission of departure denied


Top
Offline Profile  
Reply with quote  
 Post subject: Re: The worst fCraft mod that exists.
PostPosted: July 15th, 2012, 7:12 pm 
SupOP

Joined: June 24th, 2011, 10:27 pm
Posts: 314
phonebookguy wrote:
I'm by no means an expert with C#.... What exactly does this do?

It allows you to chat on omegle in fcraft. I don't see why this is the worst mod though.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: The worst fCraft mod that exists.
PostPosted: July 15th, 2012, 7:13 pm 
User avatar

Joined: June 28th, 2012, 10:58 pm
Posts: 118
Location: Indiana
what is "omegle"?

_________________
<FCB2> carlos32123: permissiin to deny the deny of the permission of departure denied


Top
Offline Profile  
Reply with quote  
 Post subject: Re: The worst fCraft mod that exists.
PostPosted: July 15th, 2012, 7:14 pm 
SupOP

Joined: June 24th, 2011, 10:27 pm
Posts: 314
phonebookguy wrote:
what is "omegle"?

A website that puts you in a conversation with a random person.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: The worst fCraft mod that exists.
PostPosted: July 15th, 2012, 7:17 pm 
User avatar

Joined: October 20th, 2011, 9:20 am
Posts: 220
Location: Subnet
Dear Celestia why would you make such a thing? This is horrifying!

_________________
A = {x ∈ P(U) | x ∉ x}

Show
Mods:
  1. /Su - Allows players to temporarily become a different rank
  2. /Snap - Like /Line but only draws straight or diagonal lines.
  3. pre-0.630 skip/none block


Top
Offline Profile  
Reply with quote  
 Post subject: Re: The worst fCraft mod that exists.
PostPosted: July 15th, 2012, 7:29 pm 

Joined: August 21st, 2011, 6:31 am
Posts: 280
Location: United Kingdom
Reminded: The terms of this command are the same as omegle.com:

Quote:
Do not behave inappropriately on Omegle, and understand that human behavior is fundamentally uncontrollable. The people you encounter on Omegle may not behave appropriately. Use Omegle at your own peril. Do not use Omegle if you are under 13, or without a parent/guardian's permission if you are under 18. Disconnect if anyone makes you feel uncomfortable. OMEGLE IS NOT PROVIDED WITH ANY WARRANTY, EXPRESS OR IMPLIED, AND THE OWNER OF OMEGLE DOES NOT ACCEPT LIABILITY OR RESPONSIBILITY FOR ANY LOSS OR DAMAGE OF ANY KIND ARISING DIRECTLY OR INDIRECTLY FROM THE USE OF OMEGLE, except to the minimum extent that warranty or acceptance of liability are required by law. Please read Omegle's privacy policy.

_________________
You cannot use certain BBCodes: [img].


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


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

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net