Gmail console App C# - c#

I'm trying to figure out why I am getting the error "Cannot assign to 'loggedIn' because it is a method group" within my menu method. Any help will be appreciated. Code is below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GmailClient
{
class Program
{
static string userName="";
static string passWord="";
public static bool loggedIn()
{
if (userName == "")
{
if (passWord == "")
{
return false;
}
else
{
return false;
}
}
else
{
return true;
}
}
static void Main(string[] args)
{
}
public static void menu()
{
Console.WriteLine("Loading menu.");
if ( loggedIn = false)
{
Console.WriteLine("__________Menu__________");
Console.WriteLine("1) Enter your Gmail credentials");
Console.WriteLine("2) Exit the Console");
Console.WriteLine("________________________");
Console.WriteLine("What do you want to do?");
int userchoice = Convert.ToInt32(Console.ReadLine());
if (userchoice == 1)
{
credentials();
}
else if (userchoice == 2)
{
Console.WriteLine("Hope to see you soon!");
Console.ReadKey();
Environment.Exit(0);
}
}
else if (loggedIn = true)
{
Console.WriteLine("__________Menu__________");
Console.WriteLine("1) Enter your Gmail credentials");
Console.WriteLine("2) Check your inbox");
Console.WriteLine("3) Send an e-mail");
Console.WriteLine("4) Exit the Console");
Console.WriteLine("________________________");
Console.WriteLine("What do you want to do?");
int userchoice = Convert.ToInt32(Console.ReadLine());
if (userchoice == 1)
{
credentials();
}
else if (userchoice ==2)
{
getMail();
}
else if (userchoice ==3)
{
sendMail();
}
else if (userchoice ==4)
{
Console.WriteLine("Hope to see you soon!");
Console.ReadKey();
Environment.Exit(0);
}
}
}
public static void credentials()
{
Console.WriteLine("Enter your Gmail address:");
userName = Console.ReadLine();
Console.WriteLine("Enter your Gmail password:");
passWord = Console.ReadLine();
}
public static void getMail()
{
Console.WriteLine("Loading inbox messages");
}
public static void sendMail()
{
Console.WriteLine("Under Construction");
}
}
}

Change if ( loggedIn = false) to if (!loggedIn()) and if (loggedIn = true) to if (loggedIn()).
Also, when using an if condition check, don't use a single equals =. = is assignment (e.g., You are assigning a value to a variable variable = "value"). Use double equals == when comparing (e.g., if (variable == true) ...).
In the case of your code, loggedIn is defined as a method/function. Your code was treating it as a property/variable.

Related

How to create a counter that counts unrighteous inputs

static void MainWindow()
{
Console.Clear();
Console.WriteLine("Menu");
Console.WriteLine("");
Console.WriteLine("1. Information");
Console.WriteLine("2. Contact");
Console.WriteLine("3. Extra");
Console.WriteLine("q. Exit");
string myOptions;
myOptions = Console.ReadLine();
switch (myOptions)
{
case "1":
Information();
break;
case "2":
Contact();
break;
case "3":
Extra();
break;
case "q":
Exit();
break;
default:
Console.Clear();
Console.WriteLine("Input is wrong");
Console.ReadKey();
MainWindow();
break;
}
Console.ReadLine();
}
I make a console menu and I need a counter that will count wrong entries. if it hits 5 times, the user is thrown back to the main menu.
I was trying to do this with while statement but it didnt work for me.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace ConsoleApp3
{
internal class Program
{
private static readonly IDictionary<char, Action> InputDictionary = new Dictionary<char, Action>
{
{ '1', Information },
{ '2', Contact },
{ '3', Extra },
{ 'q', Exit },
};
static void Main()
{
MainWindow();
}
private static void MainWindow()
{
var inputWasProcessed = false;
while (inputWasProcessed == false)
{
DisplayMainMenu();
var wrongEntries = 0;
while (wrongEntries < 5)
{
if (0 < wrongEntries)
{
Console.WriteLine($"Wrong Entries: {wrongEntries}");
}
inputWasProcessed = ProcessUserInput(Console.ReadKey().KeyChar);
if (inputWasProcessed == false)
{
wrongEntries++;
}
else
{
break;
}
}
}
Console.ReadLine();
}
private static void DisplayMainMenu()
{
Console.Clear();
Console.WriteLine("Menu");
Console.WriteLine();
Console.WriteLine("1. Information");
Console.WriteLine("2. Contact");
Console.WriteLine("3. Extra");
Console.WriteLine("q. Exit");
}
private static bool ProcessUserInput(char selectedOption)
{
if (InputDictionary.TryGetValue(selectedOption, out var action))
{
Console.WriteLine();
Console.WriteLine();
action.Invoke();
return true;
}
Console.Clear();
Console.WriteLine("Input is wrong.");
Console.WriteLine("Try again.");
return false;
}
private static void Information()
{
Console.WriteLine($"{GetCurrentMethod()} implementation.");
}
private static void Contact()
{
Console.WriteLine($"{GetCurrentMethod()} implementation.");
}
private static void Extra()
{
Console.WriteLine($"{GetCurrentMethod()} implementation.");
}
private static void Exit()
{
Console.WriteLine($"{GetCurrentMethod()} implementation.");
}
#region For Demonstration Purposes Only
[MethodImpl(MethodImplOptions.NoInlining)]
private static string GetCurrentMethod() // https://stackoverflow.com/a/2652481/109941
{
var st = new StackTrace();
var sf = st.GetFrame(1);
return sf.GetMethod().Name;
}
#endregion
}
}

