Skip to content

Commit b50e702

Browse files
committed
Merge commit '955a5fe1' local watch into main branch
2 parents 277878f + 955a5fe commit b50e702

21 files changed

Lines changed: 10379 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/elm-stuff/
2+
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
{- EVE Online Intel Bot - Local Watch Script - 2024-11-09
2+
3+
This bot watches local and plays an alarm sound when a pilot with bad standing appears.
4+
-}
5+
{-
6+
catalog-tags:eve-online,intel,local-watch
7+
authors-forum-usernames:viir
8+
-}
9+
10+
11+
module Bot exposing
12+
( State
13+
, botMain
14+
)
15+
16+
import BotLab.BotInterface_To_Host_2024_10_19 as InterfaceToHost
17+
import BotLab.NotificationsShim
18+
import Common.EffectOnWindow exposing (MouseButton(..))
19+
import Common.PromptParser as PromptParser
20+
import EveOnline.BotFramework
21+
exposing
22+
( ReadingFromGameClient
23+
, UseContextMenuCascadeNode(..)
24+
, localChatWindowFromUserInterface
25+
)
26+
import EveOnline.BotFrameworkSeparatingMemory
27+
exposing
28+
( waitForProgressInGame
29+
)
30+
31+
32+
goodStandingPatterns : List String
33+
goodStandingPatterns =
34+
[ "good standing", "excellent standing", "is in your" ]
35+
36+
37+
type alias BotMemory =
38+
{}
39+
40+
41+
type alias State =
42+
BotLab.NotificationsShim.StateWithNotifications
43+
(EveOnline.BotFrameworkSeparatingMemory.StateIncludingFramework {} BotMemory)
44+
45+
46+
botMain : InterfaceToHost.BotConfig State
47+
botMain =
48+
{ init = EveOnline.BotFrameworkSeparatingMemory.initState {}
49+
, processEvent =
50+
EveOnline.BotFrameworkSeparatingMemory.processEvent
51+
{ parseBotSettings = PromptParser.parseAllowOnlyEmpty {}
52+
, selectGameClientInstance = always EveOnline.BotFramework.selectGameClientInstanceWithTopmostWindow
53+
, updateMemoryForNewReadingFromGame = always identity
54+
, decideNextStep =
55+
always waitForProgressInGame
56+
>> EveOnline.BotFrameworkSeparatingMemory.setMillisecondsToNextReadingFromGameBase 2000
57+
, statusTextFromDecisionContext = .readingFromGameClient >> botEffectsFromGameClientState
58+
}
59+
}
60+
|> BotLab.NotificationsShim.addNotifications notificationsFunction
61+
62+
63+
notificationsFunction : { statusText : String } -> List BotLab.NotificationsShim.Notification
64+
notificationsFunction botResponse =
65+
[ ( "don't see the local chat window."
66+
, BotLab.NotificationsShim.consoleBeepNotification
67+
[ { frequency = 700, durationInMs = 100 }
68+
, { frequency = 0, durationInMs = 100 }
69+
, { frequency = 700, durationInMs = 100 }
70+
, { frequency = 400, durationInMs = 100 }
71+
]
72+
)
73+
, ( "there is a pilot with bad standing"
74+
, BotLab.NotificationsShim.consoleBeepNotification
75+
[ { frequency = 700, durationInMs = 100 }
76+
, { frequency = 0, durationInMs = 100 }
77+
, { frequency = 700, durationInMs = 500 }
78+
]
79+
)
80+
]
81+
|> List.filterMap
82+
(\( keyword, notification ) ->
83+
if botResponse.statusText |> String.toLower |> String.contains (String.toLower keyword) then
84+
Just notification
85+
86+
else
87+
Nothing
88+
)
89+
90+
91+
botEffectsFromGameClientState : ReadingFromGameClient -> String
92+
botEffectsFromGameClientState parsedUserInterface =
93+
case parsedUserInterface |> localChatWindowFromUserInterface of
94+
Nothing ->
95+
"I don't see the local chat window."
96+
97+
Just localChatWindow ->
98+
let
99+
chatUserHasGoodStanding chatUser =
100+
goodStandingPatterns
101+
|> List.any
102+
(\goodStandingPattern ->
103+
chatUser.standingIconHint
104+
|> Maybe.map (String.toLower >> String.contains goodStandingPattern)
105+
|> Maybe.withDefault False
106+
)
107+
108+
visibleUsers =
109+
localChatWindow.userlist
110+
|> Maybe.map .visibleUsers
111+
|> Maybe.withDefault []
112+
113+
subsetOfUsersWithNoGoodStanding =
114+
visibleUsers
115+
|> List.filter (chatUserHasGoodStanding >> not)
116+
117+
chatWindowReport =
118+
"I see "
119+
++ (visibleUsers |> List.length |> String.fromInt)
120+
++ " users in the local chat. "
121+
++ (subsetOfUsersWithNoGoodStanding |> List.length |> String.fromInt)
122+
++ " with no good standing."
123+
124+
alarmTriggers =
125+
if 1 < (subsetOfUsersWithNoGoodStanding |> List.length) then
126+
[ "There is a pilot with bad standing" ]
127+
128+
else
129+
[]
130+
in
131+
chatWindowReport :: alarmTriggers |> String.join "\n"

0 commit comments

Comments
 (0)