# Somnia (ENG)

## ⚙️ Installation

\
**Requirements:**

Python version 3.11.6 - 3.11.11

**Downloading:**

1 | Clone a repository

```bash
git clone https://github.com/neLNABR/Somnia-Auto.git
cd Somnia
```

2 | Create a virtual environment

```bash
python -m venv venv
venv\Scripts\activate
```

3 | Install dependencies

```bash
pip install -r requirements.txt
```

4 | Start (after customization)

```
python main.py
```

## &#x20;📁 Preparation (data folder)

Here you can find all user's data necessary for work.

`private_keys.txt` - private keys from wallets. 1 line = 1 key.

`proxies.txt` - proxies. 1 line = 1 proxy, or if there are less proxies than accounts, then they will be repeated one after another to be enough for all accounts. The format of proxies is `user:pass@ip:port.` ONLY HTTP proxies are supported.

`discord_tokens.txt -`discord tokens. 1 line = 1 token.

`twitter_tokens.txt` - tweeter tokens. 1 line = 1 token. If there are more tokens than private keys, the bot will replace the non working twitter token with one of the extra ones and overwrite it in the file, provided REPLACE\_FAILED\_TWITTER\_ACCOUNT: true is enabled in the config.

`random_message_quills.txt` - text for `quills_chat` messages. You can add any sms at your discretion (recommended).

## 📝 Config.yaml

```
SETTINGS

THREADS: 1 - number of threads/single accounts the bot will do.

ATTEMPTS: 5 - on errors, how many times the bot will attempt to perform the action.

ACCOUNTS_RANGE: [0, 0] - the range of accounts to run. 
Example: [3, 6] means the bot will execute accounts starting from the third to the sixth.
The count starts from 1.

EXACT_ACCOUNTS_TO_USE: [] - !Works only if ACCOUNTS_RANGE: [0, 0].
Example: [1, 3, 7] which means the bot will only execute accounts 1 3 and 7.

SHUFFLE_WALLETS: false - shuffle accounts before each run or not.
If true, the bot will execute the accounts in random order each time.

PAUSE_BETWEEN_ATTEMPTS: [0, 0] - pause in seconds between attempts to perform a single action.
Example: [3, 10] - the pause will be 3 to 10 seconds random.

PAUSE_BETWEEN_SWAPS: [0, 0] - pause in seconds between sending transactions.
Example: [3, 10] - the pause will be 3 to 10 seconds random.

RANDOM_PAUSE_BETWEEN_ACCOUNTS: [0, 0] - pause in seconds between accounts.
Example: [3, 10] - the pause will be 3 to 10 seconds random.

RANDOM_PAUSE_BETWEEN_ACTIONS: [0, 0] - pause in seconds between tasks/tasks.
Example: [3, 10] - the pause will be from 3 to 10 seconds random.

RANDOM_INITIALIZATION_PAUSE: [0, 0] - pause in seconds before each account starts.
For example you have 10 threads and the pause is [5, 60]
So each account will count from 5 seconds to a minute before starting.
This is used so that all accounts do not start at the same time.

SEND_TELEGRAM_LOGS: false - whether to send logs about functions to Telegram or not. true/false.

TELEGRAM_BOT_TOKEN: "12317283:lskjalsdfasdfasd-sdfadfasd" - token of the Telegram bot created in @BotFather

TELEGRAM_USERS_IDS: [235123432] - IDs of telegram users, to whom to send logs.
ATTENTION! The bot sends only to users in a message, not in chats.
You can get your account id in the tag bot @GetChatID_IL_BOT.
```

```
FLOW

SKIP_FAILED_TASKS: false - skip uncompleted tasks or not.
If false, then the bot will stop working if it failed to complete some task.
If true, then the bot will skip the task and start doing the next one.
```

```
RPCS

SOMNIA: ["https://dream-rpc.somnia.network"] - RPC for the network.
You can specify more than one, the bot will use the one that works.
```

```
OTHERS

SKIP_SSL_VERIFICATION: true - skip ssl verification.
If you see errors related to SSL in the console, try to set false.

USE_PROXY_FOR_RPC: true - whether to use proxy for RPC.
```

```
SOMNIA_NETWORK

>>> SOMNIA_SWAPS:
BALANCE_PERCENT_TO_SWAP: [5, 10] - what percentage of balance to use for swaps.

NUMBER_OF_SWAPS: [1, 3] - how many swaps to make, random number from and to.


>>> SOMNIA_TOKEN_SENDER
Used for "send_tokens" function.
BALANCE_PERCENT_TO_SEND: [5, 10] - what percentage of the balance to use to send.

NUMBER_OF_SENDS: [1, 1] - the number of transfers/transactions per run. From and to is a random number.
```

\
The config can be customized either through a text document in the **config.yaml** file or through the web interface (example in the screenshot below).

In case the web config from the menu doesn't work for some reason, you can always edit it manually in the **config.yaml** file..

To start the web interface you need to run the bot with the command python main.py and select the menu item **\[2] Edit config.**\
After that the bot will launch the config at URL <http://127.0.0.1:3456>, which you can open in any browser on your PC and customize the config from there. By default, the bot itself opens a web browser with the desired URL.\
**This config and website is launched and runs locally on your PC.**

