/
today.go
229 lines (168 loc) · 5.76 KB
/
today.go
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
package main
import (
"fmt"
"log"
"math/rand"
"time"
"gopkg.in/telebot.v3"
)
type AnoteToday struct {
}
func (at *AnoteToday) sendAd(ad string) {
var channelId int64
if conf.Dev {
channelId = TelDevAnoteToday
} else {
channelId = TelAnoteToday
}
r := &telebot.Chat{
ID: channelId,
}
m, err := bot.Send(r, ad, telebot.NoPreview, telebot.Silent)
if err != nil {
log.Println(err)
logTelegram(err.Error())
}
num := int64(m.ID)
dataTransaction2("%s__adnum", nil, &num, nil)
}
func (at *AnoteToday) start() {
for {
if at.isNewCycle() {
code := at.generateNewCode()
ad := at.getAd()
at.sendAd(fmt.Sprintf(ad, code))
}
time.Sleep(time.Second * MonitorTick)
}
}
func (at *AnoteToday) isNewCycle() bool {
ks := &KeyValue{Key: "lastAdDay"}
db.FirstOrCreate(ks, ks)
today := time.Now().Day()
if ks.ValueInt != uint64(today) && time.Now().Hour() == SendAdHour {
ks.ValueInt = uint64(today)
db.Save(ks)
return true
}
return false
}
func (at *AnoteToday) generateNewCode() int {
ks := &KeyValue{Key: "dailyCode"}
db.FirstOrCreate(ks, ks)
rand.Seed(time.Now().UnixNano())
min := 100
max := 999
code := rand.Intn(max-min+1) + min
ks.ValueInt = uint64(code)
db.Save(ks)
return code
}
func (at *AnoteToday) getAd() string {
ad := defaultAd5
// cl, err := client.NewClient(client.Options{BaseUrl: AnoteNodeURL, Client: &http.Client{}})
// if err != nil {
// log.Println(err)
// logTelegram(err.Error())
// }
// ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
// defer cancel()
// addr, err := proto.NewAddressFromString(TodayAddress)
// if err != nil {
// log.Println(err)
// logTelegram(err.Error())
// }
// entries, _, err := cl.Addresses.AddressesData(ctx, addr)
// if err != nil {
// log.Println(err)
// logTelegram(err.Error())
// }
// var winner *string
// var amountWinner int64
// for _, e := range entries {
// if winner == nil {
// address := parseItem(e.GetKey(), 0).(string)
// amountWinner = e.ToProtobuf().GetIntValue()
// winner = &address
// } else {
// amount := e.ToProtobuf().GetIntValue()
// if amount > amountWinner {
// amountWinner = amount
// address := parseItem(e.GetKey(), 1).(string)
// winner = &address
// }
// }
// }
// adData, err := getData(AdKey, winner)
// if err != nil {
// ad = defaultAd2
// log.Println(err)
// // logTelegram(err.Error())
// } else {
// adText := parseItem(adData.(string), 0)
// adLink := parseItem(adData.(string), 1)
// ad = adText.(string) + "\n\nRead <a href=\"" + adLink.(string) + "\">more</a>\n\n<a href=\"https://anotedao.com/advertise\"><strong><u>Advertise here!</u></strong></a>\n________________________\nDaily Mining Code: %d"
// winnerKey := "%s__" + *winner
// err := dataTransaction2(winnerKey, nil, nil, nil)
// if err != nil {
// log.Println(err)
// logTelegram(err.Error())
// }
// }
return ad
}
func initAnoteToday() {
at := &AnoteToday{}
go at.start()
}
var defaultAdBak = `<b><u>⭕️ ANOTE 2.0 IS NOW LIVE!</u></b> 🚀
We are proud to announce that Anote 2.0 is now available for mining.
We now have our own wallet (app.anotedao.com) which is used both as a wallet and a tool for mining. Stay tuned for more exciting news, information and tutorials!
You can find tutorial how to mine here: anotedao.com/mining
Join @AnoteDAO group for help and support!
________________________
@AnoteRobot Daily Mining Code: %d
`
var defaultAd = `Invite 3 or more users to Anote and your mining power will get multiplied by 10. You will get the referral link if you send /ref command to the miner.
You can find tutorial how to mine here: anotedao.com/mine
Join @AnoteDAO group for help and support!
<a href="https://anotedao.com/advertise"><strong><u>Advertise here!</u></strong></a>
________________________
@AnoteRobot Daily Mining Code: %d
`
var defaultAd1 = `Stake 10 AINTs or refer 3 new users and your mining power will get multiplied by 10.
You can find AINT tutorial here: anotedao.com/aint
<a href="https://anotedao.com/advertise"><strong><u>Advertise here!</u></strong></a>
________________________
@AnoteRobot Daily Mining Code: %d
`
var defaultAd2 = `Anote Staking Is Live 🚀
You can now stake your anotes and receive up to 70%% APY (Annual Percentage Yield). This means that if you stake 100 anotes, you will receive 70 more in a year. Payouts are done automatically every 10 minutes.
Read more about how to do it in the tutorial:
anotedao.com/staking
<a href="https://anotedao.com/advertise"><strong><u>Advertise here!</u></strong></a>
________________________
@AnoteRobot Daily Mining Code: %d
`
var defaultAd3 = `Mint AINT With Anotes 🚀
You can now use anotes to mint AINT which provides you with an opportunity for a long term investment because AINT behaves like a mining power for Anote.
Mint it by clicking "Mint AINT" tab in your wallet:
app.anotedao.com
<a href="https://anotedao.com/advertise"><strong><u>Advertise here!</u></strong></a>
________________________
@AnoteRobot Daily Mining Code: %d
`
var defaultAd4 = `Create Your Own Token 🚀
You can now create your own token on Anote chain and list it in Anote wallet. To create the token and list it, use our dev tool:
dev.anotedao.com
<a href="https://anotedao.com/advertise"><strong><u>Advertise here!</u></strong></a>
________________________
@AnoteRobot Daily Mining Code: %d
`
var defaultAd5 = `Mine More Anotes 🚀
<b><u>Additional 25%% for each referred user!</u></b>
Invite your friends to Anote and you will mine 25%% more aints every day for each referred user. You can find your referral link in your wallet (app.anotedao.com) or in menu if you open @AnoteRobot.
<a href="https://anotedao.com/advertise"><strong><u>Advertise here!</u></strong></a>
________________________
@AnoteRobot Daily Mining Code: %d
`