forked from proftom/SteamDatabaseBackend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMarketingHandler.cs
43 lines (40 loc) · 1.58 KB
/
MarketingHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* Copyright (c) 2013, SteamDB. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
using System;
using MySql.Data.MySqlClient;
using SteamKit2;
namespace SteamDatabaseBackend
{
public class MarketingHandler
{
public static void OnMarketingMessage(SteamUser.MarketingMessageCallback callback)
{
foreach (var message in callback.Messages)
{
// TODO: Move this query outside this loop
using (MySqlDataReader Reader = DbWorker.ExecuteReader("SELECT `ID` FROM `MarketingMessages` WHERE `ID` = @ID", new MySqlParameter("ID", message.ID)))
{
if (Reader.Read())
{
continue;
}
}
if (message.Flags == EMarketingMessageFlags.None)
{
IRC.SendMain("New marketing message:{0} {1}", Colors.DARK_BLUE, message.URL);
}
else
{
IRC.SendMain("New marketing message:{0} {1} {2}({3})", Colors.DARK_BLUE, message.URL, Colors.DARK_GRAY, message.Flags.ToString().Replace("Platform", string.Empty));
}
DbWorker.ExecuteNonQuery("INSERT INTO `MarketingMessages` (`ID`, `Flags`) VALUES (@ID, @Flags)",
new MySqlParameter("@ID", message.ID),
new MySqlParameter("@Flags", message.Flags)
);
}
}
}
}