<figure><img src="https://812398210-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwLtnARLju2IbVpsYaVuQ%2Fuploads%2FUUJVNgfs18Bi4NjyhD7F%2Fimage.png?alt=media&#x26;token=77d52b7e-b6af-4906-9af2-484e81f7894b" alt=""><figcaption></figcaption></figure>

After configuring the functions in the config, click the Save Configuration button in the top right corner of the page.

To exit the config, go back to the console and press CTRL + C several times, or just close the console.

## 💾 Database

All work in the bot is managed directly through the database. The database is created and stored in the /data folder under the name accounts.db. You can open it manually through special programs for SQL like DB Browser for SQLite.

To start working and create a database you need to run the bot with the command python main.py and select the menu item **\[3] 💾 Database actions**. Next I will describe each of the functions.

\[1] 🗑 **Create/Reset Database.** The most basic function that creates a new database or overwrites an existing one. It should be used when you start the bot for the first time, or when you want to overwrite wallets, proxies, or tasks for wallets.

\[2] ➕ **Generate New Tasks for Completed Wallets.** Used to generate new tasks for wallets that have completed their previous tasks. Example: it may be that some of your wallets have completed all the actions, but some of them still have unfinished tasks. In order not to overwrite ALL tasks and give part of the wallets a chance to finish their chain, you can select this feature and it will update tasks only for wallets that don't already have tasks.

\[3] 📊 **Show Database Contents.** Displays the contents of the database. Wallets, proxies, tasks, etc.

\[4] 🔄 **Regenerate Tasks for All Wallets.** Regenerates tasks for ALL wallets in the database.

\[5] 📝 **Add Wallets to Database.** Adds new wallets to the database. For example, you have 10 wallets in your database, you insert new wallets in data/private\_keys.txt and want to add them to the database. To avoid overwriting the entire database, you can use this function and it will simply add the new wallets to the database.

## ▶️ Usage

Before launching the bot, you need to open the **tasks.py** file in the main project folder and there customize the order of actions as shown in the example.

After that you can run the bot with the command python main.py In the menu you should select 3 and then the database settings will be opened. **For the first run press 1 (Create/Reset Database)** and the bot creates a database in the data folder. For each key will be generated routes of actions. Also in this menu you will be able to look at the remaining tasks, recreate the database, etc.

**Now you can exit the menu with button 6 and start the bot - 1.**

## ✅ Tasks

**Instructions on how to switch modules in the bot**

In order to switch a module, you need to find a file called tasks.py in the bot folder, open it with a code editor or a normal notepad, in the file you will see the TASKS variable that looks like this:

<figure><img src="https://812398210-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwLtnARLju2IbVpsYaVuQ%2Fuploads%2FJ6vabsud4DKqeGWhvoTt%2Fimage.png?alt=media&#x26;token=3d0b09ed-7aca-43cc-91ce-7823d5b0af3a" alt=""><figcaption></figcaption></figure>

**TASKS This is a list of presets, a preset is a list of modules that the bot will run.**

An example of a preset with a module inside it:

<figure><img src="https://812398210-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwLtnARLju2IbVpsYaVuQ%2Fuploads%2FrMXRgc2ZuCta3BIo1bfC%2Fimage.png?alt=media&#x26;token=c13d1501-c341-49fe-9110-b193b8f00052" alt=""><figcaption></figcaption></figure>

As you can see FAUCET is just the name of the preset, which can be anything you want, and inside it is the “faucet” module, which is responsible for starting the faucet.

You can create your own preset just by writing any name for example:

<figure><img src="https://812398210-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwLtnARLju2IbVpsYaVuQ%2Fuploads%2FTPDQ79lCN8NjRF43lvfg%2Fimage.png?alt=media&#x26;token=c47adf0c-dcf6-43e2-a7f6-2fb8ac8e7206" alt=""><figcaption></figcaption></figure>

Inside it you can add which modules you want to use example dusted, total:

<figure><img src="https://812398210-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwLtnARLju2IbVpsYaVuQ%2Fuploads%2FzYRPYDjsMDcY6SrOOeX9%2Fimage.png?alt=media&#x26;token=7e7d49c9-3e56-4690-bfa3-4529a34d45d6" alt=""><figcaption></figcaption></figure>

Then to run a given preset, you copy its name and paste it into TASKS, total:

<figure><img src="https://812398210-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwLtnARLju2IbVpsYaVuQ%2Fuploads%2FcxJU34UzCt0sT3u0PKV0%2Fimage.png?alt=media&#x26;token=48ffa2ab-5abe-4a33-8616-c7e0adf7b2b0" alt=""><figcaption></figcaption></figure>

You can use different types of randomization in the preset. For example, square brackets will mean that the bot will choose one module from all the modules inside them, in our case either dusted or ambient

<figure><img src="https://812398210-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwLtnARLju2IbVpsYaVuQ%2Fuploads%2Fza8NVZQonX31E3m6N8Oi%2Fimage.png?alt=media&#x26;token=02ae0d5b-5077-490a-a162-b3cd329e7ce8" alt=""><figcaption></figcaption></figure>

The parentheses mean that the bot will execute all the modules that are inside them, but in random order

<figure><img src="https://812398210-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwLtnARLju2IbVpsYaVuQ%2Fuploads%2FaxgXs2t6HrCabQ6Xyjon%2Fimage.png?alt=media&#x26;token=80f2eb6c-cba2-43dd-afc4-1960de9a3653" alt=""><figcaption></figcaption></figure>

You can create as many lines as you want, just don't forget to put a comma in it
