[BONUS S1][GUIDE]Using all “Dictionary” type functions with Openbullet 2

Hello,
I will show you a simple and concrete example of each Dictionary function that we can have in Openbullet 2 to know how to use them being that this block has 3 sub-blocks, I allow myself here to give you a written tutorial.

So meet here :
the first thing we are going to do and first create our dictionary
Capture3
Once that’s done we meet here :

Once here we would like for example to add values.
Then we come here :
(http://localhost:5000/docs/lolicode/blocks)
Capture4
What interests us is therefore the line concerning the dictionary

Dictionary of Strings (e.g. {("one", "first"), ("two", "second"), ("three", "third")})

Then we go to the lolicode part we have this:
Capture4
We will therefore take the example given to us and then try it
Capture4
We get this :
Capture4
Everything went as planned then let’s take a look at the side of the stacker
As you can see this gives you the method to be able to add values ​​to the dictionary


given that the dictionary works by a key, value association
So the syntax for add values on the dictionary on stacker is :

Key:Value

As show above in the screenshot once we know that we will be able to work on our dictionary.


So meet here :
Capture
Then,

We will start with “Add Key Value Pair” block so we meet here :
Capture4

The first thing to do is to select the dictionary on which you want to act in my case it’s “MyDictionary”.
and now we will add a key and a value.

As a reminder :
(key):(value)
one: first
(key):(value)
two: second
(key):(value)
three: third

So we will add for example :
(key):(value)
four:the fourth
So on the block it will be like that :


So the latter has been added if for example I would like to consult the elements in my dictionary
To do this you will add this function to Openbullet its will save us from repeating the code :

void IseeMyDictionary()
{
foreach(var tem in MyDictionary)
CLOG BallBlue tem.Key + "->" +  tem.Value
}

Then we’ll call it that :


As you can see with the CLOG we can see that our element has been added

Now let’s try the GetKey block after adding it we end up like this :


As you know it is necessary to inform the dictionary you know its now
if for example i want the key of “third” value i will do like that :

As you can see it works very well in lists with a lot of data

Now the “Remove by Key” block :


As you know we fill in the dictionary then now we will provide a key for this we will simply call the variable “getKeyOutput” :
As you can see Openbullet informs us that the item has been removed

To check this we will use our create function above :

As you can see it has been successfully removed.

Here is the code to try :

void IseeMyDictionary()
{
foreach(var tem in MyDictionary)
CLOG BallBlue tem.Key + "->" +  tem.Value
}

BLOCK:ConstantDictionary
  value = {("one", "first"), ("two", "second"), ("three", "third")}
  => VAR @MyDictionary
ENDBLOCK

BLOCK:AddKeyValuePair
  dictionary = @MyDictionary
  key = "four"
  value = "the fourth"
ENDBLOCK

IseeMyDictionary();

BLOCK:GetKey
  dictionary = @MyDictionary
  value = "third"
  => VAR @getKeyOutput
ENDBLOCK

BLOCK:RemoveByKey
  dictionary = @MyDictionary
  key = @getKeyOutput
ENDBLOCK

//Console.WriteLine(getKeyOutput);

IseeMyDictionary();

Hoping that you have understood the essentials for what would like to go further I have here used the json site that I had used in a previous tutorial on parse in order to understand data management with the dictionary I made here a configuration that allows to understand it.

Target : https://jsonplaceholder.typicode.com

Please note that the following data is absolutely false! :

void Dico(List<string> B, Dictionary<List<string>, List<string>> C, string cle = "")
{
    for (int i = 0; i < B.Count; i++)
    {
      foreach (var e in C)
      {
      e.Key.ToString();
      if (e.Key.Contains(cle))
      {
      e.Key.Remove(cle);
      }
       Console.WriteLine(e.Key[i] + "->" + e.Value[i]);
      }
    }

}

Dictionary<List<string>, List<string>> mailId = new Dictionary<List<string>, List<string>>();
BLOCK:HttpRequest
  url = "https://jsonplaceholder.typicode.com/comments"
  TYPE:STANDARD
  $""
  "application/x-www-form-urlencoded"
ENDBLOCK

BLOCK:Parse
  input = @data.SOURCE
  jToken = "[*].email"
  RECURSIVE
  MODE:Json
  => VAR @A
ENDBLOCK

BLOCK:Parse
  input = @data.SOURCE
  jToken = "[*].id"
  RECURSIVE
  MODE:Json
  => VAR @B
ENDBLOCK
Console.Clear();
mailId.Add(A,B);

//Thread.Sleep(2000);
string kill = "[email protected]"; //Here
CLOG DarkPastelGreen "Key && Value slain : " + kill
Dico(A,mailId,kill);

it stores the list data and you can also add an element to kill with the optional parameter that I added to the function

For example i have my list of FAKE data with ids if i want to kill an item from the dictionary i will do like that :
if i want to kill “[email protected]>12” i will put “[email protected]” in my string var like that :

https://share.vidyard.com/watch/w4HVunF9pXDPQnPRHZoFU8

WannaCry

5 Likes