I am getting 6 errors, it looks like all of them are in IEnumerators [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 months ago.
Improve this question
Here are the errors.
I am creating a firebase login and sign up unity project.
I have commented some of the lines because I havent programmed it yet. I am following this tutorial : https://www.youtube.com/watch?v=9-ZS7-I_CfQ
I have 2 scripts, firebaseManager and authUI manager.
Here is my firebaseManager script:
using UnityEngine;
using System.Collections;
using Firebase;
using Firebase.Auth;
using TMPro;
public class FirebaseManager : MonoBehaviour
{
public static FirebaseManager instance;
[Header("Firebase")]
public FirebaseAuth auth;
public FirebaseUser user;
[Space(5f)]
[Header("Login References")]
[SerializeField]
private TMP_InputField loginEmail;
[SerializeField]
private TMP_InputField loginPassword;
[SerializeField]
private TMP_Text loginOutputText;
[Space(5f)]
[Header("Register References")]
[SerializeField]
private TMP_InputField registerUsername;
[SerializeField]
private TMP_InputField registerEmail;
[SerializeField]
private TMP_InputField registerPassword;
[SerializeField]
private TMP_InputField registerConfirmPassword;
[SerializeField]
private TMP_Text registerOutputText;
private void Awake()
{
DontDestroyOnLoad(gameObject);
if (instance == null)
{
instance = this;
}
else if (instance != this)
{
Destroy(instance.gameObject);
instance = this;
}
}
private void Start()
{
StartCoroutine(CheckAndFixDependancies());
}
private IEnumerator CheckAndFixDependancies()
{
var checkAndFixDependanciesTask = FirebaseApp.CheckAndFixDependenciesAsync();
yield return new WaitUntil(predicate: () => checkAndFixDependanciesTask.IsCompleted);
var dependancyResult = checkAndFixDependanciesTask.Result;
if (dependancyResult == DependencyStatus.Available)
{
InitializeFirebase();
}
else
{
Debug.LogError($"Could not resolve all firebase dependancies: {dependancyResult}");
}
}
private void InitializeFirebase()
{
auth = FirebaseAuth.DefaultInstance;
StartCoroutine(CheckAutoLogin());
auth.StateChanged += AuthStateChanged;
AuthStateChanged(this, null);
}
private IEnumerator CheckAutoLogin()
{
yield return new WaitForEndOfFrame();
if (user != null)
{
var reloadUserTask = user.ReloadAsync();
yield return new WaitUntil(predicate: () => reloadUserTask.IsCompleted);
AutoLogin();
}
else
{
AuthUIManager.instance.LoginScreen();
}
}
private void AutoLogin()
{
if (user != null)
{
if (user.IsEmailVerified)
{
GameManager.instance.ChangeScene(1);
}
else
{
StartCoroutine(SendVerificationEmail());
}
}
else
{
AuthUIManager.instance.LoginScreen();
}
}
private void AuthStateChanged(object sender, System.EventArgs eventArgs)
{
if (auth.CurrentUser != user)
{
bool signedIn = user != auth.CurrentUser && auth.CurrentUser != null;
if (!signedIn && user != null)
{
Debug.Log("Signed Out");
// Write signed out user code here
}
user = auth.CurrentUser;
if (signedIn)
{
Debug.Log($"Signed In: {user.DisplayName}");
}
}
}
public void ClearOutputs()
{
loginOutputText.text = "";
registerOutputText.text = "";
}
public void LoginButton()
{
StartCoroutine(LoginLogic(loginEmail.text, loginPassword.text));
}
public void RegisterButton()
{
StartCoroutine(RegisterLogic(registerUsername.text, registerEmail.text, registerPassword.text, registerConfirmPassword.text));
}
private IEnumerator LoginLogic(string _email, string _password)
{
Credential credential = EmailAuthProvider.GetCredential(_email, _password);
var loginTask = auth.SignInWithCredentialAsync(credential);
yield return new WaitUntil(predicate: () => loginTask.IsCompleted);
if (loginTask.Exception != null)
{
FirebaseException firebaseException = (FirebaseException)loginTask.Exception.GetBaseException();
AuthError error = (AuthError)firebaseException.ErrorCode;
string output = "Unknown Error, Please Try Again";
switch (error)
{
case AuthError.MissingEmail:
output = "Please Enter Your Email";
break;
case AuthError.MissingPassword:
output = "Please Enter Your Password";
break;
case AuthError.InvalidEmail:
output = "Invalid Email";
break;
case AuthError.WrongPassword:
output = "Incorrect Password";
break;
case AuthError.UserNotFound:
output = "Account Does Not Exist";
break;
}
loginOutputText.text = output;
}
else
{
if (user.IsEmailVerified)
{
yield return new WaitForSeconds(1f);
GameManager.instance.ChangeScene(1);
}
else
{
StartCoroutine(SendVerificationEmail());
}
}
}
private IEnumerator RegisterLogic(string _username, string _email, string _password, string _confirmPassword)
{
if (_username == "")
{
registerOutputText.text = "Please Enter A Username";
}
else if (_password != _confirmPassword)
{
registerOutputText.text = "Passwords Do Not Match!";
}
// else if (_username.ToLower() == "bad word")
// {
// registerOutputText.text = "That Username Is Innapropriate";
// }
else
{
var registerTask = auth.CreateUserWithEmailAndPasswordAsync(_email, _password);
yield return new WaitUntil(predicate: () => registerTask.IsCompleted);
if (registerTask.Exception != null)
{
FirebaseException firebaseException = (FirebaseException)registerTask.Exception.GetBaseException();
AuthError error = (AuthError)firebaseException.ErrorCode;
string output = "Unknown Error, Please Try Again";
switch (error)
{
case AuthError.InvalidEmail:
output = "Invalid Email";
break;
case AuthError.EmailAlreadyInUse:
output = "Email Is Already In Use";
break;
case AuthError.WeakPassword:
output = "Weak Password. Please include capital letters, numbers and special symbols.";
break;
case AuthError.MissingEmail:
output = "Please Enter Your Email";
break;
case AuthError.MissingPassword:
output = "Please Enter Your Password";
break;
}
registerOutputText.text = output;
}
else
{
UserProfile profile = new UserProfile
{
DisplayName = _username,
PhotoUrl = new System.Uri("https://t4.ftcdn.net/jpg/02/29/75/83/360_F_229758328_7x8jwCwjtBMmC6rgFzLFhZoEpLobB6L8.jpg");
};
var defaultUserTask = user.UpdateUserProfileAsync(profile);
yield return new WaitUntil(predicate: () => defaultUserTask.IsCompleted);
if (defaultUserTask.Exception != null)
{
user.DeleteAsync();
FirebaseException firebaseException = (FirebaseException)defaultUserTask.Exception.GetBaseException();
AuthError error = (AuthError)firebaseException.ErrorCode;
string output = "Unknown Error, Please Try Again";
switch (error)
{
case AuthError.Cancelled:
output = "Update User Cancelled";
break;
case AuthError.SessionExpired:
output = "Session Expired";
break;
}
registerOutputText.text = output;
}
else
{
Debug.Log($"Firebase User Created Successfuly: {user.DisplayName} ({user.UserId})");
StartCoroutine(SendVerificationEmail());
}
}
}
}
private IEnumerator SendVerificationEmail()
{
if (user != null)
{
var emailTask = user.SendEmailVerificationAsync();
yield return new WaitUntil(predicate: () => emailTask.IsCompleted);
if (emailTask.Exception != null)
{
FirebaseException firebaseException = (FirebaseException)emailTask.Exception.GetBaseException();
AuthError error = (AuthError)firebaseException.ErrorCode;
string output = "Unkown Error, Try Again!";
switch (error)
{
case AuthError.Cancelled:
output = "Verification Task Was Cancelled";
break;
case AuthError.InvalidRecipientEmail:
output = "Invalid Email";
break;
case AuthError.TooManyRequests:
output = "Too Many Requests";
break;
}
AuthUIManager.instance.AwaitVerification(false, user.Email, output);
}
else
{
AuthUIManager.instance.AwaitVerification(true, user.Email, null);
Debug.Log("Email Sent Successfully");
}
}
}
public void UpdateProfilePicture(string _newPfpURL)
{
StartCoroutine(UpdateProfilePictureLogic(_newPfpURL));
}
private IEnumerator UpdateProfilePictureLogic(string _newPfpURL)
{
if (user != null)
{
UserProfile profile = new UserProfile();
try
{
UserProfile _profile = new UserProfile
{
PhotoUrl = new System.Uri(_newPfpURL),
};
profile = _profile;
}
catch
{
// LobbyManager.instance.Output("Error Fetching Image, Make Sure Your Link Is Valid!");
yield break;
}
var pfpTask = user.UpdateProfileAsync(profile);
yield return new WaitUntil(predicate: () => pfpTask.IsCompleted);
if (pfpTask.Exception != null)
{
Debug.LogError($"Updating Profile Picture was unsuccessful: {pfpTask.Exception}");
}
else
{
LobbyManager.instance.ChangePfpSuccess();
Debug.Log("Profile Image Updated Successfully");
}
}
}
}
Here is my AuthUIManager script:
using TMPro;
using UnityEngine;
public class AuthUIManager : MonoBehaviour
{
public static AuthUIManager instance;
[Header("References")]
[SerializeField]
private GameObject checkingForAccountUI;
[SerializeField]
private GameObject loginUI;
[SerializeField]
private GameObject registerUI;
[SerializeField]
private GameObject verifyEmailUI;
[SerializeField]
private TMP_Text verifyEmailText;
private void Awake()
{
if (instance == null)
{
instance = this;
}
else if (instance != this)
{
Destroy(gameObject);
}
}
private void ClearUI()
{
loginUI.SetActive(false);
registerUI.SetActive(false);
verifyEmailUI.SetActive(false);
FirebaseManager.instance.ClearOutputs();
checkingForAccountUI.SetActive(false);
}
public void LoginScreen()
{
ClearUI();
loginUI.SetActive(true);
}
public void RegisterScreen()
{
ClearUI();
registerUI.SetActive(true);
}
public void AwaitVerification(bool _emailSent, string _email, string _output)
{
ClearUI();
verifyEmailUI.SetActive(true);
if (_emailSent)
{
verifyEmailText.text = $"Sent Email!\nPleaseVerify {_email}";
}
else
{
verifyEmailText.text = $"Email Not Sent: {_output}\nPlease Verify {_email}";
}
}
}
In your FirebaseManager script you've put a semicolon ; at the end of line 264 instead of a comma ,.
Additionally you've put a desperate closed curly bracket } at the end of the file, which is not necessary.
All other errors basically originate from these two problems.

How to set default capacity for lists

So I tried making a todo list app making use of for loops and nested if statements. I created a function for adding tasks deleting and showing the whole list, but when I run the code I only get to input a task once even though I set the list capacity to what the user wants.
This is my code and what I've tried so far:
namespace mycsharpproject1
{
class Program
{
static void Main(string[] args)
{
List<string> todo = new List<string>();
void addt()
{
Console.WriteLine("enter task to be add");
todo.Add(Console.ReadLine());
}
void removet()
{
Console.WriteLine("enter task to be removed");
todo.Remove(Console.ReadLine());
}
void showt()
{
Console.WriteLine(todo);
}
string user_input = Console.ReadLine();
if (user_input == "r")
{
if (todo.Count == 0)
{
Console.WriteLine("you have no tasks in your list");
}
else
{
removet();
}
}
if (user_input == "a")
{
int i= Convert.ToInt32(Console.ReadLine());
if (i == todo.Capacity)
{
addt();
}
}
if (user_input == "s")
{
showt();
}
Console.ReadKey();
}
}
}
Modified your code a little bit. It's because there's no loop in your code, it only runs once. And the last like Console.ReadKey just reads an input and exits.
And the list doesn't need a capacity to be set if you exactly need that amount of item in yoru list. So, try this one.
class Program
{
static List<string> todo = null;
static void Main(string[] args)
{
todo = new List<string>();
while (true)
{
string user_input = Console.ReadLine();
if (user_input == "r")
{
if (todo.Count == 0)
{
Console.WriteLine("you have no tasks in your list");
}
else
{
removet();
}
}
if (user_input == "a")
{
addt();
}
if (user_input == "s")
{
showt();
}
}
}
static void addt()
{
Console.WriteLine("enter task to be add");
todo.Add(Console.ReadLine());
}
static void removet()
{
Console.WriteLine("enter task to be removed");
todo.Remove(Console.ReadLine());
}
static void showt()
{
todo.ForEach(q => Console.WriteLine(q));
}
}

Can a boolean be asked?

So Im new into coding. And my question is, can u make someone type if a question is yes or no and if it its true using, the swith statement say its correct. But I want to make it that the answer can be only yes or no and each bool is true or false. If not what can I do to make this work?
using System;
namespace FliptheIntegerBoolean
{
class Program
{
static void Main(string[] args)
{
bool yes;
bool no;
Console.Write("Is a dog a animal? ");
bool yes = Convert.ToBoolean( Console.ReadLine());
switch (yes)
{
case true:
Console.WriteLine("yes it is");
break;
default:
Console.WriteLine("U dumb?");
break;
}
switch (no)
{
case true:
Console.WriteLine("Then what is it? XDD");
break;
default:
Console.WriteLine("U dumb?");
break;
}
Console.ReadKey();
}
}
}
You can use an if ... else... statement
using System;
namespace FliptheIntegerBoolean {
class Program {
static void Main(string[] args) {
Console.Write("Is a dog an animal? ");
string answer = Console.ReadLine();
if (answer == "yes") {
Console.WriteLine("yes it is");
} else if (answer == "no") {
Console.WriteLine("Then what is it? XDD");
} else {
Console.WriteLine("U dumb?");
}
Console.ReadKey();
}
}
}
If you want need result as Boolean
namespace FliptheIntegerBoolean
{
class Program
{
static void Main(string[] args)
{
bool yes;
while (true)
{
Console.Write("Is a dog a animal? ");
string answer = Console.ReadLine();
if (answer.ToLower() == "yes")
{
yes = true;
}
else if (answer.ToLower() == "no")
{
yes = false;
}
else
{
Console.WriteLine("Then what is it? XDD");
continue;
}
Console.WriteLine(yes ? "yes it is" : "Then what is it? XDD");
}
}
}
}

Failing to connect to steam with SteamKit2

I am making a trade offer bot in C# using SteamKit2, and most of the time it is successfully connecting to steam. But some of the time it just freezes when I have it output "Connecting to Steam..." right before client.connect(); is called. It happens often enough that it needs to be fixed, but I don't know what the problem is. Here is my code (a lot was taken from a SteamKit2 tutorial):
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SteamKit2;
namespace ATO
{
class OfferSender
{
string username;
string password;
SteamClient client;
CallbackManager manager;
SteamUser user;
bool isRunning = false;
public OfferSender()
{
}
public void login()
{
Console.Write("Please enter your username: ");
username = Console.ReadLine();
Console.Write("Please enter your password: ");
password = Console.ReadLine();
client = new SteamClient();
manager = new CallbackManager(client);
user = client.GetHandler<SteamUser>();
new Callback<SteamClient.ConnectedCallback>(OnConnected, manager);
new Callback<SteamUser.LoggedOnCallback>(OnLoggedOn, manager);
isRunning = true;
Console.WriteLine("\nConnecting to Steam...\n");
client.Connect();
while(isRunning)
{
manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
}
Console.ReadKey();
}
public void OnConnected(SteamClient.ConnectedCallback callback)
{
if (callback.Result != EResult.OK)
{
Console.WriteLine("Error connecting to Steam: {0}", callback.Result);
isRunning = false;
return;
}
Console.WriteLine("Connected to steam.\nLogging in {0}...\n", username);
user.LogOn(new SteamUser.LogOnDetails {
Username = username,
Password = password
});
}
public void OnLoggedOn(SteamUser.LoggedOnCallback callback)
{
if (callback.Result == EResult.AccountLogonDenied)
{
Console.WriteLine("This account is SteamGuard protected.");
return;
}
if(callback.Result != EResult.OK)
{
Console.WriteLine("Unable to log in to steam {0}\n", callback.Result);
isRunning = false;
return;
}
Console.WriteLine("successfully logged in!");
Environment.Exit(0);
}
}
}
How do I fix this?
Well, after banging my head against the keyboard I finaly spoted that Steam would be requesting an AuthCode like any other new computer or browser login.
And that's it...
The code below handles either AuthCode and TwoFactor authentications:
https://github.com/SteamRE/SteamKit/tree/master/Samples/5.SteamGuard
You need to handle some more callbacks.
Here is how do I log into steam with my bot.
SteamBot.cs
using System;
using SteamKit2;
using System.Collections.Generic;
namespace StackOverflow
{
class SteamBot
{
CallbackManager m_CallbackManager;
SteamUser m_SteamUser;
SteamClient m_SteamClient;
SteamFriends m_SteamFriends;
SteamID m_SteamID;
Dictionary<string, string> m_Config;
public bool isLoggedOn { get; private set; }
public bool isReady { get; private set; }
public SteamBot(string pUsername, string pPassword)
{
isLoggedOn = false;
isReady = false;
m_Config = new Dictionary<string, string>();
m_Config.Add("username", pUsername);
m_Config.Add("password", pPassword);
Init();
RegisterCallbacks();
Connect();
}
private void Init()
{
m_SteamClient = new SteamClient();
m_CallbackManager = new CallbackManager(m_SteamClient);
m_SteamFriends = m_SteamClient.GetHandler<SteamFriends>();
m_SteamUser = m_SteamClient.GetHandler<SteamUser>();
}
private void RegisterCallbacks()
{
m_CallbackManager.Subscribe<SteamClient.ConnectedCallback>(OnConnected);
m_CallbackManager.Subscribe<SteamClient.DisconnectedCallback>(OnDisconnected);
m_CallbackManager.Subscribe<SteamUser.LoggedOnCallback>(OnLoggedOn);
m_CallbackManager.Subscribe<SteamUser.LoggedOffCallback>(OnLoggedOff);
m_CallbackManager.Subscribe<SteamUser.AccountInfoCallback>(OnAccountInfo);
}
public void WaitForCallbacks()
{
m_CallbackManager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
}
public string GetConfigValue(string pKey)
{
return m_Config[pKey];
}
public void Connect()
{
m_SteamClient.Connect();
isReady = true;
}
void OnConnected(SteamClient.ConnectedCallback pData)
{
Console.WriteLine("Connected to Steam! Logging in '{0}'...", GetConfigValue("username"));
SteamUser.LogOnDetails details = new SteamUser.LogOnDetails
{
Username = GetConfigValue("username"),
Password = GetConfigValue("password"),
};
m_SteamUser.LogOn(details);
m_SteamID = m_SteamClient.SteamID;
}
void OnDisconnected(SteamClient.DisconnectedCallback pData)
{
m_SteamClient.Disconnect();
}
void OnLoggedOff(SteamUser.LoggedOffCallback pData)
{
isLoggedOn = false;
}
void OnLoggedOn(SteamUser.LoggedOnCallback pData)
{
if (pData.Result != EResult.OK)
{
Console.WriteLine("Unable to login to Steam: {0} / {1}", pData.Result, pData.ExtendedResult);
return;
}
Console.WriteLine("Successfully logged on!");
isLoggedOn = true;
}
void OnAccountInfo(SteamUser.AccountInfoCallback pData)
{
//Announce to all friends that we are online
m_SteamFriends.SetPersonaState(EPersonaState.Online);
}
}
}
Program.cs
namespace StackOverflow
{
class Program
{
static void Main(string[] args)
{
SteamBot bot = new SteamBot("botname", "password");
while(true)
{
if(bot.isReady)
{
bot.WaitForCallbacks();
}
}
}
}
}
You need to add Steam Directory.Initialize().Wait(); before you attempt to connect so SteamKit can update its internal list of servers, as explained here.

Categories

Resources